Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Show and hide. Separate buttons 1

Status
Not open for further replies.

VW181

Mechanical
Joined
Jan 23, 2013
Messages
122
Location
NL
Hi all,

In the menu Show and hide i use most of the time only sketch, assembly constrains and coordinate systems.
Is there a way to make separate buttons in an toolbar to show and hide directly all sketches or the assembly constrains? I don't like it to open the menu first every time.
I've searched for it but i can't find single commands for it.

Thanks in advance,
Tjeerd

Using NX 8.0 on Windows 7 (64)
 
Thank you for your answer [thumbsup2], but no, i would like separate buttons.

Using NX 8.0 on Windows 7 (64)
 
I have separate hide/show (blank/unblank) buttons on all my toolbars in NX7.5, they are very handy.

Please don't tell me we will now have to hunt for them in some stinking ribbon menu..! Bah humbug..

Proud Member of the Reality-Based Community..

[green]To the Toolmaker, your nice little cartoon drawing of your glass looks cool, but your solid model sucks. Do you want me to fix it, or are you going to take all week to get it back to me so I can get some work done?[/green]
 
Well, as for Assembly Constraints, they can be toggled ON/OFF by selecting the 'Constraints' item in the Assembly Navigator and pressing MB3. As for the others, you can create a few Journals covering the specific object types, and then add icons to a toolbar which will execute the journals when selected.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
Thanks for the answers.
But the disadvantage of making journals is that I get two buttons, one to turn sketches off, and one to turn sketches on again.
There is no way to have one button to turn it off and on again?

From Capnhook i understand that he has it working, but that i can't ask how it works.

Using NX 8.0 on Windows 7 (64)
 
If you want to 'toggle' the Hide/Show status of some class of objects, you'll have to create an NX Open program to do that since there are NO interactive functions which does anything like that so it would have to be user-written. And trust me, if anyone else says they've accomplished this without writing some 'program', don't believe it. Certainly there is NOTHING in what capnhook stated that would leave one with the impression that he has somehow accomplished this feat. And his comment about about not being able to have in NX 9.0 whatever he CLAIMS to have in NX 7.5 is just not true.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
Here's some code that should toggle sketch visibility (hidden vs. shown). It uses a part attribute to save what happened the last time it was run. If the attribute is not found, it is created and it will show all available sketches; subsequent runs will toggle the sketch visibility. The journal does not change layer state: if a sketch is on an invisible layer, it will not make the layer visible, but it will alter the sketch hidden status.

Code:
[COLOR=blue]Option Strict Off[/color]  
[COLOR=blue]Imports[/color] System  
[COLOR=blue]Imports[/color] NXOpen  

