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

command updates cart

  • Thread starter Thread starter Riccardo81
  • Start date Start date

Riccardo81

Guest
I have a lot of old drawings to work and I would like to add a command (or a button) to inventor that through macro, ilogic or other I should upgrade the table chart according to the template. I could do it with the application of invetor, but it is too heavy and slow and the drawings that I have are still too old to be updated in mass (it is not worth it). I've seen that there are several scripts around the internet, but I don't know about programming, would anyone help me?
 
Do you have a trusted dealer? to us have created a button that does exactly this operation automatically.
 
Do you have a trusted dealer? to us have created a button that does exactly this operation automatically.
I'm not the one who pays and who is more comfortable with a flexible one that with a pc, I have to do everything myself and if I can lighten my work somehow I try to do it
 
I'm not the one who pays and who is more comfortable with a flexible one that with a pc, I have to do everything myself and if I can lighten my work somehow I try to do it
that sounds a little like: "We've always done this"
apart from the jokes I understand, I worked years for company that reasoned so, then slowly they realized that a small investment is positively reflected in the time of delivery of ut's work.
 
I tried. this code, but I don't know exactly how to insert it (view basic editor?) and it makes me mistake everywhere (I'm sure I'm wrong something)
that sounds a little like: "We've always done this"
apart from the jokes I understand, I worked years for company that reasoned so, then slowly they realized that a small investment is positively reflected in the time of delivery of ut's work.
for now I have to do it manually table for table, copy-paste from the template to the old table....an annoyance!
 
I could do it with the application of invetor, but it is too heavy and slow and the drawings that I have are still too old to be updated in mass (it is not worth it).
with "source transfer wizard" you can still do a lot of work.
Maybe you start in the evening and all night the pc works and you can make several steps without necessarily doing all the drawings in a single time.
then if the next day you find errors you will fix them only and when you need to use the drawing/s incriminated.
I'm sure you've got a big bang.
I'm not the one who pays and who is more comfortable with a flexible one that with a pc, I have to do everything myself and if I can lighten my work somehow I try to do it
if then the procedure takes time to the owner you have to say things directed in the face:
or invest in automated procedures or wait for you to finish the job as long as you need it.
 
Hi.
I her this rule and then you make the button with create form
in the rule go to replace
"new cartiglio name"

"path file folders with new cartiglio.idw"

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="nome cartiglio nuovo"
        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 = "percorso cartelle file con cartiglio nuovo.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("nome cartiglio nuovo")
            'strstamplist.add("altro")
            '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 = percorso cartele file con cartiglio nuovo.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
 
Hi.
I her this rule and then you make the button with create form
in the rule go to replace
"new cartiglio name"

"path file folders with new cartiglio.idw"

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="nome cartiglio nuovo"
        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 = "percorso cartelle file con cartiglio nuovo.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("nome cartiglio nuovo")
            'strstamplist.add("altro")
            '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 = percorso cartele file con cartiglio nuovo.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
but is it an ilogic code? How do I insert it?
 
so from the template if you have made new sketch symbols copy also that, but it is optional, because this was born with the 2013 version that did not have the symbol library, but if you use the symbol library nothing changes
 
News thanks for confirmation, I imagined that the reason could be related to the definition of symbols and the script had been written for an old version of inventor.

I also asked why I use/use the script below to replace the template, but I realize it doesn't fit all the needs.
Code:
if thisdoc.document.documenttype = inventor.documenttypeenum.kdrawingdocumentobject then
    thisdrawing.keepextraresources = false
    thisdrawing.resourcefilename = "percorso completo nuovo template"
end if
I also found interesting the version that he wrote jeltedejong in this debate on the autodesk site, I share it because it seems well written and clean, you think?
 
but is it an ilogic code? How do I insert it?
I try to explain the passages in the idw field.
1) in the top broswer you should have the item "model" and "+" by clicking on the + add "ilogic"
2) appear of the under tabs "rules" - " modules" - global modules" - "external rules"
the difference is that the first two are valid only in the file where you are working, the last two can always use them
3) considering the second option or always valid, go to "external rules" button dx
4) creates external rule -- choose the path and save it "registername.txt" so it is easier to share with colleagues if needed
5) copy and paste the code of the previous message. save and close
6) find in the list the newly created dx key rule, if it works and does what you need.
7) go to global modules in blank space button dx "Add Module"
8) opens the module creation screen enter form name
9) left under the rules entry you should find your rule drags to right in the close pane
10) Now to call back and execute the rule you just have to go to global modules where you find the
module just created and click on the button with rule name (which is customizable)
 
News thanks for confirmation, I imagined that the reason could be related to the definition of symbols and the script had been written for an old version of inventor.

I also asked why I use/use the script below to replace the template, but I realize it doesn't fit all the needs.
Code:
if thisdoc.document.documenttype = inventor.documenttypeenum.kdrawingdocumentobject then
    thisdrawing.keepextraresources = false
    thisdrawing.resourcefilename = "percorso completo nuovo template"
end if
I also found interesting the version that he wrote jeltedejong in this debate on the autodesk site, I share it because it seems well written and clean, you think?
I've seen it's definitely better than what I put, even because I'm not a programmer, but I took pieces from rules that I found on the net and adapted them, when he did what I needed, I saved and I didn't touch anything anymore.
 
I try to explain the passages in the idw field.
1) in the top broswer you should have the item "model" and "+" by clicking on the + add "ilogic"
2) appear of the under tabs "rules" - " modules" - global modules" - "external rules"
the difference is that the first two are valid only in the file where you are working, the last two can always use them
3) considering the second option or always valid, go to "external rules" button dx
4) creates external rule -- choose the path and save it "registername.txt" so it is easier to share with colleagues if needed
5) copy and paste the code of the previous message. save and close
6) find in the list the newly created dx key rule, if it works and does what you need.
7) go to global modules in blank space button dx "Add Module"
8) opens the module creation screen enter form name
9) left under the rules entry you should find your rule drags to right in the close pane
10) Now to call back and execute the rule you just have to go to global modules where you find the
module just created and click on the button with rule name (which is customizable)
Thank you! are totally fasting on the ilogic part
 

Forum statistics

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

Members online

No members online now.
ciao
Back
Top