×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

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!
  • Students Click Here

*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 code - What am I dong wrong?

Journal code - What am I dong wrong?

Journal code - What am I dong wrong?

(OP)
I like having simple buttons to turn certain options that i use a lot, on and off. Edges Hidden by Edges, View Hidden Lines in a drafting view, etc...

All of these that I have working are all done in Drafting. I am trying to make one work the same way in Modeling for Silhouettes. This code will turn them on, but never turns them off.


Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String)

Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work

Dim displayPart As NXOpen.Part = theSession.Parts.Display

' ----------------------------------------------
' Menu: Preferences->Visualization...
' ----------------------------------------------
Dim currentMode1 As NXOpen.Preferences.SessionVisualizationHighEndRendering.MaterialEditorEditingMode = Nothing
currentMode1 = theSession.Preferences.HighEndRenderingVisualization.StudioMaterialEditorEditingMode

Dim displayAppearanceOptions1 As NXOpen.Preferences.ViewVisualizationVisual.DisplayAppearanceOptions = Nothing

displayAppearanceOptions1.RenderingStyle = NXOpen.Preferences.ViewVisualizationVisual.RenderingStyle.StaticWireframe
displayAppearanceOptions1.HiddenEdges = NXOpen.Preferences.ViewVisualizationVisual.HiddenEdges.Visible


if displayAppearanceOptions1.Silhouettes = True then
displayAppearanceOptions1.Silhouettes = False
elseif displayAppearanceOptions1.Silhouettes = False then
displayAppearanceOptions1.Silhouettes = True
End if


displayAppearanceOptions1.SmoothEdges = True
displayAppearanceOptions1.SmoothEdgeColor = 0
displayAppearanceOptions1.SmoothEdgeFont = NXOpen.Preferences.ViewVisualizationVisual.SmoothEdgeFont.Original
displayAppearanceOptions1.SmoothEdgeWidth = NXOpen.Preferences.ViewVisualizationVisual.SmoothEdgeWidth.Original
displayAppearanceOptions1.SmoothEdgeAngleTolerance = 0.19999999999999996
workPart.ModelingViews.WorkView.VisualizationVisualPreferences.DisplayAppearance = displayAppearanceOptions1

End Sub
End Module

RE: Journal code - What am I dong wrong?

Your "displayAppearanceOptions1" variable is originally declared to be "nothing"; this means that all the member variables are not set yet. Later bits of code (your highlighted parts) attempt to make use of a member variable that still isn't set yet. To populate the member variables with the current settings, get the display options from the current work view. After that, you can make use of the values for the current setting and change them as desired. The code below gets the view settings from the current work view, sets the display style to static wireframe and toggles the silhouette curve setting (run it a few times to see the effect).

CODE

Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String) 

Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work

Dim displayPart As NXOpen.Part = theSession.Parts.Display

' ----------------------------------------------
'   Menu: Preferences->Visualization...
' ----------------------------------------------
Dim displayAppearanceOptions1 As NXOpen.Preferences.ViewVisualizationVisual.DisplayAppearanceOptions = workPart.ModelingViews.WorkView.VisualizationVisualPreferences.DisplayAppearance
displayAppearanceOptions1.RenderingStyle = NXOpen.Preferences.ViewVisualizationVisual.RenderingStyle.StaticWireframe
displayAppearanceOptions1.HiddenEdges = NXOpen.Preferences.ViewVisualizationVisual.HiddenEdges.Visible
displayAppearanceOptions1.Silhouettes = Not displayAppearanceOptions1.Silhouettes
workPart.ModelingViews.WorkView.VisualizationVisualPreferences.DisplayAppearance = displayAppearanceOptions1

' ----------------------------------------------
'   Menu: Tools->Journal->Stop Recording
' ----------------------------------------------

End Sub
End Module 

www.nxjournaling.com

RE: Journal code - What am I dong wrong?

(OP)
SO in dumbed down English, let me see if I get this right. lol

Because I had the DisplayAppearanceOptions set to "Nothing", it is basically saying nothing is set. So it didnt know what to do. You changed that to look at the display settings of the work view.

Then instead of using an IF statement, you did the following....

For the rendering style and the hidden edges, it is looking at the display settings, then the code is giving them a specific setting to use.

The Silhouettes code sees the display settings being used, then basically just tells it to use whatever setting is not already being used?


As you see, I understand code very little. I get what I can find and try to hack my way through it to make it do what I need. Doesnt always work out so well. lol

I did try it and it works great. Thanks cowski

RE: Journal code - What am I dong wrong?

The setting for the silhouettes property is a boolean value (either true or false). The code above uses the Not operator to flip the value of the silhouettes setting (Not True = False and Not False = True). It is a shortcut notation that does the same thing as the If block in your original code. My use of the Not .Silhouettes isn't what made the code work, but rather getting the view settings from the current work view before attempting to make changes.

www.nxjournaling.com

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


Resources

eBook - Integrating the Engineering Ecosystem
Aras Innovator provides multiple options for integrating data between systems, depending on the scenario. Utilizing the right approach to meet specific business requirements is vital. These needs range from authoring tools, federating data from various and dissimilar databases, and triggering processes and workflows. Download Now
Research Report - Simulation-Driven Design for SOLIDWORKS Users
In this engineering.com research report, we discuss the rising role of simulation and the paradigm shift commonly called the democratization of simulation. In particular, we focus on how SOLIDWORKS users can take advantage of simulation-driven design through two analysis tools: SOLIDWORKS Simulation and 3DEXPERIENCE WORKS. Download Now
White Paper - Industry 4.0 and the Future of Engineering Education
With industries becoming more automated, more tech-driven and more complex, engineers need to keep their skills and knowledge up to date in order to stay on top of this wave—and to be prepared for the Industry 4.0 future. The University of Cincinnati offers two online Master of Engineering degree programs designed specifically for practicing engineers. Download Now
eBook - The Design Gridlock Manifesto
In this eBook, you’ll learn 6 ways old CAD technology slows your company down and hear how design teams have put those problems to rest. “The Design Gridlock Manifesto” shares first-hand modern CAD experiences from 15 companies around the world. 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