Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

NX5 - AUTOMATE PDF EXPORT? 3

Status
Not open for further replies.

hurley710

Automotive
Feb 4, 2009
59
Currently, we export drawings into an Electronic Data Management System using GRIP. Drawings are released into .hgl format. Is there a way to automate an export of these drawings as .pdf?
 
Replies continue below

Recommended for you

@robnewcomb: the selection subroutine is currently set up to mask for solid bodies and return 1 body. We'll have to look at changing the mask and setting up an array to hold multiple selections. I might have some time to look into it later today.


@moog2: let me make sure I understand, you want to export .pdf's of the drawing and name them based on the component's name? Do you want to export pdf and dxf? What if there are multiple components in the file, which name do we use?
 
i want to export .pdf's and separately, .dxf's .
If the drawing contains multiple parts it'll be in an assembly, so the top level name of the component/assembly is what i'd like to use.
this is because our parts (& assemblies) are called say, ABCD-1234.prt and the drawing file would be ABCD-1234_dwg.prt , so the _dwg is just to differentiate the files, but the drawing would be of ABCD-1234

Could the dxf output be "_sh1" instead of just "_1"
I'd also prefer to point to a start part for the temp file, not the "BLANK" template, but if this is too hard, don't worry, as i don't want to waste too much of your time, but appreciate every minute of it.
 
sorry, but one more thing,I'd like it to over-write any existing files (cos they don't rev file numbers here.....Yea i Know......)
But same again, i can work with whatever you've time for, Thanks
 
moog2,
Run the attached script (it will list your available part templates) and respond with which template name you would like to use.

Also, as I understand it you want to export both pdf and dxf's (no parasolids or step files, etc). Is it OK if we grab the part name and just strip off the "_dwg", would that do the job?
 
 http://files.engineering.com/getfile.aspx?folder=0b3a2bf8-e4a9-4c5a-b8cf-2725c6fe703a&file=file_new_templates.vb
cowski,
I believe this is going to work after a couple bugs are figured out. NX is kicking back a couple journal compile errors as follows:
if strRelease = "PROD" then <--- 'If' must end with a matching 'End If'
strECR = Input Box("Enter ECR Number") <---Overload resolution failed because no accessible 'Input' accepts this number of arguments. Also, end of statement expected.
 
There is a space in the keyword "InputBox" that should not be there. Add an 'end if' at the end of the code.

Code:
dim strRelease as string
dim strECR as string * 5
dim strPartNumber as string
dim intResponse as integer

'retrieve RELEASE STATUS attribute
strRelease = workPart.GetStringAttribute("RELEASE STATUS")
if strRelease = "PROD" then
	'PROMPT QUESTION "IS ECR PENDING?"
	'PROMPT CHOICES: YES OR NO
	if msgbox("Is ECR pending?", vbyesno + vbquestion) = vbyes then
		'if YES, then
		strECR = InputBox("Enter ECR Number")
		printPDFBuilder1.Filename = "N:\ug\hpgl\" & "ECR" & strECR & "_" & strPartNumber & ".pdf"
	else
		'IF NO,
		printPDFBuilder1.Filename = "N:\ug\hpgl\" & strPartNumber & ".pdf"
	end if
end if
 
figured it out right as you replied. thanks again!
 
Also, you might want to add a loop around the input box so that you don't end up with an empty string.

Something like the following:

Code:
While strECR = ""
strECR = InputBox("Enter ECR Number", "")
End While
 
good idea. i added that in there. does it get a whole lot more complicated when i start asking questions that have more than just yes/no answers? id like to prompt a question that would have 5 possible answers, none being of yes/no/cancel type.
 
If you have a UI styler license you can create your own input forms (I do not have this license). I imagine it is similar to forms with Excel VBA or Visual Studio, if so, it is not too difficult.

Or maybe I should say it is as difficult as you make it!
 
I do have that license. That is something I will play around with after the weekend. One thing that would cut my work down is to launch an existing grip (.grs) file within my journal. Possible?
 
I don't think that is possible (at least not in NX6).
 
Cowski,
Yes, stripping off the _dwg will work fine for the file name, and yes i'd like separate journals for exporting, .pdf , dxf, (i could also use one for just parasolids) but mainly the pdf and dxf are what i'd like.

I ran the script and it returned all my templates(including the one in the start-up folder), not sure if you wanted me to tell you what it listed, but if you could just make it work using a path and name of one of yours, once the code is set up for using something other than the blank, i can edit it to use mine.

I've already tried changing the line where it calls the "blank" template, and changed it to my start part+path but it didn't work, so maybe it has to be declared or something?

Incidentally the list did state the blank is available even tho when its turned off in defaults, the journal didn't work,...maybe its listed cos i've been turning it on and off to test the journals?
The biggest issue at the moment is overwriting existing files.
It would be great if you can sus these out as they'd get used 10 times a day by a couple of us guy's, Thanks...
 
Cowski,
I hate to jump in with a similiar request but it's a little different than your first vb for Hurley710 (export_pdf_mod).

I was wanting to ending pdf file to be located in a specific directory, like a directory located on my desktop.

Also, is there something I could get to help me with future writing of vb programs?

Thanks
 
moog & albates1972,
Attached is a zip file containing 3 journals. One exports pdf files, one exports dxf files, and the third exports both in 1 shot. All 3 allow you to choose a folder for export. If you run either of the journals that export dxf files, make sure you edit the journal first to point to your dxf settings file (explained near the top of the journal files).

moog,
I added some notes in the 'NewFile' subroutine that should help you set up the template that you want to use.

 
 http://files.engineering.com/getfile.aspx?folder=e2bac915-b964-465a-a33c-26335cb475fa&file=moog.zip
albates,
If you are familar with some basic programming concepts (variables, loops, etc) I would suggest recording a macro and modify it to see if you can get what you need. If you are not familiar with such concepts, I would suggest finding a book or 2 at your local library on .net programming for beginners. I use visual basic because that is what I am most familiar with, but NX journals can be written in other languages as well. I don't know of any information sources that focus on NX journals, perhaps a forum on siemen's website? (I'm not sure because I don't currently have a webkey account).
 
Cowski,
They work perfectly, Could you please just add the strip-off "_dwg"
command into one of them, and i'll edit the others to suit.
Thanks again for all your generous help..

I too wish i could learn these skills, maybe with all the variants in this thread, we can try to understand some of it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor