we need to measure the extents dimensions of the subassemblies inside the main assembly, when i run the code it measures the extents dimensions of the main assembly only, it doesn't go inside the subassemblies.
so how to modify the below code to be able to reach the subassemblies level.
thanks.
Dim opendoc As Document opendoc = ThisDoc.Document Dim docfile As Document For Each docfile In opendoc.AllReferencedDocuments If docfile.DocumentType = 12291 Then Dim x = Measure.ExtentsLength Dim y = Measure.ExtentsWidth Dim z = Measure.ExtentsHeight MessageBox.Show("Part Number/Name :" & docfile.DisplayName & vbLf & "length = " & x & vbLf & "Width = " & Measure.ExtentsWidth & vbLf & "Height = " & Measure.ExtentsHeight, "Title") End If Next
Hi @Amjed_Abdat. I'm sure there are multiple ways to do this, and multiple ways to assemble the retrieved data after the fact, but here is one way you can do it. The problem with those iLogic only snippets you were using, is that I believe they just target the 'active' document, and you are wanting them to work on other referenced documents. This code below uses the RangeBox of each top level referenced sub-assembly to get its size along the main 3 axes. Beware though, the results will be in centimeters by default, so if you need the results in different units, you will need to include some math or some units conversion code.
Dim oADoc As AssemblyDocument = ThisDoc.Document
Dim oReport As String
For Each oRefDoc As Document In oADoc.ReferencedDocuments
If oRefDoc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Continue For
Dim oRefADoc As AssemblyDocument = oRefDoc
oRefADef = oRefADoc.ComponentDefinition
oMinP = oRefADef.RangeBox.MinPoint
oMaxP = oRefADef.RangeBox.MaxPoint
oXDiff = oMaxP.X - oMinP.X
oYDiff = oMaxP.Y - oMinP.Y
oZDiff = oMaxP.Z - oMinP.Z
oName = System.IO.Path.GetFileNameWithoutExtension(oRefDoc.FullFileName)
oSize = oXDiff & " Long x " & oYDiff & " Wide x " & oZDiff & " High"
If Not String.IsNullOrEmpty(oReport) Then oReport = oReport & vbCrLf
oReport = oReport & oName & " was " & oSize
Next
MsgBox(oReport,,"")
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
If you want and have time, I would appreciate your Vote(s) for My IDEAS :light_bulb: or you can Explore My CONTRIBUTIONS
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.