Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic rule to create parameters in parts with EXPORT PARAMETER

3 REPLIES 3
Reply
Message 1 of 4
bmerton
1395 Views, 3 Replies

iLogic rule to create parameters in parts with EXPORT PARAMETER

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...

 

3 REPLIES 3
Message 2 of 4
theo.bot
in reply to: bmerton

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
in reply to: theo.bot

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

Message 4 of 4
Vladimir.Ananyev
in reply to: bmerton

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

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

Post to forums  

Autodesk Design & Make Report