Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Automate PDF Export and Sort by numbers 2

Status
Not open for further replies.

hermhart

Automotive
Sep 28, 2004
23
Hello, I have these two great VB scripts for exporting a PDF and sorting the Sheet names by number, but am wondering if anyone has the knowledge on how to combine these both together into one VB script.

Thank you for any help that you can provide.
 
 http://files.engineering.com/getfile.aspx?folder=59b35ec6-3b4d-4222-b723-dfb52472d003&file=Export_Sorted_PDF.zip
Replies continue below

Recommended for you

Hi cowski,

I just tried this journal but it didn't produce any output, however looking at the log file I think it's because our part numbers have a slash in them so it's tried to create 332/G2189_3.pdf .

Recently we were looking at an export CGMs journal, which used the sheetnames rather than the filename, and cycled through the sheets to update before exporting CGMs (attached).

Is it possible to modify the attached to export PDFs in the same way?

Thanks in advance, Carl

NX 8.5 with TC 8.3

 
Cowski, I gave this a try, but unfortunately it still produced the PDF's in an unsorted order. So if I have 11 sheets, they get produced in the following manner:

Sheet1
Sheet10
Sheet11
Sheet2
Sheet3
etc.

I really appreciate your help though.
 
hermhart,
I've updated the journal, please download it again (use the link in the previous post).

carlharr,
Do you want each sheet exported to an individual pdf file?

www.nxjournaling.com
 
It's possible as long as we are exporting to the file system.

It's probably also possible if you want to export to TC dataset(s), but I have not figured that out yet.

www.nxjournaling.com
 
Hi cowski,

Just to the file system would be fine, so essentially the same as CGM export in the journal, but for PDF.
I'm looking for ways for engineers to get exports out quickly, for communicating with suppliers etc.

All this work is a follow on from the "no CGMs in MS Office products" problem.

For a couple of reasons, I'm not overly keen on exports to Teamcenter.

Much appreciated, Carl



NX 8.5 with TC 8.3
 
cowski,

That did it! Thank you so much, you are a life saver! I would have never gotten that.
 
cowski,

That is perfect!

I'll send it out to some of our users for a thorough test, but its working great on my machine.

Much appreciated, Carl

NX 8.5 with TC 8.3
 
cowski,

I hate to ask, but for the script that you made for me, is there a way that it can also be made to run externally from the NX command prompt on a directory of parts, where it would open and cycle through each .prt file in a directory, and do the same exporting that you have set up in the journal already? I'm working on modifying the script that you gave me, but I know that my programming skills are majorly lacking.

In the end, if I or you are able to make this work, I'm hoping that I might also be able to use the same code for other export types, such as STEP, IGES, etc.

Thank you again for taking a look at this, your last script for this has worked amazingly.
 
Try this journal.

Start the NX command prompt and enter:
Code:
[b]run_journal[/b] {path to journal file} [b]-args[/b] {path of folder to scan} {path of folder to output pdf files}

www.nxjournaling.com
 
cowski,

This works great, thank you!

Can I ask one last favor though? I have a bit of code I'd like to incorporate into this which makes it so it doesn't process it and make a pdf file if the sheet is empty.

I know that I am probably pushing it, but I could I ask you to incorporate such a function. One would hope that you shouldn't need such a thing, but it seems that people are not clean with their files and do not delete empty sheets.

Code:
' ----------------------------------------------
'    Do Not Process Empty Sheet(s) (DeleteEmptySheets)
' ----------------------------------------------
	For Each dwg As DrawingSheet In s.Parts.Display.DrawingSheets
	dwg.Open()
	's.ListingWindow.WriteLine("Drawing:  " & dwg.Name.ToString)
	'	For Each dV As DraftingView In dwg.GetDraftingViews()
	'   	Dim dvTag As NXOpen.Tag = dV.Tag
	'       Dim dvObj As NXOpen.Tag = NXOpen.Tag.Null
	'       ufs.View.CycleObjects(dvTag, _
	'       	UFView.CycleObjectsEnum.VisibleObjects, dvObj)
	'       If (dvObj = NXOpen.Tag.Null) Then
	'       	s.ListingWindow.WriteLine(" deleting empty view:  " & _
	'           	dV.Name.ToString)
	'           ufs.View.Delete(dvTag)
	'       End If
	'	Next
		Dim dsTag As NXOpen.Tag = dwg.View.Tag
		Dim dsObj As NXOpen.Tag = NXOpen.Tag.Null
		ufs.View.CycleObjects(dsTag, UFView.CycleObjectsEnum.VisibleObjects, _
			dsObj)
		If (dsObj = NXOpen.Tag.Null) And _
			(dwg.GetDraftingViews.Length = 0) Then
			s.ListingWindow.WriteLine("    Empty drawing not processed: " & _
				dwg.Name.ToString)
			ufs.Draw.DeleteDrawing(dwg.Tag)
		End If
	Next
	
    If thePart.Tag = Tag.Null Then
        Return
    End If
		
    Dim drawingSheets As DrawingSheet() = thePart.DrawingSheets.ToArray

    If drawingSheets.Length() > 0 Then
        lw.WriteLine("    Sheets found: " & drawingSheets.Length().ToString())
    End If

    Dim mySheet As DrawingSheet = Nothing

    Dim partName As String = thePart.Leaf.ToString()

    For Each mySheet In drawingSheets

        lw.WriteLine("     Processing Sheet: " & mySheet.Name())

        mySheet.Open()
 
I seem to get a lot of "Part Scan Error: Object reference not set to an instance of an object." errors, then it stops after that.
 
Bummer, we should have quit while we were ahead.[bigsmile]

I've updated the code, you can get it from the same link as above (link in post dated: 1 Dec 14 14:40).

www.nxjournaling.com
 
Hi Cowski,

I tried to use your updated script for exporting pdf in one file but it's giving ordering different apart from sheet numbers like sheet 10, 1 , 6, 3 etc. Could you please share correct path for script to export pdf as per sheet numbers.

And, I am also looking for export selective sheets as one pdf. for example I have 10 sheets drawing. so I want to export 1 to 5 in pdf1 and 6 to 10 ion pdf 2 like that. or selected sheets numbers in one pdf file

Please do needful


Thanks & Regards,
Ganesh
 
cowski,

This works amazingly, thank you! It does say many times "part open error: File already exists", which I'm not sure why, but it is still doing everything I hoped.

I can't thank you enough!

Thank you, thank you, thank you! [bigsmile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor