All_Colors_As_Black not working properly

All_Colors_As_Black not working properly

Anonymous
Not applicable
401 Views
2 Replies
Message 1 of 3

All_Colors_As_Black not working properly

Anonymous
Not applicable

Hello,

 

I am trying to run a macro to export all of the .idw files in a folder to PDF. I managed to run everything smoothly, but some of my exported files are not completely black. 

 

Some of them have gray lines which are not sharp at all, and others have even light blue lines. 

 

I have tried to run the same procedure without the All_Color_As_Black option, and the gray lines stayed exactly the same, while the lines that were translated properly are now colored (red and green).

My code is the following:

' Get the PDF translator Add-In.
	Dim PDFAddIn As TranslatorAddIn
	Set PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
	'Set a reference to the active document (the document to be published).
	Dim oDocument As Document
	Set oDocument = ThisApplication.ActiveDocument
	Dim oContext As TranslationContext
	Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
	oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
' Create a NameValueMap object for PDF exportation
	Dim oOptions As NameValueMap
	Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object for PDF exportation
	Dim oDataMedium As DataMedium
	Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
' Check whether the translator has 'SaveCopyAs' options
	If PDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
		' Options for drawings...
		oOptions.Value("All_Color_AS_Black") = 1
		oOptions.Value("Remove_Line_Weights") = 0
		oOptions.Value("Vector_Resolution") = 400
		oOptions.Value("Sheet_Range") = kPrintAllSheets
		'oOptions.Value("Custom_Begin_Sheet") = 2
		'oOptions.Value("Custom_End_Sheet") = 4
	End If
For Each oDocument In ThisApplication.Documents.VisibleDocuments
	
		' Make sure a drawing document is active.
		If Not (TypeOf oDocument Is DrawingDocument) Then
			'MsgBox "A drawing must be active."
			GoTo NextDoc
		End If
	
		'Get model iProperties'
		' Get the PropertySets object.
		Dim oPropSets As PropertySets
		Set oPropSets = oDocument.PropertySets
		
		' Get the Inventor Summary Information set.
		Dim oPropSet As PropertySet
		Set oPropSet = oPropSets.Item("Inventor Summary Information")
		
		' Get the revision number iProperty.
		Dim RevNumber As Property
		Set RevNumber = oPropSet.Item("Revision Number")
		
		' Get the design tracking property set.
		Set oPropSet = oPropSets.Item("Design Tracking Properties")
		
		' Get the part number iProperty.
		Dim PartNumber As Property
		Set PartNumber = oPropSet.Item("Part Number")
		
		'Get referenced Model iProperties'
		Dim oDV As DrawingView
		Dim oReffDoc As Document
		Dim oReffPropSet As PropertySet
		Dim oReffCustProp1 As Property
		Dim oReffCustProp2 As Property
		Dim oReffCustProp3 As Property
		Dim oReffCustProp4 As Property
		
		Dim drawDoc As DrawingDocument
		Set drawDoc = oDocument
		
		'Get file name'
		FileName = Left(drawDoc.DisplayName, Len(drawDoc.DisplayName) - 4)

'Set the destination file name for PDFs
			oDataMedium.FileName = FullPath & FileName & "_" & RevNumber.Value & ".pdf"
'Publish document.
		Call PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

I don't understand why some drawings come out perfectly, while others (usually the most complicated ones) fail partially. The fact that when I deactivate the option All_Colors_As_Black only some lines change color made me think that the problem was in the idw file. But if I manually export the PDF from Inventor, setting all colors as black, then it works fine. 

 

Any suggestion is much appreciated

 

Thanks

Alessandro  

0 Likes
402 Views
2 Replies
Replies (2)
Message 2 of 3

A.Acheson
Mentor
Mentor

Here is a sample of the api translator code your using and there is a few difference I see. The saving is taking place outside of the options if statement.
Also the data medium is being set before the options in your code and after the options in the sample. Has this any bearing? 
Maybe try the sample and see if it also produces the same result. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 3

Anonymous
Not applicable

Hello Alan,

 

thank you for the kind answer. 

I don't think the problem is in the order in which variables are declared sadly. I think if that was the case it would never work.

 

I think instead that the issue is in the .idw file itself, since I've recently ran the same routine on another project folder and all of the PDFs that were created had no issues at all. 

 

Still wandering what is causing this tho...

 

Have a nice day

 

Alessandro

0 Likes