Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

assembly rangeBox / bounding Box without reference parts/assemblies

Guido.LangeTuchscherer
Enthusiast

assembly rangeBox / bounding Box without reference parts/assemblies

Guido.LangeTuchscherer
Enthusiast
Enthusiast

Hello,

 

I want to extract the rangebox measures without taking into account the referenced parts or assemblies.

I am cycling through the occurences of an assembly to update the measures if necessarry (checked out, changed, not read only etc.).

 

Now I would need to somehow exclude the occurences which are only in the assembly for reference purposes (according to BOM). Preferably without exaggerating the calculation time.

 

Is there a different set of rangebox measures?

 

XMax = Round(Measure.ExtentsLength, 0)
YMax = Round(Measure.ExtentsWidth, 0)
ZMax = Round(Measure.ExtentsHeight, 0)
  

Thanks for your help and suggestions.

 

Regards Guido L.-T.

0 Likes
Reply
Accepted solutions (1)
1,392 Views
6 Replies
Replies (6)

WCrihfield
Mentor
Mentor

There is also the AssemblyComponentDefinition.RangeBox Property, but I'm not sure it will give you any more accurate values than the ones your getting your current way.  One thing you may be able to use is a LevelOfDetailRepresentation, in which all those components which are either set as reference or phantom are Suppressed and their suppression state is saved in this representation.  Level of detail representation, are mainly just for system memory conservation and performance within larger assemblies, but they have a unique ability that is sometimes useful for other purposes.  When those components are suppressed, they aren't loaded into memory, and are also excluded from the physical and mass properties of the document.  So, in theory, they wouldn't be included in a RangeBox or Extents measurements, which may result in the more accurate values you are looking for.

 

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 have time, please... Vote For My IDEAS 💡or you can Explore My CONTRIBUTIONS

Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Guido.LangeTuchscherer
Enthusiast
Enthusiast

Thanks@WCrihfield 

 

I am not sure what the AssemblyComponentDefinition.RangeBox Property returns, is it an array?

 

I guess I would need to generate a view where all referenced bodies are supressed and then take the rangebox measures?

0 Likes

WCrihfield
Mentor
Mentor

Sorry for the delay.  Busy morning.  The AssemblyComponentDefinition.RangeBox Property returns a Box object.    The box object is a 'transient geometry' object, which means it is a mathematical object held in memory.  This type of Box is always aligned with the origin planes of the model, but not necessarily starting at the origin point.  It has multiple purposes, properties and methods.  You can use its GetBoxData method or just get its MinPoint and/or MaxPoint properties directly, as Point objects.  Point objects are also just mathematical only, and have 3 numerical properties (X, Y, & Z).  Then you can use their coordinate numbers and some simple subtraction math to determine overall size of the object.  For instance if you take the MaxPoin's 'Y' coordinate (a simple decimal number), and subtract the MinPoin's 'Y' coodinate from it, the remaining number is the 'height' of the model along the 'Y-Axis' of the model.  You can try/test comparing the results you get from this method to the results you get from the 'Measure' methods you are currently using, and see if they are more accurate for your application.

 

Here is the link which talks about the measure method you are using, and what all it includes in its measurement.  Scroll to the bottom of the webpage (where it has a header of "Measure.Extents") to find where it is described.  It sounds like you have to make sure the visibility of all work features are turned off and all notebook notes are deleted before using that measure technique, to help ensure a more accurate measurement.  Having to prepare your model before you use that measure technique leads me to think it may not be the most reliable way to get that measurement, but that's just my opinion.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

Guido.LangeTuchscherer
Enthusiast
Enthusiast
Accepted solution

Thanks @WCrihfield

 

I got to read the RangeBox property of the AssemblyComponentDefinition.

However the results seem to be the same for my cases.

 

I build in another iLogic which cycles through the occurrences and suppresses everything which is a reference part or assembly according to BOM structure.

 

This seems to work fine, until I find some errors later and figure out why this is troubeling in another subroutine.

 

Just if anybody is interested:

 

XMax = Round(Measure.ExtentsLength, 0)
YMax = Round(Measure.ExtentsWidth, 0)
ZMax = Round(Measure.ExtentsHeight, 0)

Dim adoc As AssemblyDocument = ThisDoc.Document

'Dim aComp As AssemblyComponentDefinition
aComp = adoc.ComponentDefinition

Dim aOcc As ComponentOccurrence
Dim supArray As New ArrayList
'				supArray.Add("sup")

