Material change using iLogic based on form drop down.

Material change using iLogic based on form drop down.

tschaeferZNBXX
Advisor Advisor
1,860 Views
11 Replies
Message 1 of 12

Material change using iLogic based on form drop down.

tschaeferZNBXX
Advisor
Advisor

I am looking for a way to set the material style based on what a user selects from a drop down in a custom form.

 

I have added a User Parameter with a multi-value list which can be selected from a custom form.  I want to drive the sheet metal properties based on what the individual chooses from the drop down.  I believe this should be pretty easy but I am not sure where to start here. 

Thomas "Matt" Schaefer
Engineering Tooling and Vault Manager for Material Handling Systems MHS


*AU Speaker 2018*
* AU Speaker 2017 *
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.
0 Likes
1,861 Views
11 Replies
Replies (11)
Message 2 of 12

BrandonBG
Collaborator
Collaborator

https://www.cadlinecommunity.co.uk/hc/en-us/articles/207282775-Inventor-2016-iLogic-Create-Multivalu...

 

After that, it's pretty straightforward If-Then, right? If Material=Aluminum Then Thickness=Something.

 

Brandon

0 Likes
Message 3 of 12

tschaeferZNBXX
Advisor
Advisor
This changed my drop down to a static value. I think I have figured out what I actually want now. Going to have 2 different drop downs, one for thickness and one for material. Have iLogic then to drive the change in the iProperties and update my physical properties.
Thomas "Matt" Schaefer
Engineering Tooling and Vault Manager for Material Handling Systems MHS


*AU Speaker 2018*
* AU Speaker 2017 *
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.
0 Likes
Message 4 of 12

tschaeferZNBXX
Advisor
Advisor
Does anyone know how to do this? I have several material styles set up but it will not set the material style based on the parameter drop down.
Thomas "Matt" Schaefer
Engineering Tooling and Vault Manager for Material Handling Systems MHS


*AU Speaker 2018*
* AU Speaker 2017 *
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.
0 Likes
Message 5 of 12

rjay75
Collaborator
Collaborator

Do you have sheet metal styles set up. With the sheet metal style you can specifiy material, thickness and other settings. Then you can use iLogic to set the selected sheet metal style.

 

SyntaxEditor Code Snippet

SheetMetal.SetActiveStyle("styleName")

 

This will has the benifit of just making one selection to change all your properties. 

0 Likes
Message 6 of 12

tschaeferZNBXX
Advisor
Advisor
I have tried this command but it will not change it to the correct style. It does not set the active style as what I put in the "".
Thomas "Matt" Schaefer
Engineering Tooling and Vault Manager for Material Handling Systems MHS


*AU Speaker 2018*
* AU Speaker 2017 *
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.
0 Likes
Message 7 of 12

tschaeferZNBXX
Advisor
Advisor
Here is what I tried to do.

If Parameter.ValueForEquals("THICKNESS", "1/8 in")Then
SheetMetal.SetActiveStyle("1/8")
End If

Where 1/8 is the style I want it to be set to.
Thomas "Matt" Schaefer
Engineering Tooling and Vault Manager for Material Handling Systems MHS


*AU Speaker 2018*
* AU Speaker 2017 *
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.
0 Likes
Message 8 of 12

rjay75
Collaborator
Collaborator

A couple of things that might be causing the errors in your code.

 

Parameter.ValueForEquals("THICKNESS", "1/8 in") -> This code is looking for a component named THICKNESS and a parameter named "1/8 in"

 

It looks like you're trying to test a THICKNESS parameter for the value of 1/8 in.

SyntaxEditor Code Snippet

'If THICKNESS is a text value

'Internal Rule:
If THICKNESS = "1/8 in"Then
  SheetMetal.SetActiveStyle("1/8")
End If

'External Rule:
If Parameter("THICKNESS") = "1/8 in"Then
  SheetMetal.SetActiveStyle("1/8")
End If

'If it is a number value

'Internal Rule:
If THICKNESS = 0.125 Then
  SheetMetal.SetActiveStyle("1/8")
End If

'External Rule:
If Parameter("THICKNESS") = 0.125 Then
  SheetMetal.SetActiveStyle("1/8")
End If

 

 

Attached is also a document that shows different ways to set the SheetMetal style to a selectable value. (This file has the sheetmetal styles and materials setup to the same name for legacy reasons. The names do not need to be the same.)

 

Also if you're using SheetMetalStyles to control settings make sure that your sheet metal settings are set properly.

 

smsettings.PNG

 

Thickness and Material should be use to set by the rule.

 

 

 

0 Likes
Message 9 of 12

tschaeferZNBXX
Advisor
Advisor

We are trying to set up a rule within a Form that changes the Sheet Metal Rule based on the choice an individual makes from the drop down when a part is created.  Here is a screen shot of the form we have created.  I am assuming that the same can be down for the Material drop down as well by simply changing the property the IF THEN statement is looking at?

Form.PNG

Thomas "Matt" Schaefer
Engineering Tooling and Vault Manager for Material Handling Systems MHS


*AU Speaker 2018*
* AU Speaker 2017 *
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.
0 Likes
Message 10 of 12

rjay75
Collaborator
Collaborator

Ok. To change all the components individually via you would set these settings.

 

 

SyntaxEditor Code Snippet

'MessageBox.Show(newMaterial.Name)
Dim curDoc As PartDocument = ThisApplication.ActiveDocument
Dim smComp As SheetMetalComponentDefinition = ThisDoc.Document.ComponentDefinition
'Set defaults to NOT use the sheet metal style
smComp.UseSheetMetalStyleMaterial = False
smComp.UseSheetMetalStyleThickness = False
Parameter("Thickness") = 0.15

Dim newMaterial As Asset  = ThisApplication.ActiveMaterialLibrary.MaterialAssets.Item("STL,11GA,1008") 'Note: Returns a Asset Object
curDoc.ActiveMaterial = newMaterial 'Must assign an Asset Object to ActiveMaterial From the library

 

Note:  the sheet metal thickness parameter is Thickness. 

0 Likes
Message 11 of 12

tschaeferZNBXX
Advisor
Advisor

This just sets the "Thickness" parameter.  I want the part file to change the "Sheet Metal Style" based on the users input from the drop down.  I have set parameters to populate the drop down and set up sheet metal rules for each of the choices in the drop down.  So if an idividual selects "1/8 in" as their thickness, the "Sheet Metal Style" would set the rule to 1/8.  

Sheet metal styles.PNG

Thomas "Matt" Schaefer
Engineering Tooling and Vault Manager for Material Handling Systems MHS


*AU Speaker 2018*
* AU Speaker 2017 *
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.
0 Likes
Message 12 of 12

rjay75
Collaborator
Collaborator

Then using your other code it would be.

 

 

'Comparing to the value as it appears in the drop down.
Select Case Parameter("THICKNESS")
Case "1/8 in" SheetMetal.SetActiveStyle("1/8")
Case Else
'Do Nothing End Select 'If the values in the dropdown match the names of the sheetmetal styles SheetMetal.SetActiveStyle(THICKNESS)

You may want to consider having the drop down match the names of the styles. Otherwise you'd need to have a if or select statement for each different style.

 

Don't forget to have the sheetmetal options to use the Thickness from the style. 

0 Likes