×
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

Jobs

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 - Manufacturing the Cars of Tomorrow
In this ebook, we'll explore how additive manufacturing is going to transform the way cars are made. This includes commentary from thought leaders such as Ford's CTO, Ken Washington, Customer case studies of ways 3D printing is being used today, and a variety of part examples where 3D printing is already impacting how automobiles are made. Download Now
White Paper - Smart Manufacturing for Semiconductor
New technologies and approaches present great opportunities for semiconductor manufacturers to achieve high levels of innovation, yield and improvement. This white paper explores some of these cutting-edge technologies and how they can be applied effectively in the semiconductor industry. Read about how Smart Manufacturing is transforming the semiconductor industry. Download Now
White Paper - Analysis and Simulation in Aircraft Structure Certification
Organizations using simulation and analysis tools effectively see the benefits in their ability to achieve certification faster and with drastically less total cost than those who do not maximize these tools. Read this White Paper to learn about how digital tools such as analysis and simulation help in aircraft structure certification. 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