Creating PDF, Defered Updates drawing, Remove Line Weights option doesn't stick

Creating PDF, Defered Updates drawing, Remove Line Weights option doesn't stick

Anonymous
Not applicable
754 Views
9 Replies
Message 1 of 10

Creating PDF, Defered Updates drawing, Remove Line Weights option doesn't stick

Anonymous
Not applicable

Hello all,

 

I am creating a PDF from an Inventor .dwg with an iLogic code frankensteined from various sources.

 

I have some options, one of them being: 

 

oOptions.Value("Remove_Line_Weights") = 1 

This works when the dwg has Defered Updates OFF, but when the Defered Updates are ON, the line weight option doesn't do anything.

This is important because when printed, they look very different!

 

I'm sure it's because I have very little clue as to what I am doing, beyond my extreme Copy Jockey skills. Any ideas?

 

My full code below:

 

'check if file type is a drawing file
If ThisDoc.Document.DocumentType <> kDrawingDocumentObject Then
MessageBox.Show("This file is not a drawing file.", "iLogic")
Else If ThisDoc.Document.DocumentType = kDrawingDocumentObject Then

'If there is a problem creating the PDF, it's probably because one is already open with the same name
On Error Goto handlePDFLock

'sets the Approved Date in iProperties to NOW
iProperties.Value("Status", "Eng. Approved Date" ) = Now
'sets the current time as a custom value
iProperties.Value("Custom", "Time Saved") = Now.ToString("HH:mm:ss")
'sets the current date and time for filename saving
Dim NowDateTime = Now.ToString("yyMMdd") & Now.ToString("HHmm")

'saves the current doc
ThisDoc.Save

'get path of current file
strPATH = ThisDoc.Path

'get file name
strFNAME = ThisDoc.FileName(False)

'set Project and Description
strProject = iProperties.Value("Custom", "Job")

'Save PDF with options
PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

Dim oDrawing as DrawingDocument
oDrawing = ThisDrawing.Document


oOptions.Value("All_Color_AS_Black") = 1
oOptions.Value("Remove_Line_Weights") = 1  ' a 1 removes the line weights
oOptions.Value("Vector_Resolution") = 4800
	
	'If there Is an AutoCad Model Space included, then don't print it
	If oDrawing.Sheets.Item(1).Name = "Model (AutoCAD)" Then
		iBeginSheet = 2
	Else iBeginSheet = 1
	End If

oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
oOptions.Value("Custom_Begin_Sheet") = iBeginSheet
oOptions.Value("Custom_End_Sheet") = 999

'Set the destination file name
oDataMedium.FileName = strPATH & "\" & strFNAME & " " & strProject & " " & NowDateTime &".pdf"

'Publish document.
Call PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

'Open the PDF file that was just created.
ThisDoc.Launch(oDataMedium.FileName)
End If

Exit Sub
handlePDFLock:
MessageBox.Show("PDF WAS NOT SAVED.   Please close any open PDFs.", "No PDF for you")
0 Likes
755 Views
9 Replies
Replies (9)
Message 2 of 10

bradeneuropeArthur
Mentor
Mentor

For me it works correctly.

 

Drawing lineweights on deferupdate on:

 

LineWeight.PNG

 

Pdf without:

 

LineWeight Off.PNG

 

Pdf With:

 

LineWeight On.PNG

 

What inventor version are you using?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 10

Anonymous
Not applicable

I'm using 2017. What are you using?

0 Likes
Message 4 of 10

bradeneuropeArthur
Mentor
Mentor

2018

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 10

Anonymous
Not applicable

Ok, thanks for checking and confirming it works in 2018.

I am going to upgrade, but it won't be for another month - too busy to do now!

 

Anyone else confirm that it either doesn't work in 2017, or does work in 2018?

0 Likes
Message 6 of 10

bradeneuropeArthur
Mentor
Mentor

Maybe this is the issue:

 

Change your code a bit.

 

I think there is an error at your oOptions declarations:

 

If ThisDoc.Document.DocumentType <> kDrawingDocumentObject Then
MessageBox.Show("This file is not a drawing file.", "iLogic")
Else If ThisDoc.Document.DocumentType = kDrawingDocumentObject Then

'If there is a problem creating the PDF, it's probably because one is already open with the same name
On Error GoTo handlePDFLock

'sets the Approved Date in iProperties to NOW
iProperties.Value("Status", "Eng. Approved Date" ) = Now
'sets the current time as a custom value
iProperties.Value("Custom", "Time Saved") = Now.ToString("HH:mm:ss")
'sets the current date and time for filename saving
Dim NowDateTime = Now.ToString("yyMMdd") & Now.ToString("HHmm")

'saves the current doc
ThisDoc.Save

'get path of current file
strPATH = ThisDoc.Path

'get file name
strFNAME = ThisDoc.FileName(False)

'Set Project And Description
strProject = iProperties.Value("Custom", "job")

'Save PDF with options
PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

Dim oDrawing As DrawingDocument
oDrawing = ThisDrawing.Document
	'If there Is an AutoCad Model Space included, Then don't print it
	If oDrawing.Sheets.Item(1).Name = "Model (AutoCAD)" Then
		iBeginSheet = 2
	Else 
		iBeginSheet = 1
	End If
oOptions.Value("All_Color_AS_Black") = 1
oOptions.Value("Remove_Line_Weights") = 1  ' a 1 removes the line weights
oOptions.Value("Vector_Resolution") = 4800
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintSheetRange'.kPrintAllSheets
oOptions.Value("Custom_Begin_Sheet") = iBeginSheet
oOptions.Value("Custom_End_Sheet") = oDrawing.Sheets.Count

'Set the destination file name
oDataMedium.FileName = strPATH & "\" & strFNAME & " " & strProject & " " & NowDateTime &".pdf"

'Publish document.
Call PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

'Open the PDF file that was just created.
ThisDoc.Launch(oDataMedium.FileName)
End If

Exit Sub
handlePDFLock:
MessageBox.Show("PDF WAS NOT SAVED.   Please close any open PDFs.", "No PDF for you")

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 7 of 10

Anonymous
Not applicable

Thanks for pointing that out! 

I still am having trouble, I wonder if it has anything to do with Acrobat?

0 Likes
Message 8 of 10

bradeneuropeArthur
Mentor
Mentor

Please upload a pdf!

 

I was wondering that also!

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 9 of 10

Anonymous
Not applicable

I can't post the drawing that I want to (proprietary), so I will make a new one soon and post that.

0 Likes
Message 10 of 10

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @Anonymous,

 

 

Did you get a chance to prepare sample drawing file which is non proprietary?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes