use iLogic to add set of ordinate dimensions in a view of a sheet of a drawing

use iLogic to add set of ordinate dimensions in a view of a sheet of a drawing

ricardo_cano1
Explorer Explorer
87 Views
0 Replies
Message 1 of 1

use iLogic to add set of ordinate dimensions in a view of a sheet of a drawing

ricardo_cano1
Explorer
Explorer
Hello designers,
I'm Ricardo, nice to meet you.
Thank you in advance for your support. I've been trying for weeks to automatically integrate "coordinate set" into an assembly drawing view with iLogic. I found the following code, and it works for me, but only with Holes: 

Captura de pantalla 2025-07-23 121335.png

 

 

 
Public Sub Main()
  ' Set a reference to the drawing document.
  ' This assumes a drawing document is active.
  Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument

  ' Set a reference to the active sheet.
  Dim oActiveSheet As Sheet
    oActiveSheet = oDrawDoc.ActiveSheet

  '   a reference to the drawing curve segment.
  ' This assumes that a linear drawing curve is selected.
  Dim oDrawingCurveSegment As DrawingCurveSegment
    oDrawingCurveSegment = ThisApplication.CommandManager.Pick(kDrawingCurveSegmentFilter, "Select start line to start ordinate dimension")

  '   a reference to the drawing curve.
  Dim oDrawingCurve As DrawingCurve
    oDrawingCurve = oDrawingCurveSegment.Parent

  If Not oDrawingCurve.CurveType = kLineSegmentCurve Then
    MsgBox ("A linear curve should be selected for this sample.")
    Exit Sub
  End If

  ' Create point intents to anchor the dimension to.
  Dim oDimIntent  As GeometryIntent
    oDimIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve, kEndPointIntent)

  '   a reference to the view to which the curve belongs.
  Dim oDrawingView As DrawingView
    oDrawingView = 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.
    oDrawingView.CreateOriginIndicator (oDimIntent)
  End If

  '   a reference to the ordinate dimensions collection.
  Dim oOrdinateDimensions As OrdinateDimensions
    oOrdinateDimensions = oActiveSheet.DrawingDimensions.OrdinateDimensions

  Dim oTextOrigin  As Point2d
  Dim DimType As DimensionTypeEnum
  
  ' Selected curve is vertical or at an angle.
  DimType = kHorizontalDimensionType
    
  '   the text points for the 2 dimensions.
    oTextOrigin = ThisApplication.TransientGeometry.CreatePoint2d(oDrawingView.Left + 2, oDrawingCurve.StartPoint.Y)
 
  ' Create the first ordinate dimension.
  Call oOrdinateDimensions.Add(oDimIntent, oTextOrigin, DimType)
  
  For Each oDrawingCurve In oDrawingView.DrawingCurves
    If oDrawingCurve.CurveType = kCircleCurve Then
        Dim oIntent As GeometryIntent
          oIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve, kCenterPointIntent)
        
        Dim origin As Point2d
          origin = ThisApplication.TransientGeometry.CreatePoint2d(oDrawingView.Left + 2, oDrawingCurve.CenterPoint.Y)
        
        Call oOrdinateDimensions.Add(oIntent, origin, DimType)
    End If
  Next
  
    oDrawingCurveSegment = ThisApplication.CommandManager.Pick(kDrawingCurveSegmentFilter, "Select end line to complete ordinate dimension")
  
    oDrawingCurve = oDrawingCurveSegment.Parent
  
  If Not oDrawingCurve.CurveType = kLineSegmentCurve Then
    MsgBox ("A linear curve should be selected for this sample.")
    Exit Sub
  End If
  
    oDimIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve, kEndPointIntent)
  
    oTextOrigin = ThisApplication.TransientGeometry.CreatePoint2d(oDrawingView.Left + 2, oDrawingCurve.StartPoint.Y)
  
  Call oOrdinateDimensions.Add(oDimIntent, oTextOrigin, DimType)
  
End Sub




I'd like your help to also identify Lines. This is how I achieve this:

Captura de pantalla 2025-07-23 121648.png

 

 

0 Likes
88 Views
0 Replies
Replies (0)