Set Sheet Metal Gage

Solution Partner Creator Solution Partner Creator
Solution Partner Creator

Hi

 

I'm trying to set Gage to Sheet Metal document (not using Excel Gage table)

 

I have some Sheet Metal document open.

In this document, i have to apply Gage stored in Material.mtl

Just if i go to Material Table, set some material to the sheet metal part (or even do not set material)

and choose one of the gages from combo box (not excel gages file)

 

the code:

MaterialTable.SetDocumentToGageTableAssociation(SheetMetalDocument, GageNameToSet, GageTable, false, false);

 

Every time i get E_FAIL error at runtime.

I tried to pass different parameters as GageNameToSet and GageTable

In my case GageNameToSet is "G 1.0 V10" and it's exists in Gages combo box.

The GageTable, actually i don't know what to pass. i tried "materials.mtl", empty string, name of the material, but still E_FAIL.

 

Please help

 

7 REPLIES

Re: Set Sheet Metal Gage

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Hi,

You can set sheet metal gae using the code given below.

Gage table is the name of the table. In this case I have used "Stainless Steel".

You can create a new sheet metal file in SE and try this code.

 

Imports System.Runtime.InteropServices

Module Module2
    Sub Main()
        Dim objApplication As SolidEdgeFramework.Application = Nothing
        Dim objSMDoc As SolidEdgePart.SheetMetalDocument = Nothing
        Dim myMatTable As SolidEdgeFramework.MatTable = Nothing
        Dim bUseNFFromExcel As Boolean = True
        Dim bAddAssociation As Boolean = True
        Dim strInputGage As String = "16 gage"
        Dim strInutGageTable As String = "Stainless Steel"

        Try
            objApplication = Marshal.GetActiveObject("SolidEdge.Application")
            ' Get the material table object from the application
            myMatTable = objApplication.GetMaterialTable()

            objSMDoc = objApplication.ActiveDocument
            If (objSMDoc Is Nothing) Then
                MsgBox("Failed to get Sheet Metal Document object.")
            End If
            Console.WriteLine("Adding 'Document to Gage Table' Association!")
            Call myMatTable.SetDocumentToGageTableAssociation(objSMDoc, strInputGage, strInutGageTable, bUseNFFromExcel, bAddAssociation)


        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Module

 

 

Hope this helps.

 

Regards,

Kaustubh

Re: Set Sheet Metal Gage

Solution Partner Creator Solution Partner Creator
Solution Partner Creator

Hi

 

Thank you for your advice.

 

I tried to do as you show in your code.

But this code uses gages from the gages excel file.

In my case, i have to use gages without excel. just like i go to gages tab in material table, don't check "use excel", but just select some gage from the gages dropdown.

 

I can do workaround , just use gage data (neutral factor,bend radius e.t.c) from my table directly to variables, but usually, if some "manual" ability is present in Solid Edge (select gage not from excel), also there is a way to do it with code (i think so).

 

 

Re: Set Sheet Metal Gage

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Hi @AddEx,

I could not find any API matching your requirement. Can you plese file an IR for this?.

Please let me know if you need any help on "How to log an IR?".

 

Regards,

Kaustubh

Re: Set Sheet Metal Gage

Solution Partner Creator Solution Partner Creator
Solution Partner Creator
Hi

For this time i did workaround, but if it can be improved i would like to report IR.
How can i do it?

Re: Set Sheet Metal Gage

Pioneer
Pioneer

Hi AddEx,

 

Can you provide the workaround which you have used for changing the Gage value only?

 

Thanks in Advance,

Onkar

Re: Set Sheet Metal Gage

Pioneer
Pioneer
Hi AddEx,

You can try this method. Hope this helps.

"materialTable.ApplyGageFromLibraryToDoc(doc, "20 gage", "Materials-GOST")"

-OnkarP
Highlighted

Betreff: Set Sheet Metal Gage

Honored Contributor
Honored Contributor

Hi @AddEx

 

 

 

maybe Your problem is solved at anyway, but due to I also just writing a macro for offering an easier access to the materials and gages, I also have seen, that there is no direct API call for reading out the used and saved gages.

 

 

What I did to bring them into my list is, to export the material table into an XML file (one line of code) and read out the PSMGages from there (only a couple lines of code.

 

So I bring in the current saved gages definitions.

 

Maybe this helps.

 



regards
Wolfgang