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

dubbio su macro

  • Thread starter Thread starter gtsolid
  • Start date Start date

gtsolid

Guest
hi to allI have this fragment of macro that turns the parts into pdf, dwg and step.
As for the transformation in step I have problems only in case I have "." in the file name.
What do you think is the problem? I didn't find anything out of place at first.
Code:
     'pdf & dwg & step: generate step ---------- (load part within same name, save step, close part) ---------
      if myvalue = "4" or myvalue = "8" then
        filen1 = strings.left(filename, len(filename) - 4) & ".sldprt"        'full path + filename + .sldprt
        set swapp = application.sldworks
        set swmodel = swapp.activedoc
        set selmgr = swmodel.selectionmanager
        set swmodel2 = swapp.opendoc6(filen1, 1, 0, "", longstatus, longwarnings)
        swapp.opendoc6 filen1, 1, 0, "", longstatus, longwarnings
           swapp.activedoc.activeview.frameleft = 0
           swapp.activedoc.activeview.frametop = 18
           swapp.activedoc.activeview.framestate = 1
           filen2 = right(filename, len(filename) - len(workdir))
            filen2 = strings.left(filen2, len(filen2) - 4)
           set swmodel2 = swapp.activatedoc2(filen2, false, longstatus)
        filen3 = strings.left(filen1, len(filen1) - 7) & ".step"              ''full path + filename + .step
        boolstatus = swmodel2.extension.saveas(filen3, 0, 0, nothing, longstatus, longwarnings)
        set swmodel2 = nothing
        swapp.closedoc filen2
                if boolstatus then
                   if singlefile = true then msgbox filen3, vbinformation, "file salvato con successo   -step-"
                else
                   msgbox filen3 & vbnewline & lerrors, vbcritical, "salvataggio fallito, codice errore:    -step-"
                end if
      end if
 
I don't know if it's the double apex before ''full path + et cetera. . .
but there is no debug function?
it is not my software or my language...but it seems like a simple thing
 
I honestly don't understand why all that code lap you don't understand what you want to do before saving the file, I ask you an explanation about it, I don't understand why you swicci from one file to another and then always save filen1.
I think the problem lies in the righa
filen1 = strings.left(filename, len(filename) - 4) & ".sldprt"
and
filen2 = strings.left(filen2, len(filen2) - 4)

where you should remove 7 not 4 characters to the string otherwise the file remains the extension ".sl"

If you need a macro that saves the active part in step-by-click it is worth doing it again, you put it a moment, before you change this.
 
That wasn't the problem. I don't know how to move on. As for programming, I would need a tutorial, there are many functions. . .
 
and then what's the problem, I probably didn't understand what you want to do and what you want to recover from the code and why.
 
if the file does not have "." it works. If there are any, it gives me error in the line
"set swmodel2 = swapp.activatedoc2(filen2, false, longstatus)"
 
meanwhile you don't understand where "filename" comes from, I see that filen1 revenues by deleting the full string of the file (I imagine, but I don't understand which file) and revenues the only name without the extension, but I repeat the -4 leaves you in the tail a ".sl", if you want to remove all the extension you have to remove 7.

I repeat that if you explain well what the macro has to do you could rewrite it very quickly using maybe less articulated code.

If you can explain to me the strings that should contain the filename variables, filen1,filen2, workdir, I could have a clear idea of the process.

Hi.
 
hi to all I use these two macros to save in different formats...and I look good for now I found them on the internet and then changed: I or with the help of someone....who knows who will be...
Hi.
 

Attachments

Forum statistics

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

Members online

No members online now.
Back
Top