Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Created Leaders using journal

Status
Not open for further replies.

oxyd85

Mechanical
Jun 23, 2010
6
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.

 
Replies continue below

Recommended for you

The "HANDLE R-15337" is the entity name the journal uses to refer to the specific geometry used when you recorded the journal. If you run this journal in a different part it will look for "HANDLE R-15337" and most likely throw an error because it cannot find it.

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?
 
In fact I'm trying to find what property do I need to access to get that HANDLE-R-15337 since I want to be able to automatically add leaders to every single points on a drafting.

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.
 
As Cowski said, HANDLE-R-15337 is an internal reference (in this case to the the point belonging to a wave linked point) used by NX journals and is nothing the user should use. Instead you should be looking at using the point or feature collection if you want to add a leader to all points.
 
Are the points part of the model (it appears to be a wave linked point) or the drawing?

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.
 
I found away around the issue and got it working. Yes the points were waved since we do other drawing any a different prt file.
 
Now that everything is working I was wondering if there is a way to tells NX to stop updating the display until the code is finished?

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor