Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

nx journal user function for edit - component - move

Status
Not open for further replies.

cschnei

Industrial
Aug 14, 2014
14
Hello, I have a journal to place a gap (user defined symbol "gap25") on a selected dimension line, if 2 lines are crossing. Depending on the dimension's orientation the correct position of the gap is not so easy to pick. A fine tuning with "File - Component - Move" is often required. This command has a good preview for the gap' position. It would be much easier, if automatically after placing the gap on the dimension line, the gap hangs on the mouse and can be moved on the dimension line for putting it on the right place. Now I am looking for a way to include this in my journal. Hopefully someone can say me the user function to hande this command.
Thanks in advance,
Carsten
 
Replies continue below

Recommended for you

What code are you using to place the gap symbol? If the code is from here:

I'd be interested in seeing an example file where you need to adjust the gap placement after running the journal. It is a bit tricky getting the placement correct for all cases, I'd like to improve the code if I can.

www.nxjournaling.com
 
Hello,

maybe you need something like this?

Motion Callback VB Example

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
 
Module Module1
 
    Dim idSymbolBuilder1 As Annotations.IdSymbolBuilder
 
    Sub Main()
 
        Dim theSession As Session = Session.GetSession()
        Dim theUfSession As UFSession = UFSession.GetUFSession
        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()
 
        Dim myScreenPos(2) As Double
        Dim theViewTag As Tag = theSession.Parts.Display.Views.WorkView.Tag
        Dim theResponse As Integer
 
        Dim myIdSymbol As Annotations.IdSymbol
        If SelectIdSymbol("select ID Symbol", myIdSymbol) = Selection.Response.Cancel Then
            Exit Sub
        End If
 
        idSymbolBuilder1 = workPart.Annotations.IdSymbols.CreateIdSymbolBuilder(myIdSymbol)
 
        'lw.WriteLine("symbol type: " & idSymbolBuilder1.Type.ToString)
        'lw.WriteLine("symbol size: " & idSymbolBuilder1.Size.ToString)
        'lw.WriteLine("symbol text: " & idSymbolBuilder1.UpperText)
        'lw.WriteLine("symbol origin: " & idSymbolBuilder1.Origin.OriginPoint.ToString)
 
        theUfSession.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
 
        theUfSession.Ui.SpecifyScreenPosition("pick a point", AddressOf MotionCallback, Nothing, myScreenPos, theViewTag, theResponse)
 
        theUfSession.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
 
        idSymbolBuilder1.Destroy()
 
    End Sub
 
    Function SelectIdSymbol(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response
 
        Dim theUI As UI = UI.GetUI
        Dim title As String = "Select an ID Symbol"
        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.WorkPart
        Dim selectionMask_array(0) As Selection.MaskTriple
 
        With selectionMask_array(0)
            .Type = UFConstants.UF_drafting_entity_type
            .Subtype = UFConstants.UF_draft_id_symbol_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
        Else
            Return Selection.Response.Cancel
        End If
 
    End Function
 
    Sub MotionCallback(ByVal pos() As Double, _
                       ByRef motion_cb_data As UFUi.MotionCbData, _
                       ByVal client_data As System.IntPtr)
 
        Dim point1 As Point3d = New Point3d(pos(0), pos(1), pos(2))
 
        idSymbolBuilder1.Origin.Origin.SetValue(Nothing, Nothing, point1)
        idSymbolBuilder1.Commit()
 
    End Sub
 
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
 
        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
 
        '----Other unload options-------
        'Unloads the image immediately after execution within NX
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
 
        'Unloads the image explicitly, via an unload dialog
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
        '-------------------------------
 
    End Function
 
End Module
 
Thanks for the answers,
I didn't use these journals from cowski for my work. They work very fine for the most cases, especially the first way to create the gap manually. One thing that is not regognised is the crossing of an extension line and an dimension line (as mentioned in the Infotext). Only extension lines are regognised, but especilly for angular gimensions you get somtimes this situation.
That's the major reason why we would prefer the optional way, to move the gap directly after placing it on the extension or dimension line.

Schellenbergj: I am looking for something like that, but I don't know how to move this user defined symbol attached to the dimension. A way to get in the "File - Component - Move" Commant would be very helpful. Maybe there is one way.

Best regards
Carsten
 
I had some time to work on this today; I'm running out of time to work on it, so it isn't thoroughly tested or as tidy as I'd like, but it is in working condition. Let me know if you have any problems with it. Feel free to use any or all of it.

PlaceDimBreak

www.nxjournaling.com
 
Hello Cowski,
thanks for your work, but your new journal does not run on my NX8 or NX9 installation. It allways stops with errors.
I have created now a mixture of journal and macro to get nearly that what I need. The manual positioning could be a bit more comfortable but it works.
For the automatic creation of the gaps I used the journal from www.nxjournaling.com

Maybe someone else wants to use this for his work or further improvements.

Best regards
Carsten
 
 http://files.engineering.com/getfile.aspx?folder=70c7bcf6-5cca-4c6c-b3fa-84ca0388135c&file=dimension_gaps.zip
I tested with NX 8.5 and 9 with no errors. The code uses an API feature not available before 8.5, so an error in NX 8 (or earlier) is to be expected. But it should run in NX 9; what error message do you get with NX 9?

www.nxjournaling.com
 
I updated the code to remove the reference that made it incompatible with versions lower than 8.5. I tested it against NX 7.5, 8, 8.5 and 9; it works as intended in those versions. Download from the same link as above.

www.nxjournaling.com
 
It works very well now and it is exactly what I need.
Thanks a lot.
Carsten
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor