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 Parameter Formatting and Printing to description for each Part in an Assembly that uses G_L to define Length

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
chris_badilloK3ZHN
292 Views, 9 Replies

iLogic Parameter Formatting and Printing to description for each Part in an Assembly that uses G_L to define Length

I found this post to be quite useful:

 

https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-batch-part-parameter-editor-rule-i...


I am banging my head against a wall trying to print to the freshly formatted part's Description using iProperties.Value("Project", "Description"), before iterating to the next part in the assembly.

 

Ultimately, I'm hoping to get a template that will have a nice conditional that will allow me to modify for each new ANSI profile we adopt in an Frame Assembly in addition to the formatting code in the link above.  For instance, in Square Tubing, G_L is always equal to d19, so I'd write:

 

If G_L = d19 

iProperties.Value("Project", "Description) = "=Sq Tube <Stock Number> x <G_L> LG."

Else

iProperties.Value("Project", "Description) = "=<Stock Number> x <G_L> LG."

 

Every attempt I make will at best apply the formula to the Assembly iProperties Description only. 

 

Thanks, this would be a huge time saver on fabrication drawings. 

9 REPLIES 9
Message 2 of 10

Hi @chris_badilloK3ZHN 

This looks like you want to just alter descriptions of each frame member without altering cc family iprops etc? You are correct in saying that the iproperty that gets modified will be the main assembly. The iLogic API iproperty works by targeting the document the rule is in by default. For this kind of work I would prefer to go to the Inventor API as per your link. It is a more diffult route but your guaranteed to get feedback as to what object is failing and when and where. Can you give us more idea of what you want to achieve? 

Your talking about template but if you are targeting frame generated members you won't be able to embed anything into the documents and so will have to have any changes applied externally. Is there anything in the previous link you posted that semi works for you? If it does please post your work and indicate what you might like to change.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 10

Yes, when we drop a parts description in a fabrication drawing for a weldment, the frame generated parts have a silly description. We’ve been pretty happy with the solution found in the link, we can easily copy “=” and whatnot to the part’s description in the assembly from the BOM. That saves us a ton of man power. Maybe I’m getting greedy thinking we can have that last step handled by iLogic. The doesn’t always contain the relevant information for the ANSI profiles so I wanted to be able to have some conditionals in the snippet that would allow me to identify a profile by its parameters and then I could concatenate a string more fitting in the description when needed. Thanks for your quick response, hopefully I’m speaking clearly, if only dabbled with iLogic and programming.
Message 4 of 10

So if your going the inventor API here are two articles that will help you get your head around. They will help guide you in creating small sample. Open a part and see can you get the iproperty and parameter interaction your after. Once you get this working then try and move into targeting all parts.

 

How to get an iproperty also called a property in Inv API

and another on how to implement written in vba.

 

Here is the vba sample for setting the value of a parameter

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 5 of 10
A.Acheson
in reply to: A.Acheson

Hi @chris_badilloK3ZHN 

 

I had the majority of a rule created so here is what I believe your looking for.  The try catch is needed because if d19 parameter doesn't exist the rule would error out. If you want any help figuring out any lines let me know.

 

Dim asmDoc As AssemblyDocument = ThisDoc.Document
Dim trans As Transaction = ThisApplication.TransactionManager.StartTransaction(asmDoc, "FG iproperty creation") 	

'Traverse all referenced documents		
For Each doc As Document In asmDoc.AllReferencedDocuments 
	If doc.DocumentInterests.HasInterest("{AC211AE0-A7A5-4589-916D-81C529DA6D17}") _' Frame generator component
		AndAlso doc.DocumentType = DocumentTypeEnum.kPartDocumentObject _ 'Part
		AndAlso doc.IsModifiable _'Not read only CC/Library document
		AndAlso Not doc.DocumentInterests.HasInterest("SkeletonDoc") _'Not reference skeleton
		AndAlso asmDoc.ComponentDefinition.Occurrences.AllReferencedOccurrences(doc).Count > 0 Then 'Exists in assembly (not derived base component)
	 	
		'Cast to a part document so we can use intelisense to identify part document properties and methods.
		doc = TryCast(doc, PartDocument) 
		
		'Get propset equivalent of accessing iproperties tab 3.
		Dim designPropSet As PropertySet = doc.PropertySets.Item("Design Tracking Properties")
		
		'Access each iproperty.
		Dim desc As [Property] = designPropSet.Item("Description")
		Dim stkNum As [Property] = designPropSet.Item("Stock Number")

		Dim compDef As PartComponentDefinition = doc.ComponentDefinition
		
		'Get userparameter collection.
		Dim UserParams As UserParameters = compDef.Parameters.UserParameters
		
		'Get individual parameter.
		Dim G_L As UserParameter = UserParams.Item("G_L")
		Dim d19 As UserParameter 
		Try
			d19 = UserParams.Item("d19")
			'Check parameter values.
			If G_L.Value = d19.Value Then 
				desc.Value = "Sq Tube " & stkNum.Value & "x" & G_L & "LG."
			End If
		Catch Ex As Exception 'Did not find parameter
			desc.Value = stkNum.Value & "x" & G_L.Value & " LG."
		End Try
	
	End If	
Next

trans.End 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 6 of 10

We WILL Sing Songs of your valor A.Acheson!  At lease I will.  This is great, I tweaked it a bit so it could be run before or after after I format the parts with the script linked to the original post.  Tweak shown here:

 

chris_badilloK3ZHN_0-1714053880873.png

Now, I should be able to copy this snippet and tweak it around if there are other profiles that need a custom name that isn't contained in the Stock Number, correct?  That's what I plan on doing, that's what I meant when I spoke of "a template". 

 

Again, thanks a million

Message 7 of 10

Actually, I've run into a different issue.  d19 is a Reference Parameter, so it IS successfully adding the formula "=<Stock Number...." to the description, it isn't catching and comparing the d19 value as expected.  Any help?

Message 8 of 10

Nice glad it worked out for you. Here is another article that deals with working with assembly components which is likely the biggest hurdle in all of this. O will be honest when I first looked at that article a few years ago I wasnt able to grasp how it all worked. Once you can wrap your head around how to get each object be it an occurrence or document then really its just a case of building up the different scenarios your going to encounter and applying methods and properties to them.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 9 of 10

Yes you will need to declare it not as a userparameter but as a reference parameter. So access the referenceparameters collection and then declare it as a referenceparameter

 

Syntax Parameters.ReferenceParameters() As ReferenceParameters

 

Syntax

ReferenceParameters.ItemIndex As Variant ) As ReferenceParameter

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 10 of 10

Awesome!  Thanks again!  I added ReferenceParams and it's friends to your script and, lo and behold, it worked like a dream.  

 

chris_badilloK3ZHN_0-1714055250232.png

 

You've added years to my life.

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report