I have setup my library to create a Custom Part Number concatenated from Cost Center iProp and Length. This allows my part lists to Group parts with the same name (or same lengths). Instead of all my 2x2x1/8 Tube being one item, it will be broken down based on Lengths. Works great!!
Sometimes I need to just show the opposite. I have an assembly, that has a skeleton file and a frame generator assembly. The frame is made up of a custom profile and I don't require the individual lengths, just the total length of the part. I have scoured this forum and found some rules that I have almost made work perfectly. It totals up all the lengths (my custom parameter "G_L_CUSTOM) and converts to my liking and saves it to the Part Number. Where I am stuck, is I need the information that is stored in the Cost Center iProp of any of the frame generator parts. Cost Center in the Assembly iProp is blank that is why the part number is not showing up right. Is there a way to look for Cost Center iprop in the 1st part of the Frame generator assembly, store it in the rule then the rule can grab it and concatenate my new Part Number Correctly.
Dim total As Double = 0
Dim adoc As AssemblyDocument = ThisDoc.Document
For Each occ As ComponentOccurrence In adoc.ComponentDefinition.Occurrences
Dim Val As Double
Try
Val = Parameter(occ.Name, "G_L_CUSTOM")
total = total + Val
Catch
End Try
Next occ
'round inch value and convert to fraction
oLin = RoundToFraction(total, 1/16, RoundingMethod.Round)
'convert inch value to feet
oLft = total/12
'round feet value and convert to fraction
oL=RoundToFraction(oLft, 1/16, RoundingMethod.Round)
'create part number iproperty
iProperties.Value("Project", "Part Number") = iProperties.Value("Project", "Cost Center")&" - LENGTH " & oL
'create custom Length iproperty
iProperties.Value("Custom", "Length (in)") = oLin
'ensure everything is good
MessageBox.Show("Total length: " & oL & " ft")
This image shows one of the frame generator parts and the iproperties. You can see that each of the parts uses the same methodology for the part number. Cost Center + Length
Thanks!
Solved! Go to Solution.
I have setup my library to create a Custom Part Number concatenated from Cost Center iProp and Length. This allows my part lists to Group parts with the same name (or same lengths). Instead of all my 2x2x1/8 Tube being one item, it will be broken down based on Lengths. Works great!!
Sometimes I need to just show the opposite. I have an assembly, that has a skeleton file and a frame generator assembly. The frame is made up of a custom profile and I don't require the individual lengths, just the total length of the part. I have scoured this forum and found some rules that I have almost made work perfectly. It totals up all the lengths (my custom parameter "G_L_CUSTOM) and converts to my liking and saves it to the Part Number. Where I am stuck, is I need the information that is stored in the Cost Center iProp of any of the frame generator parts. Cost Center in the Assembly iProp is blank that is why the part number is not showing up right. Is there a way to look for Cost Center iprop in the 1st part of the Frame generator assembly, store it in the rule then the rule can grab it and concatenate my new Part Number Correctly.
Dim total As Double = 0
Dim adoc As AssemblyDocument = ThisDoc.Document
For Each occ As ComponentOccurrence In adoc.ComponentDefinition.Occurrences
Dim Val As Double
Try
Val = Parameter(occ.Name, "G_L_CUSTOM")
total = total + Val
Catch
End Try
Next occ
'round inch value and convert to fraction
oLin = RoundToFraction(total, 1/16, RoundingMethod.Round)
'convert inch value to feet
oLft = total/12
'round feet value and convert to fraction
oL=RoundToFraction(oLft, 1/16, RoundingMethod.Round)
'create part number iproperty
iProperties.Value("Project", "Part Number") = iProperties.Value("Project", "Cost Center")&" - LENGTH " & oL
'create custom Length iproperty
iProperties.Value("Custom", "Length (in)") = oLin
'ensure everything is good
MessageBox.Show("Total length: " & oL & " ft")
This image shows one of the frame generator parts and the iproperties. You can see that each of the parts uses the same methodology for the part number. Cost Center + Length
Thanks!
Solved! Go to Solution.
Solved by A.Acheson. Go to Solution.
Hi @Shag_Bore
I read this a few times and trying to figure out what the request are. Can you possibly put in a brief bullet point of what you want the rule to do? Then separately what it is currently doing?
One request is
"Cost Center in the Assembly iProp is blank that is why the part number is not showing up right. Is there a way to look for Cost Center iprop in the 1st part of the Frame generator assembly, store it in the rule then the rule can grab it and concatenate my new Part Number Correctly. "
If you want to store a value just set up a string variable.
Dim partNo As String = "........"
If you want to get the total length of parts, one way is to use the part number merge and copy the stock number to the part number and then all like parts will be the same. You can then reverse the process and make each size of part unique and this will sum up the same lengths for cut list.
One thing to keep in mind is that iproperty snippet has only one target document as it is shown here. Which is the target document it is launched from.
iProperties.Value("Custom", "Length (in)")
If you want to target a different document such as a part you must add the document object. See this help file here.
I still prefer property sets method for this other document target as it is more stable especially when working with drawings.
Hi @Shag_Bore
I read this a few times and trying to figure out what the request are. Can you possibly put in a brief bullet point of what you want the rule to do? Then separately what it is currently doing?
One request is
"Cost Center in the Assembly iProp is blank that is why the part number is not showing up right. Is there a way to look for Cost Center iprop in the 1st part of the Frame generator assembly, store it in the rule then the rule can grab it and concatenate my new Part Number Correctly. "
If you want to store a value just set up a string variable.
Dim partNo As String = "........"
If you want to get the total length of parts, one way is to use the part number merge and copy the stock number to the part number and then all like parts will be the same. You can then reverse the process and make each size of part unique and this will sum up the same lengths for cut list.
One thing to keep in mind is that iproperty snippet has only one target document as it is shown here. Which is the target document it is launched from.
iProperties.Value("Custom", "Length (in)")
If you want to target a different document such as a part you must add the document object. See this help file here.
I still prefer property sets method for this other document target as it is more stable especially when working with drawings.
Hey @A.Acheson,
the problem is I have edited all my content center family tables to have the iProperty Part Number be displayed as "Cost Center - Length - xxx", I have stored all our in house part numbers in that location (Cost Center) for ease of use. Then concatenated the Part Number so that I can Enable Row Merge on Part Number Match. This makes my parts lists group all items that are the same part and same length. (See image 2 below) This works great for "typical" assemblies.
Occasionally I need the opposite to happen. I want to create an external rule that I can run when this is required. I want the assembly to show up as one item in the parts list, not the total number of parts and each. I have found enough info to create the rule to find the total length of the profile in the assembly and start the Part Number name, but I am stuck on how to get the "Cost Center" iProp from any of the parts to finish off the concatenation. Also getting the description to populate is required too, first image is what I have so far, second image is the undesired result of all parts. Hope this makes it a little bit clearer, I want to run this rule when required to get the info from the parts in the assembly, no manual input. Last image in first post shows one part and the information it has stored.
Thanks!!
Hey @A.Acheson,
the problem is I have edited all my content center family tables to have the iProperty Part Number be displayed as "Cost Center - Length - xxx", I have stored all our in house part numbers in that location (Cost Center) for ease of use. Then concatenated the Part Number so that I can Enable Row Merge on Part Number Match. This makes my parts lists group all items that are the same part and same length. (See image 2 below) This works great for "typical" assemblies.
Occasionally I need the opposite to happen. I want to create an external rule that I can run when this is required. I want the assembly to show up as one item in the parts list, not the total number of parts and each. I have found enough info to create the rule to find the total length of the profile in the assembly and start the Part Number name, but I am stuck on how to get the "Cost Center" iProp from any of the parts to finish off the concatenation. Also getting the description to populate is required too, first image is what I have so far, second image is the undesired result of all parts. Hope this makes it a little bit clearer, I want to run this rule when required to get the info from the parts in the assembly, no manual input. Last image in first post shows one part and the information it has stored.
Thanks!!
Hi @Shag_Bore
If you want the Cost center iproperty from the part document, once you have the occurrence, get it's definition then it's document then you can access the property sets and then the property.
Dim occDoc As Document = occ.Definition.Document
Dim costCenterProp As Inventor.Property = occDoc.PropertySets.Item("Design Tracking Properties").Item("Cost Center")
Dim iprop As String = costCenterProp.Value
MessageBox.Show(iprop, "Title")
Hi @Shag_Bore
If you want the Cost center iproperty from the part document, once you have the occurrence, get it's definition then it's document then you can access the property sets and then the property.
Dim occDoc As Document = occ.Definition.Document
Dim costCenterProp As Inventor.Property = occDoc.PropertySets.Item("Design Tracking Properties").Item("Cost Center")
Dim iprop As String = costCenterProp.Value
MessageBox.Show(iprop, "Title")
Hey @A.Acheson!
Thanks for the reply, this helps, though when you say:
once you have the occurrence, get it's definition then it's document then you can access.....
This is what I have been trying to find out how to do, because each assembly will have a unique filename or browser name, I can't find out how to "get" or "call out" the first (or any) frame member in the frame generated assembly to then call out the iProperty.
Thanks!
Hey @A.Acheson!
Thanks for the reply, this helps, though when you say:
once you have the occurrence, get it's definition then it's document then you can access.....
This is what I have been trying to find out how to do, because each assembly will have a unique filename or browser name, I can't find out how to "get" or "call out" the first (or any) frame member in the frame generated assembly to then call out the iProperty.
Thanks!
Hi @Shag_Bore
Depending on which assembly you launch the rule the occurrences returned will be different if you only use Occurrences method. To have this work from top level you would need recursion to go through into the sub assembly sub occurrences.
adoc.ComponentDefinition.Occurrences
I would suggest to work with the referenced documents see link as it might be easier to handle.
Hi @Shag_Bore
Depending on which assembly you launch the rule the occurrences returned will be different if you only use Occurrences method. To have this work from top level you would need recursion to go through into the sub assembly sub occurrences.
adoc.ComponentDefinition.Occurrences
I would suggest to work with the referenced documents see link as it might be easier to handle.
Hey @A.Acheson,
Well after using your help and searching for help based on that help, I managed to find a solution without using your help directly 😆
I am still a noob at programming so I was searching for info on what you had suggested and came across this post, which I don't know how it didn't pop up as I searched for it specifially. Anyways, it works, as always, thanks for your help. I will run the rule within the Frame Generator assembly, it searches for the 2nd part in the assembly as the first part of a frame generator assembly is the Frame Reference Model. Copies my desired iprops to the main assembly.
'This rule will copy the iProperties from :
'The first Assembly, if it's an Assembly
'Or the first derived Part or Assembly, if it's a Part
Dim oRefName As String
If ThisDoc.Document.DocumentType = kAssemblyDocumentObject Then
'Define assembly document
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisDoc.Document
Dim oAsmDef As AssemblyComponentDefinition
oAsmDef = oAsmDoc.ComponentDefinition
Dim oAsmRef As ComponentOccurrence
'Pick the first item
oAsmRef = oAsmDef.Occurrences.Item(2)
oRefName = oAsmRef.Name
Else If ThisDoc.Document.DocumentType = kPartDocumentObject Then
'Define part document
Dim oPartDoc As PartDocument
oPartDoc = ThisDoc.Document
If oPartDoc.ReferencedDocuments.Count = 0 Then Return
Dim oDerivedRef As Inventor.Document
'Pick the first derived document
oDerivedRef = oPartDoc.ReferencedDocuments(2)
oRefName = oDerivedRef.DisplayName
Else
Return
End If
iProperties.Value("Project", "Description") = _
iProperties.Value(oRefName, "Project", "Description")
iProperties.Value("Project", "Cost Center") = _
iProperties.Value(oRefName, "Project", "Cost Center")
Dim total As Double = 0
Dim adoc As AssemblyDocument = ThisDoc.Document
For Each occ As ComponentOccurrence In adoc.ComponentDefinition.Occurrences
Dim Val As Double
Try
Val = Parameter(occ.Name, "G_L_CUSTOM")
total = total + Val
Catch
End Try
Next occ
' Get the active document.
Dim invDoc As Document
invDoc = ThisApplication.ActiveDocument
' Get the design tracking property set.
Dim invDesignInfo As PropertySet
invDesignInfo = invDoc.PropertySets.Item("Design Tracking Properties")
' Get the part number property.
Dim invPartNumberProperty As [Property]
invPartNumberProperty = invDesignInfo.Item("Part Number")
'round inch value and convert to fraction
oLin = RoundToFraction(total, 1/16, RoundingMethod.Round)
'convert inch value to feet
oLft = total/12
'round feet value and convert to fraction
oL=RoundToFraction(oLft, 1/16, RoundingMethod.Round)
'create part number iproperty
iProperties.Value("Project", "Part Number") = iProperties.Value("Project", "Cost Center")&" - LENGTH " & oL & " ft"
'create custom Length iproperty
iProperties.Value("Custom", "Length (in)") = oLin
'ensure everything is good
'MessageBox.Show("Total length: " & oL & " ft")
Cheers!
Sean
Hey @A.Acheson,
Well after using your help and searching for help based on that help, I managed to find a solution without using your help directly 😆
I am still a noob at programming so I was searching for info on what you had suggested and came across this post, which I don't know how it didn't pop up as I searched for it specifially. Anyways, it works, as always, thanks for your help. I will run the rule within the Frame Generator assembly, it searches for the 2nd part in the assembly as the first part of a frame generator assembly is the Frame Reference Model. Copies my desired iprops to the main assembly.
'This rule will copy the iProperties from :
'The first Assembly, if it's an Assembly
'Or the first derived Part or Assembly, if it's a Part
Dim oRefName As String
If ThisDoc.Document.DocumentType = kAssemblyDocumentObject Then
'Define assembly document
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisDoc.Document
Dim oAsmDef As AssemblyComponentDefinition
oAsmDef = oAsmDoc.ComponentDefinition
Dim oAsmRef As ComponentOccurrence
'Pick the first item
oAsmRef = oAsmDef.Occurrences.Item(2)
oRefName = oAsmRef.Name
Else If ThisDoc.Document.DocumentType = kPartDocumentObject Then
'Define part document
Dim oPartDoc As PartDocument
oPartDoc = ThisDoc.Document
If oPartDoc.ReferencedDocuments.Count = 0 Then Return
Dim oDerivedRef As Inventor.Document
'Pick the first derived document
oDerivedRef = oPartDoc.ReferencedDocuments(2)
oRefName = oDerivedRef.DisplayName
Else
Return
End If
iProperties.Value("Project", "Description") = _
iProperties.Value(oRefName, "Project", "Description")
iProperties.Value("Project", "Cost Center") = _
iProperties.Value(oRefName, "Project", "Cost Center")
Dim total As Double = 0
Dim adoc As AssemblyDocument = ThisDoc.Document
For Each occ As ComponentOccurrence In adoc.ComponentDefinition.Occurrences
Dim Val As Double
Try
Val = Parameter(occ.Name, "G_L_CUSTOM")
total = total + Val
Catch
End Try
Next occ
' Get the active document.
Dim invDoc As Document
invDoc = ThisApplication.ActiveDocument
' Get the design tracking property set.
Dim invDesignInfo As PropertySet
invDesignInfo = invDoc.PropertySets.Item("Design Tracking Properties")
' Get the part number property.
Dim invPartNumberProperty As [Property]
invPartNumberProperty = invDesignInfo.Item("Part Number")
'round inch value and convert to fraction
oLin = RoundToFraction(total, 1/16, RoundingMethod.Round)
'convert inch value to feet
oLft = total/12
'round feet value and convert to fraction
oL=RoundToFraction(oLft, 1/16, RoundingMethod.Round)
'create part number iproperty
iProperties.Value("Project", "Part Number") = iProperties.Value("Project", "Cost Center")&" - LENGTH " & oL & " ft"
'create custom Length iproperty
iProperties.Value("Custom", "Length (in)") = oLin
'ensure everything is good
'MessageBox.Show("Total length: " & oL & " ft")
Cheers!
Sean
Can't find what you're looking for? Ask the community or share your knowledge.