Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export Jpeg Macro

Status
Not open for further replies.

Vann

Automotive
Jan 27, 2004
8
Hello,

I am very new to UG. I am trying to write a macro in NX2 that will let me export a jpeg of a model and save it with the active model's filename.

Basically I want to open the .prt file, adjust it to the view I ant, then run my macro to save it in a directory with the rest of my jpegs.

I can't seem to find the proper syntax for inserting the active model's filename into the file dialog box during the macro.

Below is my macro so far. I left in the erronous parts so you can see what I am trying to do.


Unigraphics NX 2.0.3.1
Macro File: C:\Work\UG_COLOR_Pallette\ExportJPEG.macro
Macro Version 7.20
Macro List Language and Codeset: english 17
Part Name Display Style: $FILENAME
Selection Parameters 1 2 0.259128 1
Display Parameters 1.000000 14.048967 9.832908 -1.000000 -0.699903 1.000000 0.699903
*****************
RESET
MENU, 0, UG_FILE_EXPORT_JPEG UG_GATEWAY_MAIN_MENUBAR !
DIALOG_BEGIN "JPEG Image File" 0
BEG_ITEM 0 (1 WIDE 0) = &FILENAME ! JPEG File --- I want the active part name to display here
BEG_ITEM 3 (1 BOOL 0) = 0 ! Use White Background
EVENT VALUE_CHANGED -50 0, 3, 0, 0! Use White Background
ASK_ITEM 3 (1 BOOL 0) = 1 ! Use White Background
EVENT ACTIVATE -50 0, 1, 0, 0! Browse...
ASK_ITEM 0 (1 WIDE 0) = $FILENAME ! JPEG File
FILE_BOX -2, P:\Work\Jpegs\mat002_100_covinsert-aa.jpg P:\Work\Jpegs\*.JPG 0 ! JPEG Image File
ASK_ITEM 0 (1 WIDE 0) = "P:\Work\Jpegs\" & $FILENAME & ".jpg" ! JPEG File ---This is not working
END_ITEM 0 (1 WIDE 0) = "P:\Work\Jpegs\" & $FILENAME & ".jpg" ! JPEG File ---This is not working
END_ITEM 3 (1 BOOL 0) = 1 ! Use White Background
DIALOG_END -2, 0 ! JPEG Image File: OK
FOCUS CHANGE IN 1

I am familiar with VB and some other programming but I am not sure how (or if it is possible) to use variables in the macro.

Thanks in advance for any help.

 
Replies continue below

Recommended for you

I don't have an answer but I would love to know!!

I also have to create a lot of JPEG files and have never thought of using a macro in this manner. This macro that Vann has suggested would be perfect for our use as we also intend other engineers to get involved in JPEG creation.

I hope somenone can help with this query from Vann.


Regards,

Andy.

---------------------
Design Draughtsman
Biomet Ltd
 
There isn't anyway to do that. A UG Macro, prior to NX3, is just a keystroke record. In NX3, you may be able to do it with the new journaling, which uses VB.


"Wildfires are dangerous, hard to control, and economically catastrophic."
"Fixed in the next release" should replace "Product First" as the PTC slogan.

Ben Loosli
CAD/CAM System Analyst
Ingersoll-Rand
 
Thanks for the replies

I was kind of hoping you could manipulate the UG macro like a MS Word or Excel macro and have it pull values out of the active application.We will eventually be going to NX3 and if it has a VBA style editor than that will be very helpful.

As a side note: I am very interested in learning how to automate some things in UG and am trying to decide on what language to learn.
This forum seems really helpful. Is there any such thing as a tutorial for learning GRIP and UG/OPEN? or would I be further ahead to concentrate on C+ and .NET?

Thanks again for the replies
 
GRIP has not been enhanced since about V13 with the exception of plotting in NX3. It is considered in 'maintenance mode' by UGS.

UG/Open uses C++ and .net, depending on UG/NX version.
NX3 has journaling, which is more powerful than macros.

It also depends on what you want to automate. File management can be done with GRIP. Geometry/Drafting creation or modification require UG/Open API.


"Wildfires are dangerous, hard to control, and economically catastrophic."
"Fixed in the next release" should replace "Product First" as the PTC slogan.

Ben Loosli
CAD/CAM System Analyst
Ingersoll-Rand
 
You may be able to
1. Record a macro using the pause option which will let you manually enter the part name to open and name jpeg the same thing manually or use the macro option to allow for user to "enter text in file open dialogs" and get it to work

2. just record a macro where you paste in the file name. and save the macro in a text editor with ##### or some other symbol where the full part path is shown in the macro.

Then you can open the text file and do a replace of #####.prt with C:/PartPathlocation.prt &
#####.jpg with C:/PartPathlocation.jpg

And save it as All Files .macro and run it.

Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor