Hi All,
I wrote a simple rule in ipt to update part material based on value of :
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
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.
Im working with frame generator assembly which is containing many components.
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.
Can't find what you're looking for? Ask the community or share your knowledge.