cancel
Showing results for 
Search instead for 
Did you mean: 

Create Leader at Point in Drawing

Pioneer
Pioneer

Hi,

 

I want to make a journal to create leader at all points in the drawing.

 

I have created some points in a model and then made a drawing.

I am getting coordinates value as define in part but I want the point location wrt to drawing.

how to get it?

Below is my code.

 

Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.Annotations
Imports NXOpen.UI
Imports NXOpen.UF

Module Point_leader

Dim theSession As Session
Dim workPart As Part
Dim displayPart As Part
Dim dwgsheet As Drawings.DrawingSheet
Dim Point As Point
Dim point3 As Point3d

Sub Main(ByVal args() As String)

theSession = Session.GetSession()
workPart = theSession.Parts.Work
displayPart = theSession.Parts.Display
dwgsheet = workPart.DrawingSheets.CurrentDrawingSheet
Dim pntName As String

For Each Point In workPart.Points

pntName = Point.Name
Dim nullAnnotations_SimpleDraftingAid As Annotations.SimpleDraftingAid = Nothing

Dim draftingNoteBuilder1 As Annotations.DraftingNoteBuilder
draftingNoteBuilder1 = workPart.Annotations.CreateDraftingNoteBuilder(nullAnnotations_SimpleDraftingAid)
draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True)
draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True)
draftingNoteBuilder1.Origin.Anchor = Annotations.OriginBuilder.AlignmentPosition.MidCenter

Dim text1(0) As String
text1(0) = "Enter Text"
draftingNoteBuilder1.Text.TextBlock.SetText(text1)

draftingNoteBuilder1.Origin.Plane.PlaneMethod = Annotations.PlaneBuilder.PlaneMethodType.XyPlane
draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True)

Dim leaderData1 As Annotations.LeaderData
leaderData1 = workPart.Annotations.CreateLeaderData()

leaderData1.StubSize = 3.0
leaderData1.Arrowhead = Annotations.LeaderData.ArrowheadType.FilledArrow
draftingNoteBuilder1.Leader.Leaders.Append(leaderData1)

leaderData1.StubSide = Annotations.LeaderSide.Inferred


draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True)
draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True)


Dim baseView1 As Drawings.BaseView = CType(workPart.DraftingViews.FindObject("Front@1"), Drawings.BaseView)

Dim point1_1 As Point3d = New Point3d(0, 0, 0)
Dim nullView As View = Nothing

Dim point2_1 As Point3d = New Point3d(0.0, 0.0, 0.0)
leaderData1.Leader.SetValue(InferSnapType.SnapType.Exist, Point, baseView1, point1_1, Nothing, nullView, point2_1)


Dim text2(0) As String
text2(0) = pntName
draftingNoteBuilder1.Text.TextBlock.SetText(text2)

Dim assocOrigin1 As Annotations.Annotation.AssociativeOriginData
assocOrigin1.OriginType = Annotations.AssociativeOriginType.Drag
assocOrigin1.View = nullView
assocOrigin1.ViewOfGeometry = nullView
Dim nullPoint As Point = Nothing

assocOrigin1.PointOnGeometry = nullPoint
assocOrigin1.VertAnnotation = Nothing
assocOrigin1.VertAlignmentPosition = Annotations.AlignmentPosition.TopLeft
assocOrigin1.HorizAnnotation = Nothing
assocOrigin1.HorizAlignmentPosition = Annotations.AlignmentPosition.TopLeft
assocOrigin1.AlignedAnnotation = Nothing
assocOrigin1.DimensionLine = 0
assocOrigin1.AssociatedView = nullView
assocOrigin1.AssociatedPoint = nullPoint
assocOrigin1.OffsetAnnotation = Nothing
assocOrigin1.OffsetAlignmentPosition = Annotations.AlignmentPosition.TopLeft
assocOrigin1.XOffsetFactor = 0.0
assocOrigin1.YOffsetFactor = 0.0
assocOrigin1.StackAlignmentPosition = Annotations.StackAlignmentPosition.Above
draftingNoteBuilder1.Origin.SetAssociativeOrigin(assocOrigin1)

Dim point4 As Point3d = New Point3d(Point.Coordinates.X, Point.Coordinates.Y, 0.0)
draftingNoteBuilder1.Origin.Origin.SetValue(Nothing, nullView, point4)

draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True)

leaderData1.StubSide = Annotations.LeaderSide.Right


Dim nXObject1 As NXObject
nXObject1 = draftingNoteBuilder1.Commit()
draftingNoteBuilder1.Destroy()

 

Next

End Sub


End Module