ciao a tutti, ho provato a scaricare tutte le regole postate in questa discussione, ho inventor 2018 e nessuna mi funziona
utilizzando questa
syntaxeditor code snippet'define the active document as an assembly file
dim oasmdoc as assemblydocument
oasmdoc = thisapplication.activedocument
oasmname = left(oasmdoc.displayname, len(oasmdoc.displayname) -4)
'check that the active document is an assembly file
if thisapplication.activedocument.documenttype <> kassemblydocumentobject then
messagebox.show("please run this rule from the assembly file.", "ilogic")
exit sub
end if
'get user input
rusure = messagebox.show ( _
"this will create a pdf file for all of the asembly components that have drawings files." _
& vblf & "this rule expects that the drawing file shares the same name and location as the component." _
& vblf & " " _
& vblf & "are you sure you want to create pdf drawings for all of the assembly components?" _
& vblf & "this could take a while.", "ilogic - batch output pdfs ",messageboxbuttons.yesno)
if rusure = vbno then
return
else
end if
'- - - - - - - - - - - - -pdf setup - - - - - - - - - - - -
opath = thisdoc.path
pdfaddin = thisapplication.applicationaddins.itembyid("{0ac6fd96-2f4d-42ce-8be0-8aea580399e4}")
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") = 0
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
'get pdf target folder path
ofolder = opath & "\" & oasmname & " pdf files"
'check for the pdf folder and create it if it does not exist
if not system.io.directory.exists(ofolder) then
system.io.directory.createdirectory(ofolder)
end if
'- - - - - - - - - - - - -
'- - - - - - - - - - - - -component drawings - - - - - - - - - - - -
'look at the files referenced by the assembly
dim orefdocs as documentsenumerator
orefdocs = oasmdoc.allreferenceddocuments
dim orefdoc as document
'work the the drawing files for the referenced models
'this expects that the model has a drawing of the same path and name
for each orefdoc in orefdocs
idwpathname = left(orefdoc.fulldocumentname, len(orefdoc.fulldocumentname) - 3) & "idw"
'check to see that the model has a drawing of the same path and name
if(system.io.file.exists(idwpathname)) then
dim odrawdoc as drawingdocument
odrawdoc = thisapplication.documents.open(idwpathname, true)
ofilename = left(orefdoc.displayname, len(orefdoc.displayname) -3)
on error resume next ' if pdf exists and is open or read only, resume next
'set the pdf target file name
odatamedium.filename = ofolder & "\" & ofilename & "pdf"
'write out the pdf
call pdfaddin.savecopyas(odrawdoc, ocontext, ooptions, odatamedium)
'close the file
odrawdoc.close
else
'if the model has no drawing of the same path and name - do nothing
end if
next
'- - - - - - - - - - - - -
'- - - - - - - - - - - - -top level drawing - - - - - - - - - - - -
oasmdrawing = thisdoc.changeextension(".idw")
oasmdrawingdoc = thisapplication.documents.open(oasmdrawing, true)
oasmdrawingname = left(oasmdrawingdoc.displayname, len(oasmdrawingdoc.displayname) -3)
'write out the pdf for the top level assembly drawing file
on error resume next ' if pdf exists and is open or read only, resume next
'set the pdf target file name
odatamedium.filename = ofolder & "\" & oasmdrawingname & "pdf"
'write out the pdf
call pdfaddin.savecopyas(oasmdrawingdoc, ocontext, ooptions, odatamedium)
'close the top level drawing
oasmdrawingdoc.close
'- - - - - - - - - - - - -
messagebox.show("new files created in: " & vblf & ofolder, "ilogic")
'open the folder where the new ffiles are saved
shell("explorer.exe " & ofolder,vbnormalfocus)
mi esce questo errore

