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!

Change module through VB

Status
Not open for further replies.

lharrison

New member
Oct 19, 2011
52
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
 
Replies continue below

Recommended for you

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.
 
I'm on 7.5 and this is still not available thru VB
 
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.
 
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 _
)

 
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.
 
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?
 
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.
 
Will your journal work if you are in drafting but the drawing sheet is not displayed?
 
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).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor