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

macro vba for automatic printing

  • Thread starter Thread starter 3°minore
  • Start date Start date

3°minore

Guest
Good morning, everyone.

work with inventor 2011;
are in possession of a macro vba, taken from a discussion in this forum and modified slightly, for the automatic printing of the boards of subgroups .iam and their individual parts .ipt, which make up a .iam file.
I now need to print only tables associated with .iam subgroups appearing in separate components, excluding those associated with .ipt files and .iam files referenced.
Can someone suggest me if it is possible, and how, change the macro?

cup and neck:
Code:
function fileexists(fname) as boolean
    if dir(fname) <> "" then fileexists = true else fileexists = false
end function

public sub stampa_tutte_le_tavole_in_a4()

    dim oasmdoc as assemblydocument
    set oasmdoc = thisapplication.activedocument
    if thisapplication.activedocument.documenttype <> kassemblydocumentobject then
        msgbox "this is not an assembly document!", vbexclamation
        exit sub
    end if

    dim oprintmgr as printmanager
    set oprintmgr = thisapplication.activedocument.printmanager
    if msgbox("usare la stampante di default """ & oprintmgr.printer & """  vuoi continuare?", vbyesno + vbquestion) = vbno then
        exit sub
    end if

    dim odrgprintmgr as drawingprintmanager

    msgbox "stampante selezionata " & oprintmgr.printer & ", stampare 1 copia, formato a4."

    dirpath = left(oasmdoc.fullfilename, len(oasmdoc.fullfilename) - len(oasmdoc.displayname))

    dim orefdocs as documentsenumerator
    set orefdocs = oasmdoc.allreferenceddocuments
    dim orefdoc as document
    numfiles = 0

    for each orefdoc in orefdocs
        idwpathname = left(orefdoc.fulldocumentname, len(orefdoc.fulldocumentname) - 3) & "idw"
        if fileexists(idwpathname) then
            numfiles = numfiles + 1
            'if numfiles = 10 then exit sub
            dim odrawdoc as drawingdocument
            set odrawdoc = thisapplication.documents.open(idwpathname, true)
            odrawdoc.activate
            set odrawdoc = thisapplication.activedocument
            set odrgprintmgr = odrawdoc.printmanager

            odrgprintmgr.allcolorsasblack = true
            odrgprintmgr.scalemode = kprintbestfitscale
            set oprintmgr = thisapplication.activedocument.printmanager

            ' printer setup, default printer
            oprintmgr.colormode = kprintdefaultcolormode ' set to default
            oprintmgr.numberofcopies = 1 ' set to print one copies.
            oprintmgr.papersize = kpapersizea4 'set the paper size.
            oprintmgr.submitprint ' submit the print.
            odrawdoc.close (true)
        end if
    next
    msgbox numfiles & " file sono stati inviati alla stampante."
 
some questions:
1) is connected to each table only one set/part?
2) the axieme/part is set as a: reference in the axieme where it is inserted or b: in a "absolute" way, by separate > document settings components? or as a mix of the two solutions?

in case 1) = true and 2) = b: then

dim odoc as document
' connects to the first table document (do not check if the table is empty)
set odoc = odrawdoc.allreferenceddocuments.item(1)

if odoc.componentdefinition.bomstructure < kreferencebomstructure then
oprintmgr.submitprint ' submit the print.
end if


all this replaces the line
oprintmgr.submitprint ' submit the print.

and should be go (pump down the rows to the flight without testing them, all to improve but to see if it works is ok)

if the above conditions do not occur is another story, one of those that do not tell after the 16.30 of Friday.. .

Bye!
 
some questions:
1) is connected to each table only one set/part?
2) the axieme/part is set as a: reference in the axieme where it is inserted or b: in a "absolute" way, by separate > document settings components? or as a mix of the two solutions?
1) a single link
2) I right-click the part in the general axieme; distinct structure distinct components, reference.

I'm not doing time tonight, but tomorrow morning I'm gonna try your code.
Thank you so much!
 
1) a single link
2) I right-click the part in the general axieme; distinct structure distinct components, reference.

I'm not doing time tonight, but tomorrow morning I'm gonna try your code.
Thank you so much!
in case 2) unfortunately I am sure to 99% that does not work... The macro you ask is more complex.
 

Forum statistics

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

Members online

No members online now.
Back
Top