08-16-2020
11:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
08-16-2020
11:38 PM
I believe something like this should give you the Y-value:
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 oNV As NameValueMap Dim Height As Double Call ThisApplication.MeasureTools.GetMinimumDistance(oFace0, oXZplane, , , oNV) Dim oVector As Vector = oNV.Item("ClosestPointOne").VectorTo(oNV.Item("ClosestPointTwo")) 'Convert distance from database units to default units of the document Height = oUM.ConvertUnits(Abs(oVector.Y), 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