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

solidworks double rescue

hi to all, I share my macro to save the table in pdf and dxf adding the revision of the part/axis automatically
hello, to me does not add the rev unfortunately... help me to understand where this value loads the macro?perhcè perhaps in the declaration of the variable there is some incongruence! What am I supposed to check?
 
hello, to me does not add the rev unfortunately... help me to understand where this value loads the macro?perhcè perhaps in the declaration of the variable there is some incongruence! What am I supposed to check?
Hi, dani,

I review it as default property inside the part. In my case it is called "rev" and I put it with value "0.0".
My macro looks at the value of the property "rev" if it exists and if it is different from 0.0 then adds it in the name of the generated file.

in case you want to add the property in all files, here they added a very nice macro, that you have to customize.
 
Hi, dani,

I review it as default property inside the part. In my case it is called "rev" and I put it with value "0.0".
My macro looks at the value of the property "rev" if it exists and if it is different from 0.0 then adds it in the name of the generated file.

in case you want to add the property in all files, here they added a very nice macro, that you have to customize.
I would also like to take the present value in the box of the component properties, which to me is called revision, and insert it into the exported file name. ..can it be that the set length of the name is insufficient to contain all characters? I mean the string:
filename = strings.left(filename, len(filename) - 7)
 
Hi, dani,

I review it as default property inside the part. In my case it is called "rev" and I put it with value "0.0".
My macro looks at the value of the property "rev" if it exists and if it is different from 0.0 then adds it in the name of the generated file.

in case you want to add the property in all files, here they added a very nice macro, that you have to customize.
Maybe I figured out why it doesn't work... we have custom properties in a folder on nas while the macro probably goes to take the value from the folder of solidworks locally. how could I map the correct file?
 
Maybe I figured out why it doesn't work... we have custom properties in a folder on nas while the macro probably goes to take the value from the folder of solidworks locally. how could I map the correct file?
try to share a file part. because the properties relative to each part are or in it written.
 
I would also like to take the present value in the box of the component properties, which to me is called revision, and insert it into the exported file name. ..can it be that the set length of the name is insufficient to contain all characters? I mean the string:
filename = strings.left(filename, len(filename) - 7)

le parti in grassetto sono quelle che devi modificare, come si chiama la proprietà di revisione nei tuoi file e come è il valore zero che vuoi che non venga riportato nel nome. quella non è la lunghezza dei caratteri ma semplicemente cancella gli ultimi del filename, ovvero l'estensione.
___________________________

option explicit
dim swapp as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
dim swdraw as sldworks.drawingdoc
dim swview as sldworks.view
dim swmodelref as sldworks.modeldoc2
dim getthatinfo as string

dim swmodeldocext as sldworks.modeldocextension
dim swexportdata as sldworks.exportpdfdata

dim boolstatus as boolean
dim boolstatuspdf as boolean
dim boolstatusdxf as boolean

dim draw as string
dim pdf as string
dim dxf as string

dim filename as string
dim lerrors as long
dim lwarnings as long
dim revisione as string
dim desc as string
sub main()

set swapp = application.sldworks
set swmodel = swapp.activedoc 'controlla che documento è aperto
if swmodel is nothing then
msgbox "no current document", vbcritical 'se è aperto un documento
end
end if
if swmodel.gettype <> swdocdrawing then 'se è di tipo messa in tavola
msgbox "this macro only works on drawings", vbcritical
end
end if

set swmodeldocext = swmodel.extension
set swexportdata = swapp.getexportfiledata(swexportpdfdata)

'aazeramento delle variabili di check
boolstatus = false
boolstatuspdf = false
boolstatusdxf = false
dxf = ""
pdf = ""

'recupera percorso e nome file con estensione
filename = swmodel.getpathname

'controlla se è stato salvato
if filename = "" then
msgbox "please save the file first and try again", vbcritical
end
end if

'save drawing / salva la messa in tavola
boolstatus = swexportdata.setsheets(swexportdata_exportallsheets, 1)
boolstatus = swmodeldocext.saveas(filename, 0, 0, swexportdata, lerrors, lwarnings)
if boolstatus then
draw = "ok"
else
draw = "failed"
end if

'prende la proprietà
set swdraw = swmodel
set swview = swdraw.getfirstview
set swview = swview.getnextview
set swmodelref = swview.referenceddocument

