Measuring distance from assembly occurrence feature to Assembly World plane feature

Measuring distance from assembly occurrence feature to Assembly World plane feature

llorden4
Collaborator Collaborator
623 Views
3 Replies
Message 1 of 4

Measuring distance from assembly occurrence feature to Assembly World plane feature

llorden4
Collaborator
Collaborator

Using a null entry works for constraining inserted occurrence features to the world UCS of the assembly file, but it appears a null entry isn't allowed with the measure tools features.

 

Dist = Measure.MinimumDistance("Part:1", "YZ Plane", "", "XZ Plane")

This returns an error that part "" cannot be found.  How am I supposed to measure distances between work features of an occurrence to my world work features? 

llorden4_0-1651749477137.png

 

Autodesk Inventor Certified Professional
0 Likes
Accepted solutions (1)
624 Views
3 Replies
Replies (3)
Message 2 of 4

basautomationservices
Advocate
Advocate

I'm on my phone so can't try it out right now but "", is an empty string not null. Null is VB is 'nothing'

Contact me for custom app development info@basautomationservices.com. Follow below links to view my Inventor appstore apps.

Free apps: Smart Leader | Part Visibility Utility | Mate Origins

Paid apps: Frame Stiffener Tool | Constrain Plane Toggle | Property Editor Pro


0 Likes
Message 3 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Hi @llorden4.  Those two built-in tools for measuring stuff don't always suit every need...that's for sure.  But the similar method found under the ThisApplication.MeasureTools.GetMinimumDistance() is likely going to be a better fit in a scenario like that.  And if that doesn't work either, you will just have to do it the hard way...using object geometry properties.  WorkPlanes have a Plane property that obviously returns a Plane.  You can follow the trail of properties and methods branching from those geometry objects for measurement type purposes.

Here is a mixed example...going the longer route, just in case it may be needed.

Sub Main
	Dim oOcc As ComponentOccurrence = PickComponent
	If IsNothing(oOcc) Then Exit Sub
	Dim oOccWPlane1 As WorkPlane = oOcc.Definition.WorkPlanes.Item(1)
	Dim oOccWPlane1Proxy As WorkPlaneProxy = Nothing
	oOcc.CreateGeometryProxy(oOccWPlane1, oOccWPlane1Proxy)
	Dim oADef As AssemblyComponentDefinition = oOcc.Parent
	oAWPlane1 = oADef.WorkPlanes.Item(1)
	Dim oDist1, oDist2 As Double
	If oOccWPlane1Proxy.Plane.IsParallelTo(oAWPlane1.Plane, 0.0001) Then
		oDist1 = oOccWPlane1Proxy.Plane.DistanceTo(oAWPlane1.Plane.RootPoint)
		oDist2 = ThisApplication.MeasureTools.GetMinimumDistance(oOccWPlane1Proxy.Plane, oAWPlane1.Plane)
	Else
		MsgBox("The two planes were not parallel.",,"") : Exit Sub
	End If
	MsgBox("oDist1 = " & oDist1 & vbCrLf & "oDist2 = " & oDist2,,"")
End Sub

Function PickComponent(Optional oPrompt As String = vbNullString) As ComponentOccurrence
	oObj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select a Component.")
	If IsNothing(oObj) OrElse (TypeOf oObj Is ComponentOccurrence = False) Then Return Nothing
	Dim oOcc As ComponentOccurrence = oObj
	Return oOcc
End Function

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 4

llorden4
Collaborator
Collaborator

I knew I was going to have figure out Proxy geometry sooner or later, this forced me into that moment.

 

Creating the Proxy plane and using the MeasureTools was the winning combination.

Autodesk Inventor Certified Professional
0 Likes