Get part in assembly by coordinates

Get part in assembly by coordinates

lodhur
Observer Observer
583 Views
2 Replies
Message 1 of 3

Get part in assembly by coordinates

lodhur
Observer
Observer

Hi Inventor Community,

 

I try to write a program which gets all material between to random points in an assembly. 

My approach was to submit a 3D point and check which component of the assembly is located there. Afterwards I could access the properties of this part. Unfortuneatly I didn't manage to find the functionality in the API of Inventor. 

 

Does anybody have an idea, if this could be realised with the object model of inventor? 

 

regards, 

Kevin 

0 Likes
584 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

I think I may have something you can use.  See iLogic code below.

There are several options for inputing the point coordinates, but I am showing two basic ways here.

The one being used is one of the manual methods.  It specifies an invisible 3D mathematical point (in red) in your model area to use as your search target point.  The next line (currently commented out) shows how you could use an existing work point.  There is also another line below (which I also currently have commented out), which you would use with that method, if you choose to.  (You could also use an interactive 'Pick' method, but that doesn't seem like what you are wanting.)

The selection filter is currently set to kAssemblyOccurrenceFilter (in Blue).

It then shows you how you could dig down deeper into the selected Occurrence(s)'s Properties.

I didn't go any deeper than that, because I don't know the full extent of whay you're trying to do yet.

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
	MessageBox.Show("THIS RULE '" & iLogicVb.RuleName & "' ONLY WORKS FOR ASSEMBLY DOCUMENTS.", "WRONG DOCUMENT TYPE", MessageBoxButtons.OK, MessageBoxIcon.Stop)
	Return
End If

Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim oCompOcc As ComponentOccurrence

Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oPoint As Point = oTG.CreatePoint(0, 0, -12)
'Dim oWP As Point = oADef.WorkPoints.Item("Work Point1").Point

Dim oObjTypes = New SelectionFilterEnum(){kAssemblyOccurrenceFilter}

Dim oOE As ObjectsEnumerator = oADef.FindUsingPoint(oPoint, oObjTypes)
'Dim oOE As ObjectsEnumerator = oADef.FindUsingPoint(oWP, oObjTypes)
If oOE.Count = 0 Then
	MsgBox("Nothing found at that coordinate.")
	Return
ElseIf oOE.Count > 0 Then
	MsgBox("It found something.")
	For Each oObj In oOE
		If oObj.Type = ObjectTypeEnum.kComponentOccurrenceObject Then
			MsgBox("This is a Component Occurrence Object." & vbNewLine &
			"Name = " & oObj.Name)
			Dim oOcc As ComponentOccurrence = oObj
			Dim oOccDoc As Document = oOcc.Definition.Document
			Dim oPropSets As PropertySets = oOccDoc.PropertySets
			'Etc.
		Else
			MsgBox("Object Name = " & oObj.Name & vbNewLine &
			"Object Type = " & oObj.Type)
		End If
	Next
End If

I hope this helps.
If this solves your problem, or answers your questions, please click 'Accept As Solution".
Or, if this helps you reach your goal, please click 'LIKES" 👍.

Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.
If you agree with any of them, please vote for them.

  • Options to format contents of MessageBox, InputBox, and InputListBox Click Here
  • Ability to fully constrain and dimension to the edjes of images within drawing title block sketches, SketchedSymbol sketches, other drawing sketches, and assembly sketches Click Here
  • Save section view status in DesignViewRepresentation, so it can be used in drawing view Click Here
  • Add SolidBodies folder to iLogic Rule Editor Model Tab Click Here
  • Convert all views to Raster before autosave stores to 'OldVersions' folder Click Here

Thanks, and best of luck in your future Inventor Customization endeavors.

Autodesk Inventor 2020 Online Help
Inventor Forum
Inventor Customization Forum
Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

lodhur
Observer
Observer

Thanks for that detailed answer. Looks very promising, I will check it and tell you if it worked out for me. 

0 Likes