• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor

    Reply
    Active Contributor
    Posts: 26
    Registered: ‎07-17-2012
    Accepted Solution

    iLogic and sheetmetal Properties

    386 Views, 4 Replies
    07-17-2012 02:59 PM

    Hello,

    As starting on my first iLogic project please feel free to contribute as much a possible.

    I intend to do the following;

     

    1.) Retrieve the sheet metal material/style from an assembly and store into a String or a Text parameter

     

    2.) Fetch the list of sheet metal styles in the Inventor library (as plenty of them have been populated and shared among as a library)

     

    3.) Change the sheet metal material and style

     

    I am guessing (1) and (3) should be vey similar.

     

    A l s o : if someone can let me know on how to remove duplicate items in a list parameter ??

    Thanking as a down payment ;0

     

    Wajih

    Please use plain text.
    *Expert Elite*
    mrattray
    Posts: 1,485
    Registered: ‎09-13-2011

    Re: iLogic and sheetmetal Properties

    07-18-2012 04:55 AM in reply to: WHassan

    Sets a style as current:

     

    Dim style As String
    style = "your sheet metal rule"
    Dim oSheetMetalCompDef As SheetMetalComponentDefinition
    oSheetMetalCompDef = ThisDoc.Document.componentdefinition
    oSheetMetalCompDef.SheetMetalStyles.Item(style).Activate

     Sets a material:

     

    iProperties.Material = "your material"

     

    Retrievies material:

     

    yourVariable = iProperties.Material

    Retrieves active style:

     

    Dim oSheetMetalCompDef As SheetMetalComponentDefinition
    oSheetMetalCompDef = ThisDoc.Document.componentdefinition
    yourStyle = oSheetMetalCompDef.ActiveSheetMetalStyle.Name

     This retrieves each style in the document and displays a dialog for each one (there's better ways to do this but I'm not sure what your goal is):

     

    Dim style As String
    Dim styleCount As Integer
    Dim oSheetMetalCompDef As SheetMetalComponentDefinition
    oSheetMetalCompDef = ThisDoc.Document.componentdefinition
    styleCount = oSheetMetalCompDef.SheetMetalStyles.Count
    For i = 1 To styleCount
    	style = oSheetMetalCompDef.SheetMetalStyles.Item(i).Name
    	MsgBox(style)
    Next

     

     

     

    Mike (not Matt) Rattray

    Please use plain text.
    Active Contributor
    Posts: 26
    Registered: ‎07-17-2012

    Re: iLogic and sheetmetal Properties

    07-18-2012 07:28 AM in reply to: mrattray

    Thank you Mike.

     

    Just have a few supplimentary questions;

     

    It works for the part (.ipt), but when I try to retrive the styles for individual parts from an assembly (.ism); it prompts for an error that styles could not be retrived.

     

    But I will make this work by fetching the styles within the part and then pass the part variable to the assembly.

     

    Kudos.

     

     

    Please use plain text.
    *Expert Elite*
    mrattray
    Posts: 1,485
    Registered: ‎09-13-2011

    Re: iLogic and sheetmetal Properties

    07-18-2012 08:05 AM in reply to: WHassan

    That's because the code above is drilling into a part definition, it will fail if you use it on an assembly because an assembly doesn't have part properties. The code could be rewritten to drill into the part's definition from the assembly level, but I just had a large project dropped on my desk and don't have time to cook it up for you.

    Mike (not Matt) Rattray

    Please use plain text.
    Active Contributor
    Posts: 26
    Registered: ‎07-17-2012

    Re: iLogic and sheetmetal Properties

    07-18-2012 10:46 AM in reply to: mrattray

    Thank you for your support and dedication to help others out.

     

    This is how I got my task working, except for the matter that the sheetmetal style does not update until I manually go to the part level and update it via rules.

     

     

     

    ' ********** Rule for the Assembly ***********************

    ' **** Key paramters for the assembly *****************

    '  1) strSelectedStyle (Text)         

    '  2) optChangeStyle (True/False)

     

     

    If optChangeStyle = True Then

              Parameter( "bracket_wraper:1, "srtDesiredStyle") = strSelectedStyle

    End If

     

    ---------------------------------------------------------------------------------------------------------------

     

    ' ********** Rule for the Sheetmetal Part ***********************

    ' ************** Key paramters for the ipt  ********************

    '    1) strOriginalStyle (Text)

    '    2) srtDesiredStyle (Text)

     

    srtOriginalStyle = SheetMetal.GetActiveStyle

     

    SheetMetal.SetActiveStyle(srtDesiredStyle)

     

     

     

     

    Is there a way to pass the SheetMetal style directly from the assembly to the part file so that all the updates are synced.

     

    Thank you

     

     

     

     

     

     

    Please use plain text.