Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Create Note in NX10

Create Note in NX10

Create Note in NX10


I have an script in NX 8 for creating a note in a section of a drawing. It works like this, you make a section in the drawing through the springs in the assembly, then start the script.
The script ask for an edge to select, select an edge of a spring in the section view it creates a note with the info of the spring (see attached picture). This works very well.

But now in NX 10 I can`t select any edges in the section view, there are only drafting splines.

This is the script:

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Drawings
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Utilities
Imports NXOpen.Annotations

Module AttributeNote
Dim s As Session = Session.GetSession()
Dim ui As UI = UI.GetUI()
Dim ufs As UFSession = UFSession.GetUFSession()
' start dim standard block
Dim workPart As Part = s.Parts.Work
Dim NXmodule As Integer = 0
'ende Dim Standard Block
Dim comp As NXObject = Nothing

Sub Main()
'standard block Zeichnungserstellung
If s.Parts.Work Is Nothing Then
System.Windows.Forms.MessageBox.Show("Kein Teil geladen! - No Part Loaded!")
Exit Sub
End If

If NXmodule <> UFConstants.UF_APP_DRAFTING Then
System.Windows.Forms.MessageBox.Show("reine Zeichnungsfunktion")
Exit Sub
End If
'ENDE StandardBlock
Dim vname As String = ""
Dim viewTag As Tag = Tag.Null
Dim aView As View
Dim partname As String = ""
Dim edge As Edge = Nothing
Dim cursor As Point3d
Dim screenpos As Point3d

If select_an_edge_in_view("Kante auswaehlen", edge, cursor, vname) <> Selection.Response.Ok Then GoTo end1

' Get component data to get part attributes
If edge.IsOccurrence() Then
comp = edge.OwningComponent
end if
ufs.View.AskTagOfViewName(vname, viewTag)
aView = NXObjectManager.Get(viewTag)
If SelectPoint(screenpos) <> Selection.Response.Ok Then GoTo end1
' Create the note
CreateNote(edge, cursor, screenpos, aView)
End Sub

Function select_an_edge_in_view(ByVal prompt As String, ByRef obj As Edge, ByRef cursor As Point3d, _
ByRef vname As String) As Selection.Response
Dim ui As UI = ui.GetUI()
Dim mask(0) As Selection.MaskTriple
With mask(0)
.Type = UFConstants.UF_solid_type
.Subtype = UFConstants.UF_solid_body_subtype
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_EDGE
End With
Dim resp As Selection.Response = _
ui.SelectionManager.SelectObject("Attribute Note Creation", prompt, _
Selection.SelectionScope.AnyInAssembly, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, mask, obj, cursor)
If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Return Selection.Response.Cancel
End If
End Function

Function SelectPoint(ByRef screenpos As Point3d) As Selection.Response
Dim displayPart As Part = s.Parts.Display
Dim baseView1 As View = s.Parts.Work.Views.WorkView
Dim point As Double() = {0.0, 0.0, 0.0}
Dim point2 As Double() = {0.0, 0.0}
Dim response As Integer = 0
Dim viewTag As Tag = Nothing
Dim viewType As UFView.Type = Nothing
Dim aView As View = Nothing
Dim viewSubtype As UFView.Subtype = Nothing

ufs.Ui.SpecifyScreenPosition("Position für den Hinweis", Nothing, IntPtr.Zero, point, _
viewTag, response)
End Try
If (response <> NXOpen.UF.UFConstants.UF_UI_PICK_RESPONSE) Then Return Selection.Response.Cancel
screenpos.X = point(0)
screenpos.Y = point(1)
screenpos.Z = point(2)
Return Selection.Response.Ok
End Function

Function CreateNote(ByRef edge As Edge, ByRef Cursor As Point3d, ByRef screenpos As Point3d, _
ByRef aView As View) As Boolean
Dim nullView As View = Nothing
Dim draftingNoteBuilder1 As Annotations.DraftingNoteBuilder
Dim nullAnnotations_SimpleDraftingAid As Annotations.SimpleDraftingAid = Nothing
draftingNoteBuilder1 = s.Parts.Work.Annotations.CreateDraftingNoteBuilder (nullAnnotations_SimpleDraftingAid)
draftingNoteBuilder1.Origin.Anchor = Annotations.OriginBuilder.AlignmentPosition.MidCenter
Dim text1(3) As String
text1(0) = "<W!" & comp.Tag.tostring & "@" & "MW_STOCK_SIZE" & ">"
text1(1) = "<W!" & comp.Tag.tostring & "@" & "Sv" & ">"
text1(2) = "<W!" & comp.Tag.tostring & "@" & "Se" & ">"
text1(3) = "<W!" & comp.Tag.tostring & "@" & "R" & ">"
Dim leaderData1 As Annotations.LeaderData
leaderData1 = s.Parts.Work.Annotations.CreateLeaderData()
leaderData1.Leader.SetValue(edge, aView, Cursor)
draftingNoteBuilder1.Origin.Origin.SetValue(Nothing, nullView, screenpos)
Dim nXObject1 As NXObject
nXObject1 = draftingNoteBuilder1.Commit()
End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function

End Module

RE: Create Note in NX10

In NX 10, the default drawing view type is set to "Exact" which is similar to using "extracted edges" of previous versions. To get your code to work with the new views, you should change the selection function to allow selecting these curve types and then you can use the methods:
  • .AskDraftingCurveType
  • .AskDraftingCurveParents
To find which component that drafting curve represents.

Alternately, if you use the "Pre-NX 8.5 Exact" view type, your existing code will probably run OK as is.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close