Created Leaders using journal
Created Leaders using journal
(OP)
Hi,
I've been trying to create a leader for a point in drafting mode using NX Open VB.net . BTW I'm using NX6.
I tried to record a journal while creating a leader but some of the code generated does not really make any sense to me.
Here is a sample :
----------
Dim nullAnnotations_SimpleDraftingAid As Annotations.SimpleDraftingAid = Nothing
Dim draftingNoteBuilder1 As Annotations.DraftingNoteBuilder
draftingNoteBuilder1 = workPart.Annotations.CreateDraftingNoteBuilder(nullAnnotations_SimpleDraftingAid)
Dim text1(0) As String
text1(0) = "Ok"
draftingNoteBuilder1.Text.TextBlock.SetText(text1)
Dim leaderData1 As Annotations.LeaderData
leaderData1 = workPart.Annotations.CreateLeaderData()
leaderData1.StubSize = 5.0
leaderData1.Arrowhead = Annotations.LeaderData.ArrowheadType.FilledArrow
draftingNoteBuilder1.Leader.Leaders.Append(leaderData1)
Dim symbolscale1 As Double
symbolscale1 = draftingNoteBuilder1.Text.TextBlock.SymbolScale
Dim symbolaspectratio1 As Double
symbolaspectratio1 = draftingNoteBuilder1.Text.TextBlock.SymbolAspectRatio
Dim baseView1 As Drawings.BaseView = CType(workPart.DraftingViews.FindObject("TOP@1"), Drawings.BaseView)
draftingNoteBuilder1.Origin.AnnotationView.Value = baseView1
Dim wavePoint1 As Features.WavePoint = CType(workPart.Features.FindObject("LINKED_POINT(2)"), Features.WavePoint)
Dim point1 As Point = CType(wavePoint1.FindObject("HANDLE R-15337"), Point)
Dim point1_1 As Point3d = New Point3d(-120.76826933111, 95.6540301194006, 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, point1, baseView1, point1_1, Nothing, nullView, point2_1)
Dim point2 As Point3d = New Point3d(-120.76826933111, 95.6540301194006, 0.0)
leaderData1.Leader.SetValue(point1, baseView1, point2)
Dim leaderData2 As Annotations.LeaderData
leaderData2 = workPart.Annotations.CreateLeaderData()
leaderData2.StubSize = 5.0
leaderData2.Arrowhead = Annotations.LeaderData.ArrowheadType.FilledArrow
draftingNoteBuilder1.Leader.Leaders.Append(leaderData2)
leaderData2.StubSide = Annotations.LeaderSide.Inferred
Dim point3 As Point3d = New Point3d(-120.76826933111, 95.6540301194006, 0.0)
leaderData1.Leader.SetValue(point1, baseView1, point3)
Dim point5 As Point3d = New Point3d(-104.06544644193, 84.8464850635728, 0.0)
draftingNoteBuilder1.Origin.Origin.SetValue(Nothing, nullView, point5)
draftingNoteBuilder1.Commit()
draftingNoteBuilder1.Destroy()
-----------
What bugs me is the CType conversion between the wavePoint1.FindObject("HANDLE R-15337") and Point.
I can't figure out where that HANDLE R-15337 is coming from and I have no idea how I would retrieve this automatically for a set of point.
Anyone has some experience creating leaders in VB.NET?
Thanks in advance.
I've been trying to create a leader for a point in drafting mode using NX Open VB.net . BTW I'm using NX6.
I tried to record a journal while creating a leader but some of the code generated does not really make any sense to me.
Here is a sample :
----------
Dim nullAnnotations_SimpleDraftingAid As Annotations.SimpleDraftingAid = Nothing
Dim draftingNoteBuilder1 As Annotations.DraftingNoteBuilder
draftingNoteBuilder1 = workPart.Annotations.CreateDraftingNoteBuilder(nullAnnotations_SimpleDraftingAid)
Dim text1(0) As String
text1(0) = "Ok"
draftingNoteBuilder1.Text.TextBlock.SetText(text1)
Dim leaderData1 As Annotations.LeaderData
leaderData1 = workPart.Annotations.CreateLeaderData()
leaderData1.StubSize = 5.0
leaderData1.Arrowhead = Annotations.LeaderData.ArrowheadType.FilledArrow
draftingNoteBuilder1.Leader.Leaders.Append(leaderData1)
Dim symbolscale1 As Double
symbolscale1 = draftingNoteBuilder1.Text.TextBlock.SymbolScale
Dim symbolaspectratio1 As Double
symbolaspectratio1 = draftingNoteBuilder1.Text.TextBlock.SymbolAspectRatio
Dim baseView1 As Drawings.BaseView = CType(workPart.DraftingViews.FindObject("TOP@1"), Drawings.BaseView)
draftingNoteBuilder1.Origin.AnnotationView.Value = baseView1
Dim wavePoint1 As Features.WavePoint = CType(workPart.Features.FindObject("LINKED_POINT(2)"), Features.WavePoint)
Dim point1 As Point = CType(wavePoint1.FindObject("HANDLE R-15337"), Point)
Dim point1_1 As Point3d = New Point3d(-120.76826933111, 95.6540301194006, 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, point1, baseView1, point1_1, Nothing, nullView, point2_1)
Dim point2 As Point3d = New Point3d(-120.76826933111, 95.6540301194006, 0.0)
leaderData1.Leader.SetValue(point1, baseView1, point2)
Dim leaderData2 As Annotations.LeaderData
leaderData2 = workPart.Annotations.CreateLeaderData()
leaderData2.StubSize = 5.0
leaderData2.Arrowhead = Annotations.LeaderData.ArrowheadType.FilledArrow
draftingNoteBuilder1.Leader.Leaders.Append(leaderData2)
leaderData2.StubSide = Annotations.LeaderSide.Inferred
Dim point3 As Point3d = New Point3d(-120.76826933111, 95.6540301194006, 0.0)
leaderData1.Leader.SetValue(point1, baseView1, point3)
Dim point5 As Point3d = New Point3d(-104.06544644193, 84.8464850635728, 0.0)
draftingNoteBuilder1.Origin.Origin.SetValue(Nothing, nullView, point5)
draftingNoteBuilder1.Commit()
draftingNoteBuilder1.Destroy()
-----------
What bugs me is the CType conversion between the wavePoint1.FindObject("HANDLE R-15337") and Point.
I can't figure out where that HANDLE R-15337 is coming from and I have no idea how I would retrieve this automatically for a set of point.
Anyone has some experience creating leaders in VB.NET?
Thanks in advance.





RE: Created Leaders using journal
Some of the challenge is making these references generic so they work with other parts. Is your goal to make this work with other drawings?
RE: Created Leaders using journal
If I would be able to get the information, I would then be able to change the "HANDLE R-15337" for let's say waypoint1.property_xyz which would allow me to use the code generated by the journal.
Thus far, I have not been able to find the property or a way around this that would still allow me to create a leader.
RE: Created Leaders using journal
RE: Created Leaders using journal
If you want a leader for every point, I would suggest iterating through all the points of interest and creating a leader for each.
If you can post a simplified example file I might be able to get more specific.
RE: Created Leaders using journal
RE: Created Leaders using journal
So instead of seeing each and every leader appear one by one, they would appear all at once at the end of my code.
This would greatly improve the performance.
Thanks in advance