08-14-2020
12:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
08-14-2020
12:40 AM
It's strange, but it seems there is no way to use Measure.MinimumDistance to measure the distance between an entity in a component and an entity in the top level assembly...
Then we'll have to use more advanced API functionality:
Sub Main Dim oAsm As AssemblyDocument = ThisApplication.ActiveDocument Dim oAsmComp As AssemblyComponentDefinition = oAsm.ComponentDefinition Dim oUM As UnitsOfMeasure = oAsm.UnitsOfMeasure Dim Splice As ComponentOccurrence Splice = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select a splice plate") 'Create a proxy for Face0 (The face in the context of the assembly) Dim oFace0 As Object Splice.CreateGeometryProxy(GetNamedEntity(Splice.Definition.Document, "Face0"), oFace0) 'Get the XZ Plane of the assembly Dim oXZplane As WorkPlane = oAsmComp.WorkPlanes.Item("XZ Plane") 'Measure distance Dim Height As Double = ThisApplication.MeasureTools.GetMinimumDistance(oFace0, oXZplane) 'Convert distance from database units to default units of the document Height = oUM.ConvertUnits(Height, UnitsTypeEnum.kDatabaseLengthUnits, oUM.LengthUnits) 'Return the value in a messagebox just to control that it's right MsgBox(Height) End Sub Public Function GetNamedEntity(doc As Inventor.Document, name As String) As Object Dim attribMgr As AttributeManager = doc.AttributeManager Dim objsFound As ObjectCollection objsFound = attribMgr.FindObjects("iLogicEntityNameSet", "iLogicEntityName", name) If objsFound.Count > 0 Then Return(objsFound.Item(1)) Else Return(Nothing) End If End Function
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website