[COLOR=blue]Module[/color] Module2  

    [COLOR=blue]Dim[/color] theSession [COLOR=blue]As[/color] Session [COLOR=blue]=[/color] Session.GetSession()  
    [COLOR=blue]Dim[/color] workPart [COLOR=blue]As[/color] Part [COLOR=blue]=[/color] theSession.Parts.Work  
    [COLOR=blue]Dim[/color] sketchAttribute [COLOR=blue]As String =[/color] "SketchVisibility"  

    [COLOR=blue]Sub[/color] Main()  

        [COLOR=blue]Dim[/color] sketchesVisible [COLOR=blue]As Boolean = False[/color]  

        [COLOR=blue]Try[/color]  
            sketchesVisible [COLOR=blue]=[/color] workPart.GetBooleanUserAttribute(sketchAttribute, 0)  

        [COLOR=blue]Catch[/color] ex [COLOR=blue]As[/color] NXException  
            [COLOR=blue]If[/color] ex.ErrorCode [COLOR=blue]=[/color] 512008 [COLOR=blue]Then[/color]  
           [COLOR=green]'attribute not found[/color]
                workPart.SetBooleanUserAttribute(sketchAttribute, 0, False, Update.Option.Later)  
            [COLOR=blue]Else[/color]  
           [COLOR=green]'unexpected error[/color]
                MsgBox(ex.ErrorCode [COLOR=blue]&[/color] " : " [COLOR=blue]&[/color] ex.Message)  
                [COLOR=blue]Return[/color]  
            End [COLOR=blue]If[/color]  
        End [COLOR=blue]Try[/color]  

        [COLOR=blue]If[/color] sketchesVisible [COLOR=blue]Then[/color]  
            HideSketches()  
        [COLOR=blue]Else[/color]  
            ShowSketches()  
        End [COLOR=blue]If[/color]  

    End [COLOR=blue]Sub[/color]  

    [COLOR=blue]Sub[/color] ShowSketches()  

        [COLOR=blue]For Each[/color] theSketch [COLOR=blue]As[/color] Sketch [COLOR=blue]In[/color] workPart.Sketches  
            theSketch.Unblank()  
        [COLOR=blue]Next[/color]  

        workPart.SetBooleanUserAttribute(sketchAttribute, 0, True, Update.Option.Later)  

    End [COLOR=blue]Sub[/color]  

    [COLOR=blue]Sub[/color] HideSketches()  

        [COLOR=blue]For Each[/color] theSketch [COLOR=blue]As[/color] Sketch [COLOR=blue]In[/color] workPart.Sketches  
            theSketch.Blank()  
        [COLOR=blue]Next[/color]  

        workPart.SetBooleanUserAttribute(sketchAttribute, 0, False, Update.Option.Later)  

    End [COLOR=blue]Sub[/color]  

    [COLOR=blue]Public Function[/color] GetUnloadOption(ByVal dummy [COLOR=blue]As String[/color]) [COLOR=blue]As Integer[/color]  

 [COLOR=green]'Unloads the image when the NX session terminates[/color]
        GetUnloadOption [COLOR=blue]=[/color] NXOpen.Session.LibraryUnloadOption.AtTermination  

 [COLOR=green]'----Other unload options-------[/color]
 [COLOR=green]'Unloads the image immediately after execution within NX[/color]
 [COLOR=green]'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately[/color]

 [COLOR=green]'Unloads the image explicitly, via an unload dialog[/color]
 [COLOR=green]'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly[/color]
 [COLOR=green]'-------------------------------[/color]

    End [COLOR=blue]Function[/color]  

End [COLOR=blue]Module[/color]


www.nxjournaling.com
 
Thank you for the answers.

I've never used code like this, so i don't know what to do with it. If it's simple i will give it a try.
Can i put this code in a journal file and create a button that runs that journal file?

(Till now i only made a few macro's and an toolbar .tbr file)



Using NX 8.0 on Windows 7 (64)
 
VW181 said:
Can i put this code in a journal file and create a button that runs that journal file?

Open a plain text editor, such as notepad, copy and paste the code into the editor. Save the file with a meaningful name and change the extension from .txt to .vb. You now have a journal file that you can use in NX. You can then add a custom button to run the journal.

www.nxjournaling.com
 
Ok, tanks Cowski.
So it's a similar way like a macro. Then the rest should be easy.
Gonna test this tomorrow.

Using NX 8.0 on Windows 7 (64)
 
In conclusion, there are no separate show/hide buttons. A user has to create an NX Open program to do that. An enhancement to NX is not planned.

Proud Member of the Reality-Based Community..

[green]To the Toolmaker, your nice little cartoon drawing of your glass looks cool, but your solid model sucks. Do you want me to fix it, or are you going to take all week to get it back to me so I can get some work done?[/green]
 
The journal is working fine, sadly only in a single part. In an assembly it doesn't toggle on/off the sketches. (it also does nothing the first time you click the button, i think the attribute is created then.)
So I think I keep using Ctrl+W again.

Thanks for all the help. [thumbsup2]

Using NX 8.0 on Windows 7 (64)
 
In conclusion, VW181, the journal you refer to is NOT working fine.

Proud Member of the Reality-Based Community..

[green]To the Toolmaker, your nice little cartoon drawing of your glass looks cool, but your solid model sucks. Do you want me to fix it, or are you going to take all week to get it back to me so I can get some work done?[/green]
 
VW181 said:
So I think I keep using Ctrl+W again.

Excellent, since that is excatly how this is SUPPOSED to work in NX!

Having individual 'icons' which would toggle ON/OFF (Show/Hide) ONE SINGLE type of object would only save you a couple of gestures (keyboard entries) while wasting space by requiring you to have icons for each object type that you might possibly want to toggle ON/OFF. Besides, there would be NO way of knowing whether any objects of the type that you were interested in are even in your part file so pushing one or more of this multitude of icons may NOT do anything at all. However, when you use the 'Ctrl+W' approach, the dialog that comes-up will show ONLY those classes of objects which actually exist in your part file so you'll know EXACTLY what objects types are available for having their display status changed.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top