Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: llorden4

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)