jenuary
Guest
really a big macro... I don't stop being happy every time I use it!
Recently I wanted there to be a chance to export to dxf according to a particular dxf mapping file that I saved between my folders. I tried to change the macro file, but I don't have the necessary skills. I read that to implement export to dxf according to specific mapping you can add the following:
ounces a mapping file has been used, solidworks will continue to use it for each successive save to dxf.
you can enable that option in the api by swapp.setuserpreferencetoggle(swuserpreferencetoggle_e.swdxfmapping, true)
and you can define the path to the mapping file by swapp.setuserpreferencestringlistvalue(swuserpreferencestringlistvalue_e.swdxfmappingfiles, "<path file="" mapping="" to="" your="">"
I understand what you want to do, but I don't know how to insert the two command lines and at which point. I also believe that new variables should be declared with typology. .
Jenuary, can you give me a hand, please?</path>
con la speranza di fare cosa gradita, qui sotto riporto la "sub main" modificata da sovrascrivere nella macro,
in verde trovi i commenti e le spiegazioni per le righe aggiunte, se non è chiaro fammi sapere:
sub main()
dim swapp as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
dim swassy as sldworks.assemblydoc
dim swconf as sldworks.configuration
dim swrootcomp as sldworks.component2
dim nstart as single
dim bret as boolean
set swapp = application.sldworks
set swmodel = swapp.activedoc
set swconf = swmodel.getactiveconfiguration
set swrootcomp = swconf.getrootcomponent3(true)
debug.print "file = " & swmodel.getpathname
''' '''' '' '' ''' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ' '' ' ' ' ' '' '' '' ' '' '' ' '' ' ' ' ' ' '
''' '''' '' '' ''' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ' '' ' ' ' ' '' '' '' ' '' '' ' '' ' ' ' ' ' '
Setting area for export dxf-dwg
'
'in this part of code imposed the settings because solidworks do not show me
'to every rescue dwg\dxf the mapping set mask
dim bshowmap as boolean
'imposed using the mapping file
bshowmap = swapp.getuserpreferencetoggle(swuserpreferencetoggle_e.swdxfdontshowmap)
if bshowmap = false then bshowmap = true else bshowmap = true
swapp.setuserpreferencetoggle swuserpreferencetoggle_e.swdxfdontshowmap, false 'This part is optional, before changing the mapping file if already set,
'Save in a variable the string of the mapping file so that it can reset after the end of the macro
dim old_mapping_file as string
old_mapping_file = swapp.getuserpreferencestringlistvalue(swdxfmappingfiles) ' mi ritorna ad esempio "c:\...\mio_file.dat" '
'now step to the pointing string of the mapping file
'from before the white, i.e. the gate
swapp.setuserpreferencestringlistvalue swuserpreferencestringlistvalue_e.swdxfmappingfiles, "" whitening mapping strings 'now imposed the mapping file to which solidworks must refer for subsequent rescuesswapp.setuserpreferencestringlistvalue swuserpreferencestringvalue_e.swdxfmappingfiles, "c:\...\mia_mappatura.dat" 'imposed the mapping file 'Having with the compiled string the curtain that we find under the options during saving dxf\dwg I have to pass the dropdown line indexswapp.setuserpreferenceintegervalue swuserpreferenceintegervalue_e.swdxfmappingfileindex, 0 'I'm the first on the list then 0 'This command is optional, I go to set the rescue version
swapp.setuserpreferenceintegervalue swuserpreferenceintegervalue_e.swdxfversion, 3 ' imposed the export release "es.r2000-2002" '
'fine setting area for export dxf-dwg
traversecomponent swrootcomp, 1
Having finished the cycle, inserting these two rows is restored the initial mapping file
swapp.setuserpreferencestringlistvalue swuserpreferencestringlistvalue_e.swdxfmappingfiles, ""
swapp.setuserpreferencestringlistvalue swuserpreferencestringlistvalue_e.swdxfmappingfiles, old_mapping_file 'imposed the mapping file
''' '''' '' '' ''' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ' '' ' ' ' ' '' '' '' ' '' '' ' '' ' ' ' ' ' '
''' '''' '' '' ''' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ' '' ' ' ' ' '' '' '' ' '' '' ' '' ' ' ' ' ' 'msgbox ("export completed!")
end