revisione = swmodelref.getcustominfovalue("", "rev"

'check if the rev variable is empty or is 0.0
filename = strings.left(filename, len(filename) - 7)
if reviewed0.0" and revisione <> "-" and revisione <> "" then
filename = filename & "_rev" & revisione 'append revision if not rev 0.0
end if

'save as pdf
filename = strings.left(filename, len(filename)) & ".pdf"

boolstatuspdf = swexportdata.setsheets(swexportdata_exportallsheets, 1)
boolstatuspdf = swmodeldocext.saveas(filename, 0, 0, swexportdata, lerrors, lwarnings)
if boolstatuspdf then
pdf = "ok"
else
pdf = "failed"
end if

'save as dxf
filename = strings.left(filename, len(filename) - 3) & "dxf"
boolstatusdxf = swexportdata.setsheets(swexportdata_exportallsheets, 1)
boolstatusdxf = swmodeldocext.saveas(filename, 0, 0, swexportdata, lerrors, lwarnings)
if boolstatusdxf then
dxf = "ok"
else
dxf = "failed"
end if

'message saved status
if boolstatus <> boolstatuspdf <> boolstatusdxf then
msgbox "save all successful" _
& vblf & "" _
& vblf & filename
else
msgbox "save as drawing failed" _
& vblf & "" _
& vblf & "sw draw:" & draw _
& vblf & "pdf: " & pdf _
& vblf & "dxf: " & dxf _
& vblf & "" _
& vblf & "error code:" & lerrors _
& vblf & "" _
& vblf & filename
end if

end sub
 
le parti in grassetto sono quelle che devi modificare, come si chiama la proprietà di revisione nei tuoi file e come è il valore zero che vuoi che non venga riportato nel nome. quella non è la lunghezza dei caratteri ma semplicemente cancella gli ultimi del filename, ovvero l'estensione.
___________________________

option explicit
dim swapp as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
dim swdraw as sldworks.drawingdoc
dim swview as sldworks.view
dim swmodelref as sldworks.modeldoc2
dim getthatinfo as string

dim swmodeldocext as sldworks.modeldocextension
dim swexportdata as sldworks.exportpdfdata

dim boolstatus as boolean
dim boolstatuspdf as boolean
dim boolstatusdxf as boolean

dim draw as string
dim pdf as string
dim dxf as string

dim filename as string
dim lerrors as long
dim lwarnings as long
dim revisione as string
dim desc as string
sub main()

set swapp = application.sldworks
set swmodel = swapp.activedoc 'controlla che documento è aperto
if swmodel is nothing then
msgbox "no current document", vbcritical 'se è aperto un documento
end
end if
if swmodel.gettype <> swdocdrawing then 'se è di tipo messa in tavola
msgbox "this macro only works on drawings", vbcritical
end
end if

set swmodeldocext = swmodel.extension
set swexportdata = swapp.getexportfiledata(swexportpdfdata)

'aazeramento delle variabili di check
boolstatus = false
boolstatuspdf = false
boolstatusdxf = false
dxf = ""
pdf = ""

'recupera percorso e nome file con estensione
filename = swmodel.getpathname

'controlla se è stato salvato
if filename = "" then
msgbox "please save the file first and try again", vbcritical
end
end if

'save drawing / salva la messa in tavola
boolstatus = swexportdata.setsheets(swexportdata_exportallsheets, 1)
boolstatus = swmodeldocext.saveas(filename, 0, 0, swexportdata, lerrors, lwarnings)
if boolstatus then
draw = "ok"
else
draw = "failed"
end if

'prende la proprietà
set swdraw = swmodel
set swview = swdraw.getfirstview
set swview = swview.getnextview
set swmodelref = swview.referenceddocument

revisione = swmodelref.getcustominfovalue("", "rev"

'check if the rev variable is empty or is 0.0
filename = strings.left(filename, len(filename) - 7)
if reviewed0.0" and revisione <> "-" and revisione <> "" then
filename = filename & "_rev" & revisione 'append revision if not rev 0.0
end if

'save as pdf
filename = strings.left(filename, len(filename)) & ".pdf"

boolstatuspdf = swexportdata.setsheets(swexportdata_exportallsheets, 1)
boolstatuspdf = swmodeldocext.saveas(filename, 0, 0, swexportdata, lerrors, lwarnings)
if boolstatuspdf then
pdf = "ok"
else
pdf = "failed"
end if

'save as dxf
filename = strings.left(filename, len(filename) - 3) & "dxf"
boolstatusdxf = swexportdata.setsheets(swexportdata_exportallsheets, 1)
boolstatusdxf = swmodeldocext.saveas(filename, 0, 0, swexportdata, lerrors, lwarnings)
if boolstatusdxf then
dxf = "ok"
else
dxf = "failed"
end if

'message saved status
if boolstatus <> boolstatuspdf <> boolstatusdxf then
msgbox "save all successful" _
& vblf & "" _
& vblf & filename
else
msgbox "save as drawing failed" _
& vblf & "" _
& vblf & "sw draw:" & draw _
& vblf & "pdf: " & pdf _
& vblf & "dxf: " & dxf _
& vblf & "" _
& vblf & "error code:" & lerrors _
& vblf & "" _
& vblf & filename
end if

end sub
Thanks I will try right away, while I wanted to ask you if you can tell me from what file and in which folder the macro goes to read the rev value. I imagine it is the property of the document. Having set a file path different from default, having shared it on servers, this macro follows this edit or searches it in the installation files in the local directory?
 
Hi.
Thank you, I discovered this macro and could solve some problems and avoid unnecessary work.
After doing some tests, I ask if somehow it is possible to save all files (or only those selected from a list) present within a set, without having to import them one at a time in the appropriate window.
Thank you very much
greetings
Good morning, everyone.
I attach Rel. 4.0 to savebackground, after so much expectation.
This version allows you to save files in different paths than the source file according to the modes you see in the attached image.
I have not yet entered the export in "stl" format as required sa xxfast, che salute.

Now we can define a rescue path on which our converted files will go, or automatically create sub folders based on the extension inside the file's residence manager.
remains always in foot the saving of the file in the path of origin as before, without under folders.

installation:
- as for previous versions extract the installation file from the .zip file and launch the program that will install automatically.
- in the case of previous installations in the pc will be overwritten automatically.

inside the zip file you will also find the updated guide.

I hope I was able to settle someone.

View attachment 52082
 
no it is not possible, you have to choose them from explore resources by uploading them into the list.
 
no it is not possible, you have to choose them from explore resources by uploading them into the list.
Okay.
Thanks for the answer.
if there's some update planned I think it would be interesting to integrate this function
 
Good morning, everyone.
I attach Rel. 4.0 to savebackground, after so much expectation.
This version allows you to save files in different paths than the source file according to the modes you see in the attached image.
I have not yet entered the export in "stl" format as required sa xxfast, che salute.

Now we can define a rescue path on which our converted files will go, or automatically create sub folders based on the extension inside the file's residence manager.
remains always in foot the saving of the file in the path of origin as before, without under folders.

installation:
- as for previous versions extract the installation file from the .zip file and launch the program that will install automatically.
- in the case of previous installations in the pc will be overwritten automatically.

inside the zip file you will also find the updated guide.

I hope I was able to settle someone.

View attachment 52082
thank you very much jenuary....useful this macro, with a considerable saving of time.
 
I throw it there... a macro like this modified suit could export a drawing file consisting of many separate pdf sheets having each of them as file name the sheet name?
I don't know if I explained.
thanks in advance
so many hairs
 
I throw it there... a macro like this modified suit could export a drawing file consisting of many separate pdf sheets having each of them as file name the sheet name?
I don't know if I explained.
thanks in advance
so many hairs
a macro should be created to connect to the saving event of the table. to save the macro export all pdf single according to your requests.
 
a macro should be created to connect to the saving event of the table. to save the macro export all pdf single according to your requests.
ah here is interesting, before retiring then I will take a specific course, always if there is still such technology.
Thank you.
so many hairs
 
hello to all this rescue system could be done directly by the open axieme? in the apex sense and doing the rescue, saves me all pdf with the dvx of the parts that are part of the set?
 
No, it doesn't work with this logic. was born to always have updated files to each save indifferently from the type of open file, you also have the possibility to batch export a list of files. if you tie a macro to the rescue event of the assemblies can do what you ask, but the macro should be created from scratch. has infinite possibilities of use using the link to macros
 
Hello, Lorenzo.
you tried to use the solid package: "planning"; It is not automatic but it is enough that you select the files you need and you can convert/copy them in the format you want, it is a very fast process that we use in the office where I am.
I give you an example of application: Once we have completed all drawings (type 50 drawings), we open the planner, we select the folder with all drawings, we select the desired format (usually pdf) and the software performs everything automatically while working on other.
 

Forum statistics

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

Members online

No members online now.

Back
Top