×
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

Change module through VB

Change module through VB

Change module through VB

(OP)
Can anyone tell me if there are any commands available in VB that allow you to change from the drafting module to the modeling module, assuming that modeling has not yet been started. I tried recording a few journals but it doesn't seem to record these events.

Bruce

RE: Change module through VB

Not sure how to automate it, but you could use a button to save a few clicks:

Right Click->Customize->Commands

Under "Application", bring the Drafting button to your toolbar.

Then again, if your goal is to begin the drafting application right away, you can select a drawing when specifying your new part.

RE: Change module through VB

I'm on 7.5 and this is still not available thru VB

RE: Change module through VB

(OP)
Unfortunately this is for an automation routine so using a button is feasible. Sometimes the part files open up in drafting mode, which causes the program to fail because it tries running code that is supposed to run within the modeling environment. We got around it by having someone manually open each part file and move it into modeling, but automation of this would save significant time.

RE: Change module through VB

Hi,

If you are working in external mode you can use any of the modeling/drafting related routines.

If you are working in internel mode i am not finding any routine which switches the application. But, you can find the existing application with the below mentioned routine and then compare it with the required application.

Public Sub AskApplicationModule ( _
    <OutAttribute> ByRef module_id As Integer _
)

 

RE: Change module through VB

(OP)
could you please specify what you mean by internal and external? I assume by external you mean running an externally compiled application via 'Execute NXOpen...' which is the method I am using.

It is an application used to open models and take screenshots of them. If a i try to take a screenshot or change the view type(wireframe,shaded,etc...) then the program fails. If the models are switched to the modeling view however, then the program executes just fine.

RE: Change module through VB

(OP)
My code fails whenever I try to change the shading type and NX is within a draft:

MainSession.Parts.Display.Views.WorkView.RenderingStyle = View.RenderingStyleType.ShadedWithEdges;

I get an Object not found error. The same error occurs if it try to execute on the workpart as well:

MainSession.Parts.Work.Views.WorkView.RenderingStyle = View.RenderingStyleType.ShadedWithEdges;

Is there another way to call these methods that won't throw an error if I am currently on a draftin sheet?

RE: Change module through VB

(OP)
I am currently using a try/catch block that saves the filename of the erroneous part and prints them all out at the end. Not the most graceful solution but it allows the routine to digest all of the parts without crashing, but someone must go back through and switch all of the 'bad' parts into modeling so they can be captured as well.

I'm starting to think this might just be the way it is.

RE: Change module through VB

Will your journal work if you are in drafting but the drawing sheet is not displayed?

RE: Change module through VB

(OP)
No, the program explicitly fails whenever a part opens in the drafting module. Further investigation has shown me that anytime code is executed on Session.Parts....  an object not found error occurs if the current part is in drafting view.

I am using an externally compiled C# application, and running it by using the Execute NXOpen command. I am not very familiar with the execution of journals within NX(though I have experience in CATIA), so if anyone can test this for me on this avenue, it would be greatly appreciated.

I also discovered that AskApplicationModule does not function properly when executed from an outside program. It always returns '80' regardless of module. (Though that is documented in the .NET help).

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!


Resources