NX5 - AUTOMATE PDF EXPORT?
NX5 - AUTOMATE PDF EXPORT?
(OP)
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?





RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
It was created on NX6, but I'm fairly confident it will run on NX5. Give it a shot.
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
So where do I start? Record a journal to do what I want, and then find a Visual Basic coder to help me modify it?
-Dave
Everything should be designed as simple as possible, but not simpler.
RE: NX5 - AUTOMATE PDF EXPORT?
I have another journal that outputs a parasolid, I'd be glad to get you started. I got some help for it on this forum, if you search for 'journal output parasolid' you will probably find the code. I'm a bit tied up this morning, but I should be able to post something more useful this afternoon or tomorrow.
Do you have multiple sheets and solid bodies in your file that you want output as parasolid, STEP, and IGES? If so, do you want all of them to be output or only 1 specific solid body?
RE: NX5 - AUTOMATE PDF EXPORT?
Some drawing files will have multiple sheets. Model files should only have one solid that should be exported, but I can't guarantee someone doesn't have reference solids in the file. Because of this, I'm wondering if rather than automating the process, I should look to make it a 'guided process', ie run the journal, but get prompted to select the solid, etc. It wouldn't speed the process, but the hand-holding approach would ensure that all of the required files are created.
Also, we're using Teamcenter, so to have the files saved into TC automatically would be a bonus.
-Dave
Everything should be designed as simple as possible, but not simpler.
RE: NX5 - AUTOMATE PDF EXPORT?
Here is a starting point for you. A few words of warning are in order:
1) if your drawings use the 'master model' approach, the STEP and IGES export won't work. Apparently, STEP and IGES do not see a component as a valid entity to export, but the parasolid export works just fine.
2) you will have to open the journal file and edit the location of your STEP and IGES settings files. Look for the lines "Const stepSettingsFile as string =..." and "Const igesSettingsFile as string = ..." near the beginning of the file.
3) I am not running teamcenter, so I do not know how to save files into TC. Perhaps someone else on the forum can help you with that aspect.
4) The journal has worked in my limited testing, but I do not guarantee it to be bug free. Please post any problems you have with it.
RE: NX5 - AUTOMATE PDF EXPORT?
My journal writing has been a success! My only snag is I still am not sure how to get it to point to an attribute. Is it possible to point to an attribute name to save as the output .pdf? I would like the .pdf to be saved as the value of the attribute "PART_NUMBER"
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
CODE
Dim pdfFile as string
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
I normally go all this manually when data comes in and needs to be available to others who don't run UG.
What would need to be modified to allow the selection of sheet bodies as well?
Rob
RE: NX5 - AUTOMATE PDF EXPORT?
both your vb files are awesome, but could i trouble you to modify the for me (i've tried)
I want them to be named from the component (master model), not the drawing file, and i'd like them to output to a specific directory, eg. X\pdf's.
Help appreciated...
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
@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?
RE: NX5 - AUTOMATE PDF EXPORT?
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.
RE: NX5 - AUTOMATE PDF EXPORT?
But same again, i can work with whatever you've time for, Thanks
RE: NX5 - AUTOMATE PDF EXPORT?
I need to figure out how to prompt a question with choices of yes or no. I've attached a .vb file with what I've figured out on my own. Any help would be greatly appreciated. Thanks in advance.
RE: NX5 - AUTOMATE PDF EXPORT?
Try this:
RE: NX5 - AUTOMATE PDF EXPORT?
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?
RE: NX5 - AUTOMATE PDF EXPORT?
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.
RE: NX5 - AUTOMATE PDF EXPORT?
CODE
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
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
Something like the following:
CODE
strECR = InputBox("Enter ECR Number", "")
End While
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
Or maybe I should say it is as difficult as you make it!
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
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...
RE: NX5 - AUTOMATE PDF EXPORT?
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
RE: NX5 - AUTOMATE PDF EXPORT?
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.
RE: NX5 - AUTOMATE PDF EXPORT?
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).
RE: NX5 - AUTOMATE PDF EXPORT?
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.
RE: NX5 - AUTOMATE PDF EXPORT?
The code is in there and works for the pdf output, but I forgot to update the dxf output to use the new filename. Here are the updated versions.
RE: NX5 - AUTOMATE PDF EXPORT?
Thanks, it works great. I created another copy but different scale. I appreciatte writing the file out for me.
Maybe they make a "net programming for dummies" book. :) I think I might need that one.
Allen
RE: NX5 - AUTOMATE PDF EXPORT?
Brilliant,they work perfectly, i edited the "export drawings" to create the one for pdf's.
I couldn't find where you'd stripped off the "_dwg",
the code looked the same to me, but, hey..., it works..
Thanks again for all your help, they'll be extremely useful to us, If you ever come to Surfers' Paradise (AUS) I owe you some beers..
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
it's better than my effort, but still not right,
it strips off the _dwg, but adds the folder name i browsed it to in front of the file name, and still puts it in the same place the file was from.
RE: NX5 - AUTOMATE PDF EXPORT?
This version works for me, let me know if you have any problems.
RE: NX5 - AUTOMATE PDF EXPORT?
Thanks, that works perfectly.
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
CODE
RE: NX5 - AUTOMATE PDF EXPORT?
I opened up a dxf today with e-drawings, and everything is on the wrong axis.
Is it possible to add this journal, to the dxf-export, which will flip the drwg up onto the X-Z axis and colour the curves to white...
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
I think it a problem off your general setting- exporting dxf/dwg ( nothing to do -> we think). switch->:
customers defaults ->gateway ->visualization - view screen tab
initial view from trf-tri to top
RE: NX5 - AUTOMATE PDF EXPORT?
I changed it from front to top, but has made no difference,
i even created a new drwg from scratch on those settings.
E-drawings is a free viewer,download it & see what you get.
I was also told this problem occurs in Auto-bad as well, but i don't have it.
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
export 2d-exchange option data to export
export entire part
export top view (or) disired direction
RE: NX5 - AUTOMATE PDF EXPORT?
Yes that's right,also change the colour of everything to white.
uwam2ie,
This journal works by exporting a .cgm , then re-importing it and outputting that as a .dxf
If i then open the file in e-drawings, all you see is 1 line, as the whole drwg is layed flat on the wrong axis, rotating the ,cgm before output will fix this.
RE: NX5 - AUTOMATE PDF EXPORT?
notice that also in dxfdwg export a view option is aviable
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
Also it looks like your setting a record with the number of replies in a thread:)
The reason I'm writing is only partially on subject. This thread has been about exporting to DWG/DXF with 2D exchange. I'm having trouble doing this so that when the DWG/DXF file is opened in Acad the hidden line show up correctly. May I ask, cowski & others, what do the hidden lines in your exported files look like when you open them in Acad?
Thanks,
James
RE: NX5 - AUTOMATE PDF EXPORT?
I have installed edrawings and now I better understand the problem. Try the new & improved attached version, I can't give it 100% guarantee, but it worked in my testing.
jkcone,
I can't comment on ACAD as I do not have it to test with, but using the CGM method the hidden lines translate correctly to the edrawings viewer. I worked on ACAD years ago and seem to remember there is a setting for linetype scale (LINESCALE maybe?). Perhaps this setting is too large in ACAD making a dashed line appear as a solid line (essentially one long dash)?
This thread has also surprised me as to how long it has become. I don't think it is a record setter, but I have not seen one this long in the NX forum since Things UG needs to FIX!!! or something along those lines.
uwam2ie,
Thank you for the comment as that sparked an idea which I hope is the solution for this journal. Also, I would still love to see what settings you use for successful DXF export so that CGM's will not need to be used.
RE: NX5 - AUTOMATE PDF EXPORT?
some advice ... worked for me
-control the visualisation setting on view
-use the oldest dwg dxf Acad version (R14)
- activate drawing view style extracted edges
-use line,character or color mapping files for dxfdwg (advanced)
-for set up/control tests use the Ugpart output in 2dexchange
review the results control if everything is plain - whats lost
setting should be optimized (cotrolled)to the destinated cad solution or view -
hope it helps
RE: NX5 - AUTOMATE PDF EXPORT?
I'm not clear as to what all settings your talking about (I'm relatively new to UG). Please let me know, I'll be happy to list them. Are these settings under the Customer Defaults or the settings in the individual files?
I'm not sure what you mean by "-control the visualisation setting on view"?
I tried the R14 setting but it didn't seem to make any difference.
Didn't have any luck figuring out the "- activate drawing view style extracted edges" setting.
No luck with "-use line,character or color mapping files for dxfdwg (advanced)" either.
I did use the 2D exchange.
Acoording to this I'm pretty munch in the dark :(
If you'd like to respond back maybe I;ll help me get up to speed.
I did run across a new result thought. If I export a metric file to DWG with 2D exchange the hidden lines shows decent, not great but decent. Kinda coarse.
uwam2ie, are you able to export an NX inch drawing with 2D exchange & have the hidden lines show up correctly without modifying them in Acad?
Thanks for your help,
James
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
CODE
strCurrentDate = format(Today, "MMddyy")
RE: NX5 - AUTOMATE PDF EXPORT?
Hello again! Hope all is good. My journal is complete and has been implemented. Now I'm just tweaking it here and there to make it nicer. I figured out how to retrieve the date. I just can't figure out how to display it has the default value for an input box:
strCheckDate = workPart.GetStringAttribute("CHECKED DATE")
strCheckDate = InputBox(prompt:="Enter Checked Date")
workPart.SetAttribute("CHECKED DATE", strCheckDate)
RE: NX5 - AUTOMATE PDF EXPORT?
System.DateTime.Today.ToString("MMddyy")
Hurley I think the following should do what you want.
Dim strCheckedDate As String = WorkPart.GetStringAttribute("CHECKED DATE")
strCheckedDate = InputBox("Enter Checked Date: ","", strCheckedDate)
WorkPart.SetAttribute("CHECKED DATE", strCheckedDate)
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
Thanks again for your continued commitment to a solution for this long standing UG floor, and congratulations on a well oiled, working solution, you ARE indeed, "the man"...
RE: NX5 - AUTOMATE PDF EXPORT?
NXOpen.NXException: Orignal view to replace in layout is invalid
at NXOpen.Layout.ReplaceView(ModelingView oldView, ModelingView newView, Boolean performFitView)
at NXJournal.Main() in C:\Users\Moog\AppData\Local\Temp\NXJournals3600\journal.vb:line 130
RE: NX5 - AUTOMATE PDF EXPORT?
Does it return the same error for every part? This line of code is simply trying to perform a 'replace view' to switch to the top view. Try doing this manually (right click in the model view -> Replace view -> Top view) and see what happens.
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
Try turning on the "Auto rotate and center" option on the print dialog.
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
Yes, i get the same error for every part, and the replace view, in modelling, works fine??
RE: NX5 - AUTOMATE PDF EXPORT?
I don't have any better ideas right now.
RE: NX5 - AUTOMATE PDF EXPORT?
Now that my .pdf export is off and working, I thought I'd give your dxf export a shot, since its such a nuisance to always export a .cgm, re-import, and externally translate to a .dxf. I downloaded your latest .vb file for this and it kicks back a cgmbuilder error. Thought you could explain. Thanks in advance.
RE: NX5 - AUTOMATE PDF EXPORT?
Are you still running NX5? The journal was created in NX6, CGMBuilder may not be supported in NX5.
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?
Yes I'm using 64bit, on windows 7 at version NX6.0.5.
I'll try creating the journal you suggested. So do you think if i created the file in, say 6.0.4.3 , and I'm now running the journal in 6.0.5 it may cause this problem?
RE: NX5 - AUTOMATE PDF EXPORT?
The error message "original view is invalid" makes it sound like something is wrong with the part, but if it gives the same error in every file then something else must have changed.
RE: NX5 - AUTOMATE PDF EXPORT?
I did the replace view journal and it works in numerous parts, so i looked at its code which was slightly different to your journal, so i copied it in it's place, but still got the same error when playing the journal.
The code read....
Dim layout1 As Layout = CType(workPart.Layouts.FindObject("L1"), Layout)
Dim modelingView1 As ModelingView = CType(workPart.ModelingViews.FindObject("TOP"), ModelingView)
layout1.ReplaceView(workPart.ModelingViews.WorkView, modelingView1, True)
Instead of your.....
Dim layout1 As Layout = CType(workPart.Layouts.Current, Layout)
Dim modelingView1 As ModelingView = CType(workPart.ModelingViews.FindObject("TOP"), ModelingView)
layout1.ReplaceView(workPart.ModelingViews.WorkView, modelingView1, True)
Does this give any clues?
RE: NX5 - AUTOMATE PDF EXPORT?
I'm getting somewhere now...
My journal only works from a drawing file if i first switch to modelling...
So, i tried using your journal, but first switching to modelling, instead of letting the journal do it, and even tho it takes a very long time to complete, it actually creates the dxf, although it also saves the cgm, & the part it uses to import the cgm
RE: NX5 - AUTOMATE PDF EXPORT?
Even better....
I've just tried some recent files, as long as i switch to modelling first, your journal works fine, and the temp files don't get saved..
RE: NX5 - AUTOMATE PDF EXPORT?
Can the X_T-Step-Iges.vb export be altered to select multiple solids/sheet bodies from a file?
For example, have it Export all currently shown Sheets and solids on the screen?
Rob
RE: NX5 - AUTOMATE PDF EXPORT?
RE: NX5 - AUTOMATE PDF EXPORT?