• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

question about ilogic

  • Thread starter Thread starter Gian704
  • Start date Start date

Gian704

Guest
work with inventor 2021, first with 2014 I was able to create files in pdf and dwg with the macro visual basic that you posted here, now with the 2021 it is no longer possible to use visual basic, I would like to know if someone is able to do the same with ilogic, I fucked the old macro, it works but does not create files with the revision that I imposed, take off here what I have combined, someone will tell me where is the error
thank you to those who want to answer me.

syntaxeditor code snippet
strfolder = "c:\users\acer\desktop\dwg-dxf-pdf\" & thisdoc.filename(false) 'without extension

thisdoc.document.saveas(strfolder & (".pdf), true

'ooptions.value('all_color_as_black') = 0
'ooptions.value("remove_line_weights") = 0
'ooptions.value("vector_resolution") = 600
'ooptions.value("sheet_range") = kprintallsheets
'ooptions.value('custom_begin_sheet') = 1
'ooptions.value('custom_end_sheet') = 5

' revision number
dim srev as string
rev = inputbox("revision:? ", "input revision number", "00")

ocustompropset = ("{d5cd505-2e9c-101b-9397-08002b2cf9ae")

on error resume next
dim scod as string

' replace "code" with the name used for the hyperperty that interests you
scod = ocustompropset.item("code").value

filename = filename & " rev. " & rev & ""

'get the pdf translator add-in.
dim pdfaddin as translatoraddin
pdfaddin = thisapplicationaddins.itembyid("{0ac6fd96-2f4d-42ce-8be0-8aea580399e4}")

dim strinifile as string

' common init
' created in context
dim ocontext as translationcontext
ocontext = thisapplication.transientobjects.createtranslationcontext
ocontext.type = kfilebrowseiomechanism

' created in namevaluemap object
dim ooptions as namevaluemap
ooptions = thisapplication.transientobjects.createnamevaluemap

' created at datamedium object
dim odatamedium as datamedium
odatamedium = thisapplication.transientobjects.createdatamedium

'function that returns the file name by removing the path and suffix

'toglie il .ipt
if trunc = true then
filename = strings.left(filename, len(filename) - 4)
end if

dim pos as integer
'cycle that removes the path: finds "\" and keeps everything right

pos = instr(filename, "\")
filename = strings.right(filename, len(filename) - pos)
loop until pos = 0
islandname = filename
 
Last edited:
Hello.
In fact, the "s" is in the name of a declared variable but is not used, so there is no error (as much as it is an inaccuracy, but rather than adding the "s" in all uses I would prefer to remove it from the declared variable not to compromise the operation of the rule).
the variable used in fact is "rev", not "srev" and in i-logic if you value a variable works even without declaring it.
I think the problem could be in the name that is then assigned to the pdf output:
if you are using "filename" or "isolanome" then only the name of the original file without extension will come out, but the revision that you write in input here: " rev = inputbox("revision:? ", "input revision number", "00") " is used to write the string "filename", not "filename" --> filename = filename & " rev."
 
Hello.
In fact, the "s" is in the name of a declared variable but is not used, so there is no error (as much as it is an inaccuracy, but rather than adding the "s" in all uses I would prefer to remove it from the declared variable not to compromise the operation of the rule).
the variable used in fact is "rev", not "srev" and in i-logic if you value a variable works even without declaring it.
I think the problem could be in the name that is then assigned to the pdf output:
if you are using "filename" or "isolanome" then only the name of the original file without extension will come out, but the revision that you write in input here: " rev = inputbox("revision:? ", "input revision number", "00") " is used to write the string "filename", not "filename" --> filename = filename & " rev."
grateful to both but both removing the "s" and changing filename, the result does not change, it is not where the error could be.
Thanks anyway. (y)
 
...
the variable used in fact is "rev", not "srev" and in i-logic if you value a variable works even without declaring it.
...
I said I was rusty. ;)
But just to remove some oxide... in the line
filename = filename & " rev. " & crack & ""
Why is filename "recurring"? I usually used this way of enhancing the variables in case of repetition of the macro, but in this case a value of "rev" would always be added to the one already present in the previous cycle (not finding, in the previous rows, another valorization, or "zeration", of the variable filename). .
writing so
filename = thisdoc.filename(false) & " rev. " & rev & ""
Would you solve something?
 
do you want to save pdf by adding the revision?
Code:
dim mypath as string
dim myfilename as string
dim myrev as string
dim newfilename as string


mypath = "c:\dovevogliosalvare\"
myfilename = thisdoc.filename(false) 'filename without path and without estensioen
myrev = inputbox("rev.:", "revision","00") 'request for insertion revision

newfilename = mypath & myfilename & myrev & ".pdf" 'creating the name

'messagebox.show(newfilename, "filename")

thisdoc.document.saveas(newfilename , true) 'rescuing the document
 
I would do so
Code:
sub exportpdf()

' defines the active document
dim odoc as document
set odoc = thisapplication.activedocument

dim trail as string ' route
dim snomefile as string ' file name without extension
dim sfilecomplete as string ' full file name of path and extension

' defines the path in which the current file is located
left(odoc.file. fullfilename, instrrev(odoc.file.fullfilename, "\"))
snomefile = left(odoc.displayname, instrrev(odoc.displayname, ".") - 1)

' defines the full file name
sfilecomplete = search & snomefile & ".pdf"

odoc.saveas sfilecomplete, true 'Save the file

end
 
hello to all I use this rule brought from 2013 to 2021 and it works
takes the values from the model (e.g. code , revision , description) and saves pdf in other folder
Code:
modelname = io.path.getfilename(thisdrawing.modeldocument.fullfilename)


iproperties.value("project", "part number") = iproperties.value(modelname,"project", "part number")
iproperties.value("project", "description") = iproperties.value(modelname,"project", "description")
iproperties.value("project", "revision number") = iproperties.value(modelname,"project", "revision number")
iproperties.value("status", "status") = iproperties.value(modelname,"status", "status")


if not iproperties.value(modelname,"project", "revision number")="" then
strfolder = "m:\documenti condivisi\xxx\" & thisdoc.filename(false) 'without extension
thisdoc.document.saveas(strfolder & ("-") & ("- rev. ") & iproperties.value(modelname,"project", "revision number") & (".pdf") , true)

end if

if  iproperties.value(modelname,"project", "revision number")="" then
'thisdoc.document.saveas(thisdoc.changeextension(".pdf"), true)
strfolder = "m:\documenti condivisi\xxxx\" & thisdoc.filename(false) 'without extension
thisdoc.document.saveas(strfolder & ("-") &  (".pdf") , true)

end if
Code:
 
do you want to save pdf by adding the revision?
Code:
dim mypath as string
dim myfilename as string
dim myrev as string
dim newfilename as string


mypath = "c:\dovevogliosalvare\"
myfilename = thisdoc.filename(false) 'filename without path and without estensioen
myrev = inputbox("rev.:", "revision","00") 'request for insertion revision

newfilename = mypath & myfilename & myrev & ".pdf" 'creating the name

'messagebox.show(newfilename, "filename")

thisdoc.document.saveas(newfilename , true) 'rescuing the document
Hello, thank you very much works perfectly.
a question is complicated, instead of manually inserting the revision number, making it read directly from the iproperties of the drawing?
other thing but this only by curiosity, can you save the files in the source directory of the idw file?

Thank you very much
Hi.
 
hi the rule I posted above takes the value of the revision from the model, copy it in the iproperties of the design and insert it into the file name.
 
hi the rule I posted above takes the value of the revision from the model, copy it in the iproperties of the design and insert it into the file name.
Hi.
I tried yours too, but it made me a mistake, because I had made a caxxata myself, and I did not deepen, now I solved. It works great is what I was looking for, thank you.
p.s. same question about the rescue directory but it's just something not indispensable (like cherry on the cake) . Would it be possible to save pdfs in the same folder of origin of the idw file?
Thank you very much
Hi.
 
hi the rule I posted above takes the value of the revision from the model, copy it in the iproperties of the design and insert it into the file name.

ho fatto cosi e sembra funzionare :

modelname = io.path.getfilename(thisdrawing.modeldocument.fullfilename)


iproperties.value("project", "part number") = iproperties.value(modelname,"project", "part number")
iproperties.value("project", "description") = iproperties.value(modelname,"project", "description")
iproperties.value("project", "revision number") = iproperties.value(modelname,"project", "revision number")
iproperties.value("status", "status") = iproperties.value(modelname,"status", "status")


if not iproperties.value(modelname,"project", "revision number")="" then

thisdoc.document.saveas(thisdoc.changeextension("_") & iproperties.value(modelname,"project", "revision number") & (".pdf") , true)
thisdoc.document.saveas(thisdoc.changeextension("_") & iproperties.value(modelname, "project", "revision number") & (".dxf"), true)
thisdoc.document.saveas(thisdoc.changeextension("_") & iproperties.value(modelname,"project", "revision number") & (".dwg") , true)
end if

if iproperties.value(modelname,"project", "revision number")="" then

thisdoc.document.saveas(thisdoc.changeextension (".pdf") , true)
thisdoc.document.saveas(thisdoc.changeextension (".dxf"), true)
thisdoc.document.saveas(thisdoc.changeextension (".dwg") , true)
end if
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top