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 Rule to populate finished material size based on model geometry selection

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
wseaston
2105 Views, 2 Replies

iLogic Rule to populate finished material size based on model geometry selection

I created the following user parameters:

 

Thickness

Width

Length

Dia

 

I then created a Custom iProperty which consisted of the following "formula":    Finished Material Size = <Thickness> x <Width> x <Length> Lg.

 

eg. of Finished Material Result :        Finished Material Size = 6 x 25 x 300 Lg.

 

The problem comes up when dealing with diametrical components as the above formula will only populate for square or rectangular parts.

 

I have an idea which would work if I could use iLogic code to populate the Finished Material Size iProperty. I have tried but failed.

 

This is my plan.

 

First I created another user parameter called "Geometry Type" which has a drop down selection of either "DIA" or "SQUARE, RECTANGULAR"

I then created the following iLogic code to set 0 as the value for the "unused" size parameters

 

If PART_GEOMETRY = "DIA" Then WIDTH = "0"
If PART_GEOMETRY = "DIA" Then THICKNESS = "0"
If PART_GEOMETRY = "SQUARE, RECTANGULAR" Then DIA = "0"

 The part I just can't get to work is as follows.

 

I need some iLogic code which will populate the "FINISHED MATERIAL SIZE" custom iproperty with one of the following based on my "GEOMETRY TYPE" selection.

 

"DIA" would return the following to "FINISHED MATERIAL SIZE":      = Ø <Dia> x <Length> Lg.

 

While

 

"SQUARE, RECTANGULAR" would return the following to "FINISHED MATERIAL SIZE":     = <THICKNESS> x <WIDTH> x <LENGTH> Lg.

 

I tried the following code but it does not work:

 

If PART_GEOMETRY = "DIA" Then iProperties.Value("Custom", "FINISHED MATERIAL SIZE")= "Ø"DIA "x" LENGTH "Lg."
If PART_GEOMETRY = "SQUARE, RECTANGULAR" Then iProperties.Value("Custom", "FINISHED MATERIAL SIZE")= THICKNESS "x" WIDTH "x" LENGTH "Lg."

 

 Does anyone have any ideas on this?

 

Thanks

 

2 REPLIES 2
Message 2 of 3
wseaston
in reply to: wseaston

I figured out a solution to my problem...

 

If anyone is interested, here is the code I ended up using which does the job I wanted it to.

 

If PART_GEOMETRY = "DIA" Then WIDTH = "0"
If PART_GEOMETRY = "DIA" Then THICKNESS = "0"
If PART_GEOMETRY = "SQUARE, RECTANGULAR" Then DIA = "0"

dfms = "=Ø<DIA> x <LENGTH> Lg."
sfms = "=<THICKNESS> x <WIDTH> x <LENGTH> Lg."

If PART_GEOMETRY = "DIA" Then iProperties.Value("Custom", "FINISHED MATERIAL SIZE")= dfms
If PART_GEOMETRY = "SQUARE, RECTANGULAR" Then iProperties.Value("Custom", "FINISHED MATERIAL SIZE")= sfms

 

Message 3 of 3
rhasell
in reply to: wseaston

Hi

 

I do something similar, except I use a list to change the Part/material type, Curtis Waguespack helped me with the code for the list, I have modified it to suit my environment. The list allows me to change a part on an adhoc basis and also sets up the BOM for sorting and View Rep settings. I even have a section for a custom part. This might be of some use to you?

 

Sub Main oSELECT

Dim resu1t As String="Result"

Dim Matt As New ArrayList
Matt.Add("SHS")
Matt.Add("RHS")
Matt.Add("CHS")
Matt.Add("CLEAT")
Matt.Add("PLATE")
Matt.Add("FLAT BAR")
Matt.Add("E-ANGLE")
Matt.Add("U-ANGLE")
Matt.Add("Rope Extrusion")
Matt.Add("Extrusion")
Matt.Add("Vanilla")
Matt.Add("Custom")

'Display table and get the selection
resu1t=InputListBox("Change Component type", Matt, resu1t, _
Title := "Componet type", ListName := "Component Type")

'Set iProperties based on the selection.
If resu1t="SHS" Then
iProperties.Value("Project", "Description")="=<HEIGHT> x <WIDTH> x <THICK> SHS"
iProperties.Value("Project", "Stock Number")= "=<HEIGHT> x <WIDTH> x <THICK> x <LENGTH> SHS"
iProperties.Value("Custom", "TYPE")= "SHS"
Call oFILLET
'End If

ElseIf resu1t="RHS" Then
iProperties.Value("Project", "Description")="=<HEIGHT> x <WIDTH> x <THICK> RHS"
iProperties.Value("Project", "Stock Number")= "=<HEIGHT> x <WIDTH> x <THICK> x <LENGTH> RHS"
iProperties.Value("Custom", "TYPE")= "RHS"
Call oFILLET
'End If

ElseIf resu1t="CHS" Then
iProperties.Value("Project", "Description")="=Ø<OD> x <THICK> CHS"
iProperties.Value("Project", "Stock Number")= "=Ø<OD> x <THICK> x <LENGTH> CHS"
iProperties.Value("Custom", "TYPE")= "CHS"
'iLogicVb.Automation.GetRule(ThisDoc.Document, "Fillet_Rule").IsActive = False
Call oFllt_supp
'End If

