Hi there,
could somebody help me to program an iLogic rule?
I'm a beginner with that program.
What I want is a rule for save copy as idws into pdfs.
My thought was to make it in a message box "yes/no" version.
- if I save an idw the message box should come up "Save copy as pdf? Yes - No"
- if "yes" then "save copy as" window comes up
- if "no" then rule ends
PLease help.
Solved! Go to Solution.
Create a rule and paste in this:
PDFout = MessageBox.Show("Save a PDF of this File?", "Save PDF", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
If PDFout = vbYes
Then ThisDoc.Document.SaveAs(ThisDoc.ChangeExtension(".pdf"), True)
Else
End If
Then create an event trigger for After Save to call this rule (see attached).
This does not check for or handle situations where an existing readonly PDF may occur, and it does not give you the opportunity to set the Publish options such as saving all sheets of the PDF.
If I figure that out, I'll post back.
edit:
also the MessageBoxDefaultButton.Button1
line sets the Yes button active so you can just hit Enter onthe keyboard when the message box is shown to save the PDF.
I know you got your Question
answered but you can get this to defined folder.
Will give you more control over saving all pdfs to one folder
partname_string=iProperties.Value("Project", "Part Number")'
LOCATE="enter your path here" example ("F:\D-Projects\")
ThisDoc.Document.SaveAs(LOCATE & partname_string & ".pdf" , True)
That was under assumption that the part# is your drawing #
Which is mostly the case to get less confusion in file handling 🙂
Is it possible to have it programmed so that it askes me everytime where I want to save that?
something like LOCATE = "ask me later"
Try this:
Dim oFileDlg As inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
oFileDlg.Filter = "PDF Files (*.pdf)|*.pdf"
oFileDlg.InitialDirectory = ThisDoc.Path
oFileDlg.FileName = ThisDoc.Filename
oFileDlg.CancelError = True
oDoc = ThisApplication.ActiveDocument
On Error Resume Next
oFileDlg.ShowSave()
If Err.Number <> 0 Then
MessageBox.Show("File not chosen.", "Dialog Cancellation")
ElseIf oFileDlg.FileName <> "" Then
selectedfile = oFileDlg.FileName
oDoc.SaveAs(selectedfile,True)
MessageBox.Show("File " & selectedfile & " was saved.", "PDF saved")
End If
Hello Bmiller,
You rock !! I liked that 🙂
Thanks guys, glad to help.
This still lacks one thing, and that is access to the PDF Options, such as saving all sheets.
To do that I think you have to call the PDF Translator add-in. But I've not quite figured that out yet.
Maybe someone will come along and help with that, or I'll post back if I get time to look at it deeper and have some luck.
Okay here is a version that allows you to set the PDF options, such as "print all pages" and "remove object line weights", but I'm not certain how to use the properties and alllow the user to choose the save location. This works fine for us because we save our PDF's right next to our IDW's, but it would be nice to know how to display the SaveCopyAs dialog as well.
path_and_name = ThisDoc.PathAndFileName(False) ' without extension
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
If PDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 1
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("Custom_End_Sheet") = 4
End If
'Set the destination file name
oDataMedium.FileName = path_and_name & ".pdf"
'Publish document
PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions,oDataMedium)
I'm pretty sure that this line:
path_and_name = ThisDoc.PathAndFileName(False) ' without extension
could be modified so you only grab the FileName, and then add it to a path of your choosing.
Hi,
I am wanting to name my PDF a different name than the file name. How can I do this?
We use vault as a search engine of all our parts so we have the stock number as the part and we use the part number for a different number to get manufactured.
ipt: BA1234
idw: BA1234
In the iproperties 'Project tab'
Part Number: BM5678
Stock Number: BA1234
I want to print a PDF using the iproperties number e.g. BM5678
How do I change the code to do this?
Format:HTML Format
Version:1.0
StartHTML: 165
EndHTML: 3272
StartFragment: 314
EndFragment: 3240
StartSelection: 314
EndSelection: 314
strFolder = "V:\Vault\Designs\Stock Items\PDF\" & ThisDoc.iProperties.Value("Project", "Part Number")(False) 'without extension
ThisDoc.Document.SaveAs(strFolder & (".pdf") , True)
MessageBox.Show("PDF Created", "File Save")
This should do it:
oPath = ThisDoc.Path
PN = iProperties.Value("Project", "Part Number")
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
If PDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 1
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("Custom_End_Sheet") = 4
End If
'Set the destination file name
oDataMedium.FileName = oPath & "\" & PN & ".pdf"
'Publish document
PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions,oDataMedium)'Confirmation message
MessageBox.Show("PDF SAVED TO: " & oDataMedium.FileName ,"PDF Saved", MessageBoxButtons.OK)
Or use this to set the hard path to V:\Vault\Designs\Stock Items\PDF
oPath = "V:\Vault\Designs\Stock Items\PDF\"
PN = iProperties.Value("Project", "Part Number")
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
If PDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 1
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("Custom_End_Sheet") = 4
End If
'Set the destination file name
oDataMedium.FileName = oPath & PN & ".pdf"
'Publish document
PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions,oDataMedium)'Confirmation message
MessageBox.Show("PDF SAVED TO: " & oDataMedium.FileName ,"PDF Saved", MessageBoxButtons.OK)
or the short version:
strFolder = "V:\Vault\Designs\Stock Items\PDF\" & iProperties.Value("Project", "Part Number") ThisDoc.Document.SaveAs(strFolder & (".pdf") , True) MessageBox.Show("PDF Created", "File Save")
That works a treat mate. Thanks so much.
Trying to write some of my own code but it wasn't working how I wanted it to.
Can we change it a little so it does everything I require?
I currently have vault set up to save a copy to my local folder and then have to check the file into vault.
The above code saves the pdf to my local drive and not vault.
How do we make it save a copy of the pdf in the same folder as the inventor file in vault and also add the pdf to vault?
Remembering the naming of the file and pdf are different.
File name: BA-1234
iproperties
Part Number: BM-5678
Stock Number: BA-1234
They don't need to be side by side, just in the same vault folder.
Is it possible to have the pdf attached to the idw file?
I don't think it is possible but is it possible to have the iproperties of the ipt or iam attached to the pdf and displayed like an inventor file?
Dear all,
I'm new to iLogic. Can anyone please clarify me few questions.
I'm working with an iAssembly with so many individual components (not iParts). Is it feasible if I work with iLogic instead of iAssembly?
if Yes, what kind of rules do I need to apply?
Everytime, do I need to create a "New level of detail" as per the components configuration?
I'm pretty much interested in this. Any body's help will be greatly appreciated.
Thanks in advance.
N.Kalyan
Hey try this one.
You set the folder you want and it will PDF all sheets included.
oPath directs it to a folder so all PDFs are in one folder if you want.
oPath = "V:\Vault\Designs\Stock Items\PDF\"
PN = iProperties.Value("Project", "Part Number")
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
If PDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 1
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("Custom_End_Sheet") = 4
End If
'Set the destination file name
oDataMedium.FileName = oPath & "\" & PN & ".pdf"
'Publish document
PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions,oDataMedium)
'Confirmation message
MessageBox.Show("PDF SAVED TO: " & oDataMedium.FileName ,"PDF Saved", MessageBoxButtons.OK)
neresh kalyan
If you are looking for iLogic help, give me a call.
Thomas Fitzgerald
Mfg. Engineering Consultant
iLogic
262.812.6137
thomas.fitzgerald@irontownsoftware.com
Can't find what you're looking for? Ask the community or share your knowledge.