Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic and sheetmetal Properties

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
WHassan
2128 Views, 5 Replies

iLogic and sheetmetal Properties

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

5 REPLIES 5
Message 2 of 6
mrattray
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

Message 3 of 6
WHassan
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.

 

 

Message 4 of 6
mrattray
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

Message 5 of 6
WHassan
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

 

 

 

 

 

 

Message 6 of 6
albertuan
in reply to: mrattray

Many thanks to Mike Rattray,

 

I found everywhere how to activate a style once you get the name but only in his post how to get the SHEETMETAL STYLES name list.

 

So that's how I use it for an external rule function ready to be assigned to a multi value parameter.

 

 

' Return an arraylist of names of the custom sheetmetal syles 
Function GetSMStyleNames() As ArrayList Dim StileNameSimpleList As New ArrayList For Each TmpStyle As SheetMetalStyle In ThisDoc.Document.componentdefinition.SheetMetalStyles If TmpStyle.Name.ToLower.IndexOf("default") = -1 StileNameSimpleList.Add(TmpStyle.Name) End If Next Return StileNameSimpleList End Function

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report