- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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'
Free apps: Smart Leader | Part Visibility Utility | Mate Origins
Paid apps: Frame Stiffener Tool | Constrain Plane Toggle | Property Editor Pro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.