- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I have a many flexible sub-assemblies in a large organic main structure. In order to avoid sizing and placing each sub-assy, I'm using flexibility to place them and constrain them. I'm then writing code to go over those sub-assemblies, measure the distance between two points, save a copy of the sub-assembly and update it to suit the measured dimension.
The problem is that I can't get MeasureTools.GetMinimumDistance to work. The user selects a sub-assembly occurrence, then the code identifies the geometry to measure, but I get an error on the MeasureTools.GetMinimumDistance line. I suspect I'm defining my geometry (Plane1 and Axis1) wrong because manually picking the geometry works fine.
I tried various combination of selecting the occurrence (oOcc) and the work geometry (Plane1 and Axis1) using .definition and .contextdefinition. I found that if I selected the occurrence AND work geometry with .contextdefinition then the GetMinimumDistance returned 0 distance.
How do I access the work geometry of an occurrence, while maintaining their context in the main assembly?
Code is below:
Sub SaveFlexibleAssyAsCopy()
Dim oA As AssemblyDocument
Dim oOcc As ComponentOccurrence
Dim oSS As SelectSet
Set oA = ThisApplication.ActiveDocument
Set oOcc = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "Select first outrigger occurrence.")
Dim oPlate As ComponentOccurrence
Set oPlate = oOcc.ContextDefinition.Occurrences(3)
Dim Plane1 As WorkPlane
Set Plane1 = oPlate.Definition.WorkPlanes(2)
'Set Plane1 = ThisApplication.CommandManager.Pick(kWorkPlaneFilter, "Select outrigger workplane.")
Dim oBeam As ComponentOccurrence
Set oBeam = oOcc.ContextDefinition.Occurrences(1)
Dim Axis1 As WorkAxis
Set Axis1 = oBeam.Definition.WorkAxes(3)
'Set Axis1 = ThisApplication.CommandManager.Pick(kWorkAxisFilter, "Select outrigger axis.")
' Display the distance between the points using the current document units.
Dim uom As UnitsOfMeasure
Set uom = ThisApplication.ActiveDocument.UnitsOfMeasure
Dim oDist As Double
oDist = uom * ThisApplication.MeasureTools.GetMinimumDistance(Plane1, Axis1)
End Sub
Thanks in advance.
Solved! Go to Solution.