iLogic rule to create parameters in parts with EXPORT PARAMETER

iLogic rule to create parameters in parts with EXPORT PARAMETER

bmerton
Enthusiast Enthusiast
1,521 Views
3 Replies
Message 1 of 4

iLogic rule to create parameters in parts with EXPORT PARAMETER

bmerton
Enthusiast
Enthusiast

I am having what is probably a very elementary issue with creating a Parts List in Inventor

 

I need Surface Area, Mass, Thickness and Material for each part in the Parts list.

 

I also need to multiply the above by a Total_Quantity parameter in the assembly to give Total_Surface_Area, Total_Mass, etc etc

 

I also 

 

The only way I have been able to get these is by creating a user parameter in the assembly for Total_Quantity, and then adding all the six / seven parameters to each part and sub-assembly manually.

 

Additionally, the EXPORT PARAMETER checkbox must be checked for each one, which is often forgotten, meaning someone (me) has to go back in and check each and every part).

 

This can take a long long time.

 

Is there a simple iLogic rule that can be used to insert the parameters into all parts and sub-assembies related to an assembly automatically that will also check the Export Parameter box so it can be used in a Parts List?

 

Many thanks in advance...

 

0 Likes
1,522 Views
3 Replies
Replies (3)
Message 2 of 4

theo_bot
Advocate
Advocate

use this sample to create parameters.

if you want to make it work from a assembly you need to loop thru the componentoccurences.

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 6739 StartFragment: 314 EndFragment: 6707 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

'Dim oDoc As AssemblyDocument
Dim oDoc As PartDocument = ThisDoc.Document 'of : oDoc as AssemblyDocumment = ThisDoc.Document

'nummerieke parameter
Try
prop = oDoc.ComponentDefinition.Parameters.UserParameters.item ("G_L")
Catch
newprop = oDoc.ComponentDefinition.Parameters.UserParameters.AddByExpression("G_L", "100", "mm")
End Try

param =Parameter.Param("G_L") 
param.ExposedAsProperty = True 

'param.CustomPropertyFormat.Precision = kThreeDecimalPlacesPrecision 
param.CustomPropertyFormat.ShowTrailingZeros = False 
param.CustomPropertyFormat.ShowLeadingZeros = False 
param.CustomPropertyFormat.ShowUnitsString = False 
'param.CustomPropertyFormat.Units = "in" 
Message 3 of 4

bmerton
Enthusiast
Enthusiast

Thanks theo.bot

 

Sorry to be so ignorant, but how do I get it to loop through component occurences?

 

Also, what if I want to add a text parameter?

 

Ben

0 Likes
Message 4 of 4

Vladimir.Ananyev
Alumni
Alumni

If you need to set parameters and iProperties you may avoid looping through component occurences because really you need in  the documents (not component occurrences).

So it would be enough to iterate 

  • AssemblyDocument.ReferencedDocuments collection  
    returns all the documents directly referenced by this document

or

  • AssemblyDocument.AllReferencedDocuments collection  
    contains  all the document references of this AssemblyDocument along with all of the recursively nested references.
Cheers,

Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes