Inventor General Discussion

Inventor General Discussion

Reply
Active Contributor
WHassan
Posts: 32
Registered: ‎07-17-2012
Message 1 of 5 (700 Views)
Accepted Solution

iLogic and sheetmetal Properties

700 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

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

 

 

 

*Expert Elite*
mrattray
Posts: 2,515
Registered: ‎09-13-2011
Message 2 of 5 (690 Views)

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

Active Contributor
WHassan
Posts: 32
Registered: ‎07-17-2012
Message 3 of 5 (678 Views)

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.

 

 

*Expert Elite*
mrattray
Posts: 2,515
Registered: ‎09-13-2011
Message 4 of 5 (672 Views)

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

Active Contributor
WHassan
Posts: 32
Registered: ‎07-17-2012
Message 5 of 5 (664 Views)

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

 

 

 

 

 

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!