Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

NX9 - Orient to Isometric and export Jpeg

Status
Not open for further replies.

Kenja824

Automotive
Nov 5, 2014
949
0
0
US
I am trying to create a journal to orient the model view to ISOMETRIC, then to export a Jpeg to a specific directory.

Journal does not seem to record exporting a Jpeg. I found the attached file is a code I found that almost does what I want. I had to turn off the GetUnloadOption lines to get it to work but it creates a jpg for every view. I would only want the ISOMETRIC view. I cannot figure out how to change that.


1) Will someone please help me adjust it to my needs?

2) The lines I turned off... are they important to have for any reason that I would want to fix them rather than turn them off?

PS
My original plan was to create code that would switch to modeling (if not in modeling already), orient to an iso view, shade it (crap, I dont think I have this code set to shade it), export a jpeg, switch to drafting and import the image it created and place it on the sheet. As soon as I realized that I couldnt find anything on changing applications, I gave up on that idea and decided to work toward two different buttons for this.
 
 http://files.engineering.com/getfile.aspx?folder=e474613d-146c-40d2-81e4-1c9913d6e265&file=jpeg.vb
Replies continue below

Recommended for you

Hello Kenja824,

The following should process only the Isometric view.

Hope this helps,
Joe

[pre] For Each wpModelingView In workPart.ModelingViews
[highlight #FCE94F]If wpModelingView.Name = "Isometric"[/highlight][highlight #D3D7CF][/highlight]
workPart.Views.WorkView.Orient(wpModelingView.Name, View.ScaleAdjustment.Fit)
strPartJpg = partName & "_" & wpModelingView.Name & ".jpg"
strPartJpg = Path.Combine(outputDirectory, strPartJpg)
ufs.Disp.CreateImage(strPartJpg, UFDisp.ImageFormat.Jpeg, UFDisp.BackgroundColor.White)
[highlight #FCE94F]End If[/highlight]
Next[/pre]
 
Thanks Jpetach

However, I get an error when I run this.

NXOpen.NXException: The view may not be rotated
at NXOpen.View.Orient(String viewName, ScaleAdjustment viewScale)
at Module.Main() in C:\Users\Kschonmeier\AppData\Local\Temp\NXJournals2616\journal.vb:line 40


Line"40 is....
workPart.Views.WorkView.Orient(wpModelingView.Name, View.ScaleAdjustment.Fit)


 
Hello Kenja824,

My suspicion is that error is part specific. Does this occur for a newly created part (ideally using file-> New -> Blank)?
The system defined "Isometric" view should not have any rotation and the line mentioned is not attempting to rotate the view orientation.

-joe
 
Ha! I see what was wrong. It was me that was wrong. My overall plan is to have the code export a jpeg as this code does, but then go to drafting and insert the image. So not thinking clearly, I tried running this code from drafting. If I go to modeling, it works perfectly.

However, I am having a hard time trying to get code switch over to drafting and insert the image now. I have never figured out how to switch from modeling to drafting in VB code and not even sure if it can be done. I tried to record a journal from the drafting side that just turns the display sheet off (so it looks like you are in modeling) but it seems to not record that either. Starting to think I need to just make this into two different buttons.

Thanks for the help Jpetach.
 
Hello Kenja824,

NX journals have access to modeling and drafting functions without needing to switch applications. However, the journal code has to insure that the NX session is displaying the contents that would be displayed in the respective applications. So, for the purpose of exporting the jpeg image the drawing sheet is not the proper display. Switching to a layout that contains a model view is needed.

Please see the discussion [URL unfurl="true"]http://www.eng-tips.com/viewthread.cfm?qid=264567[/url] and look at the April 18th discussion about switching to the "L1" layout. In the example code the "Top" view was being used, where your case would use Isometric.

HTH,

Joe
 
Why would you want to add an isometric view in JPeg? NX9 can add a shaded Isometric view directly.
Just curious why you are choosing this path. :)

Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2

Building new PLM environment from Scratch using NX11 / TC11
 
NutAce said:
Why would you want to add an isometric view in JPeg? NX9 can add a shaded Isometric view directly.
Just curious why you are choosing this path. :)

I can't speak for Kenja824, but I can say that I've experienced lots of frustration with trying to plot drawings with shaded views. In some cases we've resorted to creating a jpg and importing that to the drawing. We've opened various IR's with GTAC, but the situation remains the same.

www.nxjournaling.com
 
Kenja824,
There is a command in the API to switch applications (e.g. modeling to drafting), in NX 9 this is the .ApplicationSwitchRequest method. The downside here is the switch doesn't happen until the rest of your code finishes executing. Using this method won't provide the result you are looking for. NX 10 and above has the .ApplicationSwitchImmediate method which attempts to switch as soon as the method is called.

To get what you want in NX 9, you could start in the drafting module, turn the sheet display off (.AskDisplayState, .SetDisplayState), orient the view, generate the image, turn the sheet display on, and import the image (.CreateImageFromFile).

www.nxjournaling.com
 
Status
Not open for further replies.
Back
Top