Hi,
The previous script is a VBA Code and you are using it in ilogic.
Here is the iLogic one
Public Sub Main()
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
' Set a reference to the active sheet.
Dim oActiveSheet As Sheet = oDrawDoc.ActiveSheet
Dim oDoc As Document = oActiveSheet.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument
If oDoc.DocumentType = kAssemblyDocumentObject Then
' a reference to the drawing curve segment.
' This assumes that a linear drawing curve is selected.
Dim oDrawingCurveSegment As DrawingCurveSegment = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select start line to find occurrence")
' a reference to the drawing curve.
Dim oDrawingCurve As DrawingCurve = oDrawingCurveSegment.Parent
Dim oReferDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim pt As WorkPoint = oReferDef.WorkPoints.Item(1)
Call oActiveSheet.DrawingViews.Item(1).SetIncludeStatus(pt, True)
If Not oDrawingCurve.CurveType = CurveTypeEnum.kLineSegmentCurve Then
MsgBox ("A linear curve should be selected for this sample.")
Exit Sub
End If
Dim oCenterMark As Centermark = oActiveSheet.Centermarks.Item(oActiveSheet.Centermarks.Count)
' Create point intents to anchor the dimension to.
Dim oDimIntent As GeometryIntent = oActiveSheet.CreateGeometryIntent(oCenterMark, kCenterPointIntent)
' a reference to the view to which the curve belongs.
Dim oDrawingView As DrawingView= oDrawingCurve.Parent
' If origin indicator has not been already created, create it first.
If Not oDrawingView.HasOriginIndicator Then
' The indicator will be located at the start point of the selected curve.
Call oDrawingView.CreateOriginIndicator(oDimIntent)
End If
' a reference to the ordinate dimensions collection.
Dim oOrdinateDimensions As OrdinateDimensions = oActiveSheet.DrawingDimensions.OrdinateDimensions
Dim oTextOrigin As Point2d
Dim DimType As DimensionTypeEnum
' Selected curve is vertical or at an angle.
DimType = DimensionTypeEnum.kVerticalDimensionType
' the text points for the 2 dimensions.
oTextOrigin = ThisApplication.TransientGeometry.CreatePoint2d(oCenterMark.Position.X, oCenterMark.Position.Y - 2)
' Create the first ordinate dimension.
Dim oOrdinateDimension1 As OrdinateDimension = oOrdinateDimensions.Add(oDimIntent, oTextOrigin, DimType)
Dim LArray() As String
LArray = Split(oDrawingCurve.ModelGeometry.ContainingOccurrence.Name, ":")
Dim occ As ComponentOccurrence
For Each occ In oReferDef.Occurrences
Dim occName() As String
occName = Split(occ.Name, ":")
If occName(0) = LArray(0) Then
pt = occ.Definition.WorkPoints.Item(1)
Dim oProxy As WorkPointProxy
Call occ.CreateGeometryProxy(pt, oProxy)
Call oActiveSheet.DrawingViews.Item(1).SetIncludeStatus(oProxy, True)
oCenterMark = oActiveSheet.Centermarks.Item(oActiveSheet.Centermarks.Count)
Dim oIntent As GeometryIntent
oIntent = oActiveSheet.CreateGeometryIntent(oCenterMark, kCenterPointIntent)
Dim origin As Point2d
origin = ThisApplication.TransientGeometry.CreatePoint2d(oCenterMark.Position.X, oCenterMark.Position.Y - 2)
Call oOrdinateDimensions.Add(oIntent, origin, DimType)
End If
Next
Else
MsgBox ("Referenced document is not an assembly document")
End If
End Sub