Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

NX Journal for importing CGMS and exporting pdfs.

Status
Not open for further replies.

beng021228

Mechanical
Apr 10, 2012
17
0
0
US
I'm writing a Journal that will import cgm files and export a pdf of the cgm. I'm using NX6 with the vb language for journals. I say nx6, but I run into the same problem in nx8. First I recorded a journal where I create a new model file, go into drafting (thus creating a dummy blank sheet that doesn't get used) import the cgm file, and export the new sheet created by the import as a pdf. Doing this manually creates a correctly sized drawing sheet containing the cgm data. When I replay this journal it imports the cgm into the dummy sheet, the size is incorrect, unless it so happens that the cgm is the same size as my dummy sheet. I'm trying to figure out how to get the journal to import the cgm file in the same way that manually importing does. My goal is to end up with a form type journal where I select a folder containing cgm files, hit exexute and it converts the cgm files to pdfs. Currently it works thusly, however all the pdfs are chopping bits of the cgm off because of the incorrect sheet size. I thought maybe I could preread the cgm file and determine the size I should make my dummy sheet, but I think cgm files are in hex and I don't know how to deal with that. Any help would be greatly appreciated.

Here's my bit of code where the importing happens:
Dim importer1 As Importer
importer1 = workPart.ImportManager.CreateCgmImporter()

importer1.FileName = fullfilepath & "cgm"

Dim markId9 As Session.UndoMarkId
markId9 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Import CGM Commit")

Dim nXObject3 As NXObject
nXObject3 = importer1.Commit()

theSession.DeleteUndoMark(markId9, Nothing)

importer1.Destroy()

Thanks again.
 
Replies continue below

Recommended for you

/facepalm

This will eliminate miles of code.

Thanks!! By the way, I saw that website when searching for an answer. I wondered if it was brand new. It looks great.
 
I got it working, but it seems that I can't pass it a file on a network drive for some reason. I even tried using the cgm2pdf manually through a command prompt. Local folders work fine, local folders with spaces in the names works fine as well. It's odd.
 
Status
Not open for further replies.
Back
Top