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 Parameter Description help

7 REPLIES 7
Reply
Message 1 of 8
devonjohnson
1557 Views, 7 Replies

ilogic Parameter Description help

Hi there,

 

I have been using ilogic code I found (from Curtis W) which looks at the material selected in a part and then populates the 'Description' field with a formula.  This works great but for SHS I want to include the miter angles so I need the code to look to see if parameter "ANG1" or "ANG2" exists and if so then populate with the relevant formula.  Otherwise populate with the standard formula.  The code below includes the 'if' statements which are not working, if anyone could offer any help it would be greatly appreciated!! 

 

 

Sub Main oSELECT


If iProperties.Material = "ALUMINIUM" Then
iProperties.Value("Project", "Description")="=<HEIGHT> x <WIDTH> x <THK> THK"
iProperties.Value("Custom", "TYPE")= "ALUMINIUM"

 

ElseIf iProperties.Material = "SS ALLTHREAD" Then
iProperties.Value("Project", "Description")="=M<DIA> x <LENGTH> LG"
iProperties.Value("Custom", "TYPE")= "SS ALLTHREAD"

 

ElseIf iProperties.Material = "SS ANGLE" Then
iProperties.Value("Project", "Description")="=<HEIGHT>x<WIDTH>x<THK> x <LENGTH> LG"
iProperties.Value("Custom", "TYPE")= "SS ANGLE"

 

ElseIf iProperties.Material = "SS FLAT" Then
iProperties.Value("Project", "Description")="=<WIDTH> x <THK> x <LENGTH> LG"
iProperties.Value("Custom", "TYPE")= "SS FLAT"

 

ElseIf iProperties.Material = "SS HEX" Then
iProperties.Value("Project", "Description")="=<HEIGHT>AF x <LENGTH> LG"
iProperties.Value("Custom", "TYPE")= "SS HEX"

 

ElseIf iProperties.Material = "SS PIPE" Then
iProperties.Value("Project", "Description")="=Ø<DIA> x <LENGTH> LG"
iProperties.Value("Custom", "TYPE")= "SS PIPE"

 

ElseIf iProperties.Material = "SS PLATE" Then
iProperties.Value("Project", "Description")="=<HEIGHT> x <WIDTH> x <THK> THK"
iProperties.Value("Custom", "TYPE")= "SS PLATE"

 

ElseIf iProperties.Material = "SS RHS" Then


If Parameter = ("ANG1") Then
iProperties.Value("Project", "Description")="=<HEIGHT>x<WIDTH>x<THK> x <LENGTH> LG (<ANG1> / 0)"
iProperties.Value("Custom", "TYPE")= "SS RHS"

End If

If Parameter = ("ANG2") Then
iProperties.Value("Project", "Description")="=<HEIGHT>x<WIDTH>x<THK> x <LENGTH> LG (<ANG1> / <ANG2>)"
iProperties.Value("Custom", "TYPE")= "SS RHS"


Else
iProperties.Value("Project", "Description")="=<HEIGHT>x<WIDTH>x<THK> x <LENGTH> LG"
iProperties.Value("Custom", "TYPE")= "SS RHS"

End If


ElseIf iProperties.Material = "SS ROUND" Then
iProperties.Value("Project", "Description")="=Ø<DIA> x <LENGTH> LG"
iProperties.Value("Custom", "TYPE")= "SS ROUND"

 

ElseIf iProperties.Material = "SS SHEET" Then
iProperties.Value("Project", "Description")="=<HEIGHT> x <WIDTH> x <THK> THK"
iProperties.Value("Custom", "TYPE")= "SS SHEET"

 

ElseIf iProperties.Material = "SS SQUARE" Then
iProperties.Value("Project", "Description")="=<HEIGHT>SQ <LENGTH> LG"
iProperties.Value("Custom", "TYPE")= "SS SQUARE"

 

ElseIf iProperties.Material = "SS TUBE" Then
iProperties.Value("Project", "Description")="=<HEIGHT> x <WIDTH> x <LENGTH> LG"
iProperties.Value("Custom", "TYPE")= "SS TUBE"

 

ElseIf iProperties.Material = "UHMW, White" Then
iProperties.Value("Project", "Description")="=<HEIGHT> x <WIDTH> x <THK> THK"
iProperties.Value("Custom", "TYPE")= "UHMW, White"

 

ElseIf iProperties.Material = "ACETAL" Then
iProperties.Value("Project", "Description")="=<HEIGHT> x <WIDTH> x <THK> THK"
iProperties.Value("Custom", "TYPE")= "ACETAL"

 

End If

 

End Sub

 

 

Thanks,
Devon Johnson

Inventor 2020
7 REPLIES 7
Message 2 of 8
VdVeek
in reply to: devonjohnson

Where do the parameters "ANG1" and "ANG2" come from?

It looks like the Miter is created by a split. So when you look for a Split feature you find a Miter.

This iLogic Rule is working in the part environment.

 

If Feature.IsActive("Split1") = True
iProperties.Value("Project", "Description")="Miter 1"
End If

An easy way to find all the posible parameters in a rule is to select the part name under the Model Tab and RMC and click Capture Current State. This shows all the posible parameters with there names.

 

Rob.

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
Message 3 of 8
devonjohnson
in reply to: VdVeek

If the section needs to have mitres, we use the cut extrusion feature and then rename the angular dimension to get it to show up in the iproperties 'Description'.  I can get the code to work if these parameters exist, but if they don't I get errors because the code is looking for them.  I need to know how to change the code to skip these parameters if they don't exist.  Any ideas on how to do this?

Thanks,
Devon Johnson

Inventor 2020
Message 4 of 8
mrattray
in reply to: devonjohnson

ElseIf...

  Try
    iProperties.Value("Project", "Description")="=<HEIGHT>x<WIDTH>x<THK> x <LENGTH> LG (<ANG1> / <ANG2>)"
    iProperties.Value("Custom", "TYPE")= "SS RHS"
  Catch
    Try
      iProperties.Value("Project", "Description")="=<HEIGHT>x<WIDTH>x<THK> x <LENGTH> LG (<ANG1> / 0)"
      iProperties.Value("Custom", "TYPE")= "SS RHS"
    Catch
      iProperties.Value("Project", "Description")="=<HEIGHT>x<WIDTH>x<THK> x <LENGTH> LG"
      iProperties.Value("Custom", "TYPE")= "SS RHS"
    End Try
  End Try

ElseIf...

 Try using this instead of the extra if/else statement.

Mike (not Matt) Rattray

Message 5 of 8
devonjohnson
in reply to: mrattray

Thanks for that, its nearly there, the first expression is being added in now whether it has miters or not, so atleast I'm not getting error messages!  It has to be something very close to that, thanks again for your help.

Thanks,
Devon Johnson

Inventor 2020
Message 6 of 8
mrattray
in reply to: devonjohnson

If you could post up the files that your trying to run this on then I could play around with them to see what you need. I was just taking a shot in the dark with that code.

Mike (not Matt) Rattray

Message 7 of 8

Hi devonjohnson,

 

I think I would use a Select Case for this. Here's an example. Note that I'm not sure I have the If statement correct for how you want it, but you can adjust it as needed. I just set it up to work for my testing.

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120



 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

'get the material in use
oMaterial = iProperties.Material 

'select the case based on the material in use
'and then set the description
Select Case oMaterial 

Case = "SS RHS" 
	'quite errors if parameter does not exist
	Parameter.Quiet = True
	'check for the miter parameters
	If Parameter("ANG1") isnot nothing Then
	sDecr = "=<HEIGHT>x<WIDTH>x<THK> x <LENGTH> LG (<ANG1> / 0)"
	Else If Parameter("ANG2") isnot nothing Then
	sDecr = "=<HEIGHT>x<WIDTH>x<THK> x <LENGTH> LG (<ANG1> / <ANG2>)"
	Else
	sDecr ="=<HEIGHT>x<WIDTH>x<THK> x <LENGTH> LG"
	End If

Case = "ALUMINIUM"
sDecr = "=<HEIGHT> x <WIDTH> x <THK> THK"

Case = "SS ALLTHREAD"
sDecr = "=Ø<DIA> x <LENGTH> LG"

Case = "SS ANGLE" 
sDecr = "=<HEIGHT>x<WIDTH>x<THK> x <LENGTH> LG"

'add more cases here as needed...

End Select

'set the iProperties
iProperties.Value("Project", "Description") = sDecr
iProperties.Value("Custom", "TYPE") = oMaterial

 

Message 8 of 8
devonjohnson
in reply to: devonjohnson

Hi Curtis,

 

That worked great thanks so much!  The only thing I had to change was the order, the ANG2 variation had to be before ANG1 or else it wasn't picked up.

 

Really appreciate your help, it had been driving me nuts!

 

Regards,
Devon

Thanks,
Devon Johnson

Inventor 2020

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

Post to forums  

Autodesk Design & Make Report