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

replacement cart

  • Thread starter Thread starter pietro2014
  • Start date Start date
hello if you have many files already made, I use this rule, and if I remove hand to a file made with old templates, I click and change. You have to have a template with the paper you want to put, and then replace the paths.
Code:
public sub main ()

    'check title in active document
    try
        dim odrawdoc as drawingdocument
            odrawdoc = thisapplication.activedocument
       
       
        ' check if drawing deferupdate state is true
        if not odrawdoc.drawingsettings.deferupdates = "false" then
           'showerror("can`t change title because drawing file is deferupdate")
            exit sub  
        end if      
   
        'sostituisco i simboli nel disegno
        try
            deletesymbols
            'copysymbols
        catch
           
        end try
       
        dim title="cartiglio-2019"
        call replacetitle(title)
   
    catch
        msgbox("errore durante sostituzione cartiglio")
       
    end try

   
end sub

sub replacetitle(byref title as string )

    dim odrawdoc as drawingdocument
    odrawdoc = thisapplication.activedocument
    dim template = "c:\impostazioni_inventor\2018\templates\2019 standard.idw"  
       

    dim otemplate as drawingdocument
    dim osourcetitleblockdef as titleblockdefinition
    dim onewtitleblockdef as titleblockdefinition
    dim osheet = odrawdoc.activesheet

    try  
        'apro il template      
        otemplate = thisapplication.documents.open(template, false)
        'aggancio la definizione del nuovo cartiglio
         osourcetitleblockdef = otemplate.titleblockdefinitions.item(title)
        'copio la definizinoe del cartiglio nel nuovo disegno
         onewtitleblockdef = osourcetitleblockdef.copyto(odrawdoc, true)
        'chiudo il template
         otemplate.close
   
        'msgbox("tentativo di inserimento cartiglio "  & title)
         
        'inserimento cartiglio sul disegno
       
'        dim i as integer
'        dim intprompts as integer = 0
'        for i = 1 to onewtitleblockdef.sketch.textboxes.count
'            dim otext = onewtitleblockdef.sketch.textboxes(i)          
'            if (otext.text = "my_prompt")          
'                intprompts = intprompts + 1
'            end if
'        next
       
        'msgbox ("trovati " & intprompts & " messaggi prompt")
       
        dim oprompts(2) as string
        oprompts(0) = ""
        oprompts(1) = ""
        oprompts(2) = ""
        osheet.titleblock.delete()      
           osheet.addtitleblock(onewtitleblockdef,,oprompts)
       
        'msgbox("title block changed to " & vbcr & title)


    catch ex as exception
        msgbox("errore: " & ex.message)
    end try
   
   
end sub

sub deletesymbols

dim odoc as drawingdocument = thisdoc.document
dim osksymdefs as sketchedsymboldefinitions = odoc.sketchedsymboldefinitions
dim osksymdef as sketchedsymboldefinition

for each osksymdef in osksymdefs
    if osksymdef.isreferenced = false then
        osksymdef.delete
    end if
next
   
end sub

sub copysymbols
           
            dim strselectedstamp as string = "result2"
           
            dim strstamplist as new arraylist
           
            dim strstamprequired as boolean
            strstamprequired = true
            strstamplist.add("cartilgio-2019")
            'strstamplist.add("x ossitaglio")
            'strstamplist.add("test")
            strselectedstamp = inputlistbox("please select a stamp.", strstamplist, strselectedstamp, "stamp selection", "available stamps")
            dim strdrawdoc as inventor.drawingdocument = thisapplication.activedocument
            dim sourcefile as string = "m:\_impostazioni_inventor\2018\templates\2019 standard.idw"
                   
            dim strsourceidw as drawingdocument
            strsourceidw = thisapplication.documents.open(sourcefile, false)
            dim symboldef as sketchedsymboldefinition
           
            dim copyfrom as sketchedsymboldefinition
           

     try
            for each symboldef in strsourceidw.sketchedsymboldefinitions
               
                    copyfrom = (symboldef.copyto(strdrawdoc, true))
               
            next
catch ex as exception
messagebox.show(ex.message, "title")

end try
            strsourceidw.close()
    end sub
I just needed the code piece to copy the symbols, thank you! 😅

regarding the path of the standard.idw file, you can recover it through this command:
Code:
sfolder = thisapplication.fileoptions.templatespath
 
Good morning
Thanks adahm, I read everything and I tried to put only these two lines, but it doesn't work. .

I just wanted to replace/update the edge and the cartilage

Thank you.
 

Attachments

  • fser.webp
    fser.webp
    11.1 KB · Views: 7

Forum statistics

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

Members online

No members online now.
Back
Top