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 : Update Material based on Thickness & Part Type in Assembly

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
704 Views, 4 Replies

ilogic : Update Material based on Thickness & Part Type in Assembly

Hi All,

 

I wrote a simple rule in ipt to update part material based on value of :

  1. Part Thickness,"<G_T>"
  2. Part Category, "PLATE", "SECTION" & "HOLLOW SECTION." in "iProperties.Value("Summary", "Title")"

the code working fine in ipt.

 

Can anyone help me to modified/make the rule to update material of the part in assembly.?  

 

Thanks

 

 

 

 

 

SyntaxEditor Code Snippet

'PLATE
If  G_T <=20 And iProperties.Value("Summary", "Title") = "PLATE" Then 
iProperties.Material = "GOLD"

Else If  20 < G_T <= 100 And iProperties.Value("Summary", "Title") = "PLATE" Then 
iProperties.Material = "BRONZE, CAST"
'--------------------------------------------------------------------------------------------------'SECTION
Else If  G_T <=25 And iProperties.Value("Summary", "Title") = "SECTION" Then 
iProperties.Material = "SILVER"

Else If  25 < G_T <= 63 And iProperties.Value("Summary", "Title") = "SECTION" Then 
iProperties.Material = "TITANIUM"
'--------------------------------------------------------------------------------------------------'HOLLOW SECTION
Else If  G_T <=20 And iProperties.Value("Summary", "Title") = "HOLLOW SECTION" Then 
iProperties.Material = "STEEL"

Else If  20 < G_T <= 40 And iProperties.Value("Summary", "Title") = "HOLLOW SECTION" Then 
iProperties.Material = "LEAD"
'--------------------------------------------------------------------------------------------------
End If
4 REPLIES 4
Message 2 of 5
tolgay.hickiran
in reply to: Anonymous

You might want to put this rule in the part and CALL the rule from the assembly.

That should work for you.

Some worthwhile ideas
Copy Design should rename ilogic Rules too!
Why Nastran In-CAD doesn't have an SDK?IMPLEMENTED!

Tolgay Hickiran
Founding Partner
SignatureSignature

website
emailskypelinkedinyoutubeemail

Message 3 of 5
Anonymous
in reply to: Anonymous

To cycle through each part in an assembly, I use:

Try
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument

' Iterate through all of the documents referenced by the assembly.
Dim oDoc As Document
For Each oDoc In oAsmDoc.AllReferencedDocuments

' Verify that the document is a part.
	If oDoc.DocumentType = kPartDocumentObject Then	
		Dim oPartDoc As PartDocument = oDoc

'Manipulate part	
		Dim model As String = oPartDoc.DisplayName
		model = model & ".ipt"
		Try
'Code here
		Catch
                       MessageBox.Show("Error in " & model)
		End Try
	Else If oDoc.DocumentType = kAssemblyDocumentObject Then
	Dim oADoc As AssemblyDocument = oDoc

'Manipulate part	
		Dim model As String = oADoc.DisplayName
		model = model & ".iam"
		Try
'Code if you need to change any subassemblies
		Catch
                       MessageBox.Show("Error in " & model)
		End Try
	End If
Next
Catch
MessageBox.Show("Must be in the assembly environment for this to work")
End Try

You should be able to copy and paste your code into the sections I have listed and it should work.  Let me know if it doesn't.

Message 4 of 5
Anonymous
in reply to: tolgay.hickiran

Im working with frame generator assembly which is containing many components.

Message 5 of 5
adam.nagy
in reply to: Anonymous

As @Anonymous showed you can get to the actual parts inside the assembly and then you could set the iProperty on them.

 

One thing to note is that it will change the property for the part document (and not its occurrence in the assembly) and so if this part is used in other assemblies as well then this material change will be reflected in those assemblies too.



Adam Nagy
Autodesk Platform Services

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

Post to forums  

Autodesk Design & Make Report