Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.
This question just came up, and I was curious if anyone knows of a way to do this ( without making derived parts or extra sub assemblies of a part with a cut), or can figure out a slick way to do this.
The goal is to show the mass of the part in the parts list, after it has some material cut away from it at the assembly level.
So as the picture shows, I want to programmatically override the mass of the part in the parts list to show what it is at the assembled level ( 500 kgs ).
I don't know of a way for us to get the cut away mass, and didn't see anything in the API
Inventor 2024 Help | CutFeature Object | Autodesk
Note in real life the cuts are more complex, the assembly would have more parts, but the cuts material mass would be the same for each instance of each part.
Attached is a simple data set with an iLogic rule in the drawing to write the Total Mass to the parts list.
Thanks in advance!
Inventor Forum links: Inventor iLogic , API and Customization Forum | Inventor Ideas Forum | General Inventor Forum
Hi @Curtis_Waguespack. This is just a thought, and I usually would not suggest writing assembly level data back down to part level, but...if you want to keep it just one row in the PartsList, even though different occurrences of the same part may be cut in different ways, I would run an event driven rule at the assembly level that inspects each occurrence that is referencing each referenced document, to get its calculated mass (ComponentOccurrence.MassProperties route), record it in a Dictionary, calculate the 'average', write that to a custom iProperty in the referenced part. In the drawing, while editing the PartsList, select the column for the Mass, right click, choose Format Column, go to the Substitute tab, Enable Value Substitution, under {When exists, use value of} choose Browse for property, then pick that the custom iProperty, then under where it says {When rows are merged, value used is}, choose Sum of Values. Not sure if that will work for you, but it sounded OK in my head. I'm not super familiar with 'merged' rows though.
Wesley Crihfield
(Not an Autodesk Employee)
@WCrihfield thanks for taking a look at this!
...even though different occurrences of the same part may be cut in different ways
This will not be a concern for the use case.
...In the drawing, while editing the PartsList, select the column for the Mass, right click, choose Format Column, go to the Substitute tab, Enable Value Substitution
I'm probably looking to avoid substitution in the parts list, due to the anticipation of units mismatch errors
...to get its calculated mass (ComponentOccurrence.MassProperties route), record it in a Dictionary, calculate the 'average', write that to a custom iProperty in the referenced part.
that's very close to the ideas I came up with, but my data set example is a little too simple to convey the challenge here. Let's say that there was a third component that is not the same part, and it shares the same cut feature as the first 2 parts, but also has another assembly level cut.
here the 3rd part has a corner cut away using
the same cut feature as the other 2 blocks,
but also has a hole cut.
I can't think of a clean way to get the mass (or cut volume) of each part at the assembly level, which is ultimately what I think we'd need.
The best I've been able to think of, is to suppress everything but one component in the assembly, take the mass of the assembly, then suppress it, then un suppress the next one, take the mass of the assembly, and so on.
Inventor Forum links: Inventor iLogic , API and Customization Forum | Inventor Ideas Forum | General Inventor Forum
OK. I was just thinking fast and in broad strokes, throwing ideas out there to get folks thinking about it from different angles.
I know that if I use the default / manual Measure tool in an assembly, set to part priority (instead of faces/edges), and select an assembly component, it will show me its Mass, Volume, & 'Center of Volume Position'. And I can suppress / unsuppress the feature(s) that are cutting into it to get different values shown. I just assumed that we should be able to get the same data by code using the ComponentOccurrence.MassProperties route to access the Mass of the individual assembly components after assembly level cut type features have removed some material from them.
But even if we did get accurate numbers, that still does not account for possible units differences among multiple model files though, some of which may be ReadOnly for various reasons. Plus, if the part is used in multiple assemblies, then writing this type of data to the single part file's custom iProperty is usually messy. My first thoughts were to somehow use the 'instance properties', but I could not think of a 'clean' way to get that data into a column of the PartsList in the drawing. Oh well. Lots of smart folks here looking at this, so someone will likely come up with something better soon.
Wesley Crihfield
(Not an Autodesk Employee)
Is it possible to get mass of the "solid body" (instead of the part) in assembly?
Is it possible to add the assembly feature to part document as a Shadow features?
Hi, maybe it’s possible to make use of the instance properties (added in Inventor 2022)
Ps.
Grouping off the columns is not supported in the Api so you have to make default partslist in the style editor
Sub main Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument Dim oSheet As Sheet = oDrawDoc.ActiveSheet Dim oMassList As New List(Of Double) Dim oPartsList As PartsList = oSheet.PartsLists.Item(1) Dim oAsmDoc As AssemblyDocument = oPartsList.ReferencedDocumentDescriptor.ReferencedDocument Dim oPartDoc As PartDocument = Nothing ' Get the assembly component definition. Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition ' Get all of the leaf occurrences of the assembly. Dim oLeafOccs As ComponentOccurrencesEnumerator = oAsmDef.Occurrences.AllLeafOccurrences ' Iterate through the occurrences and print the name. Dim oOcc As ComponentOccurrence For Each oOcc In oLeafOccs If oOcc.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then oPartDoc = oOcc.Definition.Document Dim oMassProp As MassProperties = oOcc.MassProperties Dim oMass As String = CStr(Math.Round(oMassProp.Mass,2)) & " " & "kg" Dim oVolume As Double = oMassProp.Volume oMassList.Add(oMassProp.Mass) CreateInstanceProp(oOcc, "NewMass", oMass) CreateInstanceProp(oOcc, "NewVol", oVolume) 'CreateUpdateCustomprop(oPartDoc, oMass, "NewMass") End If Next Dim oBOM As BOM = oAsmDoc.ComponentDefinition.BOM oBOM.StructuredViewEnabled = True oBOM.SetPartNumberMergeSettings(False) oSheet.PartsLists.Item(1).Delete() Dim oview As DrawingView = oSheet.DrawingViews.Item(1) Dim oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width, oSheet.Height) oSheet.PartsLists.Add(oview, oPlacementPoint, PartsListLevelEnum.kStructuredAllLevels) oPartsList = oSheet.PartsLists.Item(1) Dim oCullumns As PartsListColumns = oPartsList.PartsListColumns Dim oRows As PartsListRows = oPartsList.PartsListRows Dim oRow As PartsListRow = Nothing Try oCullumns.Add(PropertyTypeEnum.kCustomProperty, , "NewMass") Catch ex As Exception End Try Dim oCountRow As Integer = oRows.Count oRow = oRows.Add(oCountRow, False) Dim MassTotal As PartsListCell = oRow.Item(5) Dim Desc As PartsListCell = oRow.Item(4) Desc.Value = "TOTAL MASS" Dim oTotalMass As Double = Math.Round(oMassList.Sum, 2) MassTotal.Value = CStr(oTotalMass & " " & "kg") oPartsList.Sort("ITEM", True) Dim oCollumn As PartsListColumn = oCullumns.Item("NewMass") End Sub Private Sub CreateInstanceProp(ByVal occ As ComponentOccurrence, oPropName As String, OValue As String) occ.OccurrencePropertySetsEnabled = True ' get the property set and add a property Dim instancePropSet As PropertySet = occ.OccurrencePropertySets(1) Dim instanceProp As Inventor.Property Try instancePropSet.Item(oPropName).Value = OValue Catch ex As Exception instanceProp = instancePropSet.Add(OValue, oPropName) End Try End Sub
If a response answers your question, please use ACCEPT SOLUTION to assist other users later.
Also be generous with Likes! Thank you and enjoy!
Can't find what you're looking for? Ask the community or share your knowledge.