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

journal to add component attribute to note automatically

journal to add component attribute to note automatically

journal to add component attribute to note automatically

I recorded a journal to try to automate adding linked attribute from a component to a note in drafting. The attribute names are the same among all components and currently we are selecting the components interactively one at a time. The problem is I cannot find anything in the journal that will do this with a live attribute. Now I already do this by grabbing the value from the component in it's current state but this is plain text and doesn't update when the attribute in the component is updated.

I've recorded a short video showing the interactive steps to clarify the process. Does anyone know if it is possible to link a component attribute to a note through a journal?

NX 1899 Windows 10

RE: journal to add component attribute to note automatically

Thanks cowski, that was a great help, it gave me a direction to keep looking. The link below was where it lead, and combined with other programs was what was needed. I'll post the code after more testing and cleanup, right now it's pretty messy with a lot of unneeded code.


NX 1899 Windows 10

RE: journal to add component attribute to note automatically

This is the code, not expecting any points for style but I'm no programmer LOL. There are more elegant ways of cycling through lists, etc., and feedback is always helpful.

CODE -->

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Module1
    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()
    Dim theUISession As UI = UI.GetUI()
    Dim workPart As Part = theSession.Parts.Work
    Dim lw As ListingWindow = theSession.ListingWindow
    Sub Main()
        If IsNothing(theSession.Parts.BaseWork) Then
            'active part required
        End If
        Const undoMarkName As String = "NXJ journal"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

        Dim theComponent As Assemblies.Component

        Dim attTitle As String = "description"
        Do Until SelectComponent("select a component", theComponent) = Selection.Response.Cancel
            'does material attribute exist?
            If theComponent.HasUserAttribute(attTitle, NXObject.AttributeType.String, 0) Then
                lw.WriteLine("component, " & theComponent.DisplayName & ", does not have the attribute: " & attTitle)
            End If
    End Sub

    Function SelectComponent(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response
        Dim theUI As UI = UI.GetUI
        Dim title As String = "Select a component"
        Dim includeFeatures As Boolean = False
        Dim keepHighlighted As Boolean = False
        Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
        Dim cursor As Point3d
        Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
        Dim selectionMask_array(0) As Selection.MaskTriple
        With selectionMask_array(0)
            .Type = UFConstants.UF_component_type
            .Subtype = UFConstants.UF_all_subtype
        End With
        Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _
         title, scope, selAction, _
         includeFeatures, keepHighlighted, selectionMask_array, _
         selobj, cursor)
        If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
            Return Selection.Response.Ok
            Return Selection.Response.Cancel
        End If

    End Function

    Sub AddComponentInfo(ByVal tempComp As Assemblies.Component)                       
        'get associative text for attribute
        Dim associativeText1 As Annotations.AssociativeText
        associativeText1 = workPart.Annotations.CreateAssociativeText()
        Dim text1(4) As String
        text1(0) = associativeText1.GetObjectAttributeText(tempComp, "description")
        text1(1) = associativeText1.GetObjectAttributeText(tempComp, "size")
        text1(2) = associativeText1.GetObjectAttributeText(tempComp, "vendor")
        text1(2) = text1(2) + ": "+associativeText1.GetObjectAttributeText(tempComp, "part_num")

        'get point screen position
        Dim myView As NXOpen.View = Nothing
        Dim myCursor As Point3d
        'ask the user to select a new origin for this UDO 
        Dim myResponse As Selection.DialogResponse = theUISession.SelectionManager.SelectScreenPosition("Select Note Origin", myView, myCursor)

        Dim nullNXOpen_Annotations_SimpleDraftingAid As NXOpen.Annotations.SimpleDraftingAid = Nothing
        Dim pmiNoteBuilder1 As NXOpen.Annotations.PmiNoteBuilder = Nothing
        pmiNoteBuilder1 = workPart.Annotations.CreatePmiNoteBuilder(nullNXOpen_Annotations_SimpleDraftingAid)
        pmiNoteBuilder1.Origin.Anchor = NXOpen.Annotations.OriginBuilder.AlignmentPosition.MidCenter
        pmiNoteBuilder1.Style.LetteringStyle.GeneralTextSize = (.125)
        pmiNoteBuilder1.Origin.Plane.PlaneMethod = NXOpen.Annotations.PlaneBuilder.PlaneMethodType.ModelView

        Dim assocOrigin1 As NXOpen.Annotations.Annotation.AssociativeOriginData = Nothing
        assocOrigin1.OriginType = NXOpen.Annotations.AssociativeOriginType.Drag
        Dim nullNXOpen_View As NXOpen.View = nullNXOpen_View
        pmiNoteBuilder1.Origin.Origin.SetValue(Nothing, nullNXOpen_View, myCursor)
        Dim nXObject1 As NXOpen.NXObject = pmiNoteBuilder1.Commit()


    End Sub

End Module 

NX 1899 Windows 10

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