ElseIf resu1t="CLEAT" Then
iProperties.Value("Project", "Description")="=<HEIGHT> x <WIDTH> x <THICK> CLEAT"
iProperties.Value("Project", "Stock Number")= "=<THICK> THK CLEAT"
iProperties.Value("Custom", "TYPE")= "CLEAT"
Call oFllt_supp
'End If

ElseIf resu1t="PLATE" Then
iProperties.Value("Project", "Description")="=<HEIGHT> x <WIDTH> x <THICK> PLATE"
iProperties.Value("Project", "Stock Number")= "=<THICK> THK PLATE"
iProperties.Value("Custom", "TYPE")= "PLATE"
Call oFllt_supp

ElseIf resu1t="FLAT BAR" Then
iProperties.Value("Project", "Description")="=<WIDTH> x <THICK> FB"
iProperties.Value("Project", "Stock Number")= "=<WIDTH> x <THICK> x <LENGTH> FB"
iProperties.Value("Custom", "TYPE")= "FLAT"
iProperties.Value("Project", "Cost Center")="FLAT"
Call oFllt_supp

ElseIf resu1t="E-ANGLE" Then
iProperties.Value("Project", "Description")="=<HEIGHT> x <THICK> EA"
iProperties.Value("Project", "Stock Number")= "=<HEIGHT> x <THICK> x <LENGTH> EA "
iProperties.Value("Custom", "TYPE")= "ANGLE"
iProperties.Value("Project", "Cost Center")="ANGLE"
Call oFllt_supp

ElseIf resu1t="U-ANGLE" Then
iProperties.Value("Project", "Description")="=<HEIGHT> x <WIDTH> x <THICK> UA"
iProperties.Value("Project", "Stock Number")= "=<HEIGHT> x <WIDTH> x <THICK> x <LENGTH> UA"
iProperties.Value("Custom", "TYPE")= "ANGLE"
iProperties.Value("Project", "Cost Center")="ANGLE"
Call oFllt_supp

ElseIf resu1t="Rope Extrusion" Then
iProperties.Value("Project", "Description")="=<EXTR> EXTRUSION"
iProperties.Value("Project", "Stock Number")= "=<EXTR> EXTRUSION x <LENGTH>"
iProperties.Value("Custom", "TYPE")= "XTR"
iProperties.Value("Project", "Cost Center")="XTR"
Call oFllt_supp

ElseIf resu1t="Extrusion" Then
iProperties.Value("Project", "Description")="=<HEIGHT> x <WIDTH> x <THICK> EXTRUSION"
iProperties.Value("Project", "Stock Number")= "=<HEIGHT> x <WIDTH> x <THICK> x <LENGTH> EXTRUSION"
iProperties.Value("Custom", "TYPE")= "EXTRUSION"
Call oFllt_supp

ElseIf resu1t="Vanilla" Then
iProperties.Value("Project", "Description")=""
iProperties.Value("Project", "Stock Number")= ""
iProperties.Value("Custom", "TYPE")= "N/A"
iProperties.Value("Project", "Cost Center")="N/A"
Call oFllt_supp

ElseIf resu1t="Custom" Then
'Capture new TYPE
oTYPE = InputBox("Set TYPE", "Component Type", iProperties.Value("Custom", "TYPE"))
iProperties.Value("Custom", "TYPE")=oTYPE
iProperties.Value("Project", "Description")="=<HEIGHT> x <WIDTH> x <THICK> <TYPE>"
iProperties.Value("Project", "Stock Number")= "=<HEIGHT> x <WIDTH> x <THICK> x <LENGTH> <TYPE>"
iProperties.Value("Project", "Cost Center")=oTYPE
Call oFllt_supp

End If
'If the form closed, then open it again.
iLogicForm.ShowGlobal("Parameters", FormMode.NonModal)
End Sub

Private Sub oFILLET
' Create Custom Paramteres if not done.
Dim oPartDoc as PartDocument = ThisDoc.Document
Dim userParams As UserParameters = oPartDoc.ComponentDefinition.Parameters.UserParameters
Try
  RAD_Params = oPartDoc.ComponentDefinition.Parameters("RO")
Catch
    Dim newParam As UserParameter = userParams.AddByExpression("RO", 0, "mm")
End Try
Try
  RAD2_param = oPartDoc.ComponentDefinition.Parameters("RI")
Catch
    Dim newParam As UserParameter = userParams.AddByExpression("RI", 0, "mm")
End Try
''Call rule set Values.
'Call oRAD
''The above rule does not go active, so I put another rule in the part which is suppressed.
'' this Unsurpresses it.
iLogicVb.Automation.GetRule(ThisDoc.Document, "Fillet_Rule").IsActive = True
Return
End Sub

 

Private Sub oFllt_supp
iLogicVb.Automation.GetRule(ThisDoc.Document, "Fillet_Rule").IsActive = False
Return
End Sub

 

Reg
2024.2
Please Accept as a solution / Kudos

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

Post to forums  

Autodesk Design & Make Report