'Position der Detailgenauigkeit erfassen
Dim ActLOD As String = aComp.RepresentationsManager.ActiveLevelOfDetailRepresentation.Name

' Für jede Occurrence (subobjekt in BG) prüfen ob Referenzteil
For Each aOcc In aComp.Occurrences
	If aOcc.BOMStructure = kReferenceBOMStructure Then
		'get current state
		If Not aOcc.Suppressed Then 
			'array definieren/befüllen merken
'			MsgBox("Nicht unterdrückt")
			supArray.Add("notSup")
			'dann unterdrücken
			aOcc.Suppress
		Else
			'ebenfalls array befüllen 
'			MsgBox("Bereits unterdrückt")
			supArray.Add("Sup")
		End If
	End If
Next
'InputListBox("Found references?",supArray,supArray(0),"Test")

'Maße auslesen
XaMax = Round(Measure.ExtentsLength, 0)
YaMax = Round(Measure.ExtentsWidth, 0)
ZaMax = Round(Measure.ExtentsHeight, 0)

Dim iaOcc As Integer = 0

''Anschließend zurücksetzen
For Each aOcc In aComp.Occurrences
	If aOcc.BOMStructure = kReferenceBOMStructure Then
		'unsuppress if it wasn't suppressed in the first place
		If supArray(iaOcc)="notSup" Then 
			aOcc.Unsuppress
			iaOcc = iaOcc + 1
		'leave suppressed 
		Else If supArray(iaOcc)="Sup" Then
			iaOcc = iaOcc+1
		End If
	End If
Next

'Position der Detailgenauigkeit zurücksetzen
aComp.RepresentationsManager.LevelOfDetailRepresentations.Item(ActLOD).Activate

boxMaxX = aComp.RangeBox.MaxPoint.X*10
boxMaxY = aComp.RangeBox.MaxPoint.Y*10
boxMaxZ = aComp.RangeBox.MaxPoint.Z*10
boxMinX = aComp.RangeBox.MinPoint.X*10
boxMinY = aComp.RangeBox.MinPoint.Y*10
boxMinZ = aComp.RangeBox.MinPoint.Z*10

XeMax = Round(boxMaxX - boxMinX)
YeMax = Round(boxMaxY - boxMinY)
ZeMax = Round(boxMaxZ - boxMinZ)

'XeMax = Round(Measure.ExtentsLength, 0)
'YeMax = Round(Measure.ExtentsWidth, 0)
'ZeMax = Round(Measure.ExtentsHeight, 0)


MessageBox.Show("Start" & " | " & "Testmaße" & "  |  " & "Endmaße" & _
		vbCrLf & "X = " & XMax & "  |  " & "Xa = " & XaMax & "  |  " & "Xe = " & XeMax & _
		vbCrLf & "Y = " & YMax & "  |  " & "Ya = " & YaMax & "  |  " & "Ye = " & YeMax & _
		vbCrLf & "Z = " & ZMax & "  |  " & "Za = " & ZaMax & "  |  " & "Ze = " & ZeMax, _
		"Maße") 'Titel
0 Likes

pascal_birkner5K8Z7
Community Visitor
Community Visitor

Hello, 

thanks for the iLogic for bounding Box without reference parts.

I have tried to link the iLogic with the event trigger ‘Before safe’. Unfortunately, I get an error message here. Does anyone have any ideas on how to rewrite the iLOgic so that it can be integrated into the event trigger?

0 Likes

WCrihfield
Mentor
Mentor

Hi @pascal_birkner5K8Z7.  What version/year of Inventor are you using?  If you are using 2022 or newer version, then you may need to change some of the code from using LOD's (LevelOfDetailRepresentations) to using ModelStates.  There are also newer resources available in Invntor's API for getting the size of an assembly that you may prefer, over the standard RangeBox.  Attached is a text file containing some code you can try as an iLogic rule for a similar task, but it uses ModelStates, the newer PreciseRangeBox property, converts units to document units, rounds the values to 3 decimal places, and writes the results to the iLogic Log window, instead of showing it in a pop-up message.  It will find or create a custom ModelState named "Reference Components Suppressed", activate it, suppress all components set to reference BOMStructure, get the size of the assembly at that point, then switch back to the originally active ModelState.  It could also optionally delete that custom ModelState, if you would like, in one of the last lines, but that line is currently commented out.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes