How can I annotate these dimensions in a drawing, using iLogic?

How can I annotate these dimensions in a drawing, using iLogic?

ricardo_cano2
Explorer Explorer
120 Views
4 Replies
Message 1 of 5

How can I annotate these dimensions in a drawing, using iLogic?

ricardo_cano2
Explorer
Explorer

Hi all, hopefully I'm not asking something that has been answered dozens of time before 🙏🙏🙏

I'm trying to create an iLogic rule for drawings.
Where annotations are automatically added in an organized manner, and where holes exist, the annotation is added to the dimension.

ricardo_cano1_1-1753376208067.png

 

 

Public Sub Main()
  Dim oDrawDoc As DrawingDocument
  oDrawDoc = ThisApplication.ActiveDocument

  Dim oActiveSheet As Sheet
  oActiveSheet = oDrawDoc.ActiveSheet

  Dim oDrawingCurveSegment As DrawingCurveSegment
  oDrawingCurveSegment = ThisApplication.CommandManager.Pick(kDrawingCurveSegmentFilter, "Seleccionar la línea del origen")

  Dim oDrawingCurve As DrawingCurve
  oDrawingCurve = oDrawingCurveSegment.Parent

  If Not oDrawingCurve.CurveType = kLineSegmentCurve Then
    MsgBox("Esta no es una línea Ingeniero")
    Exit Sub
  End If

  Dim oDimIntent As GeometryIntent
  oDimIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve, kEndPointIntent)

  Dim oDrawingView As DrawingView
  oDrawingView = oDrawingCurve.Parent

  If Not oDrawingView.HasOriginIndicator Then
    oDrawingView.CreateOriginIndicator(oDimIntent)
  End If

  Dim oOrdinateDimensions As OrdinateDimensions
  oOrdinateDimensions = oActiveSheet.DrawingDimensions.OrdinateDimensions

  Dim oTextOrigin As Point2d
  Dim DimType As DimensionTypeEnum
  DimType = kHorizontalDimensionType

  Dim TG As TransientGeometry
  TG = ThisApplication.TransientGeometry

  oTextOrigin = TG.CreatePoint2d(oDrawingView.Left + 2, oDrawingCurve.StartPoint.Y)
  Call oOrdinateDimensions.Add(oDimIntent, oTextOrigin, DimType)

  Dim oIntent As GeometryIntent
  Dim textPt As Point2d

  For Each oDrawingCurve In oDrawingView.DrawingCurves
    Select Case oDrawingCurve.CurveType
      Case kCircleCurve
        oIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve, kCenterPointIntent)
        textPt = TG.CreatePoint2d(oDrawingView.Left + 2, oDrawingCurve.CenterPoint.Y)

      Case kLineSegmentCurve
        oIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve, kStartPointIntent)
        textPt = TG.CreatePoint2d(oDrawingView.Left + 2, oDrawingCurve.StartPoint.Y)

      Case kCircularArcCurve
        oIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve, kEndPointIntent)
        textPt = TG.CreatePoint2d(oDrawingView.Left + 2, oDrawingCurve.EndPoint.Y)

      Case Else
        oIntent = Nothing
    End Select

    If Not oIntent Is Nothing Then
      Call oOrdinateDimensions.Add(oIntent, textPt, 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 = TG.CreatePoint2d(oDrawingView.Left + 2, oDrawingCurve.StartPoint.Y)
  Call oOrdinateDimensions.Add(oDimIntent, oTextOrigin, DimType)

End Sub

This is the code I currently have and the following photo is of the results it generates for me.

ricardo_cano1_2-1753376453806.png

best regards, thanks

0 Likes
Accepted solutions (1)
121 Views
4 Replies
Replies (4)
Message 2 of 5

JelteDeJong
Mentor
Mentor

I have a blog post: "Automatically generate hole position dimensions". I expect that it is what you want to do.

There are also other rules for adding other kinds of dimensions on my blog.

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 5

ricardo_cano2
Explorer
Explorer

Hola Jelte Jong.
En primer lugar, estoy emocionado. No pensé que alguna vez responderías a mis preguntas en este foro.
He estado leyendo tu blog y creo que es genial.

Estoy creando un guión maestro, pero he progresado tanto que me siento perdido.

¿Puedes darme alguna orientación?

Gracias.

0 Likes
Message 4 of 5

ricardo_cano2
Explorer
Explorer

Hi Jelte Jong.
First of all, I'm excited. I didn't think you'd ever be answering my questions on this forum.
I've been reading your blog and I think it's great.

I'm creating a master script, but I've made so much progress that I feel lost.

Can you give me some guidance?

Thanks.

Message 5 of 5

JelteDeJong
Mentor
Mentor
Accepted solution

Long master scripts can quickly become overwhelming and difficult to manage. Here are a few strategies to keep things organised and maintainable:

1. One Rule to Rule Them All

Create a single master rule that calls other, smaller rules. This helps maintain structure and keeps each rule focused and readable.

2. Create an Add-In

If your rules become too complex or contain too many functions, it might be worth developing an Add-In. While this offers more power and flexibility, it does require a deeper dive into .NET development and can be a bit more challenging to set up.

3. Use a DLL for Your Functions

This is a hybrid approach between rules and Add-Ins. You move most of your code into a DLL and call its functions from your iLogic rules. This keeps your rules clean while leveraging the power of external code.

 

I’ve written about the Add-In and DLL approaches on my blog and GitHub feel free to check them out.

If you have any questions, don’t hesitate to ask here on the forum!

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes