silvia_cherry
Guest
ciao a tutti!
ho questa regola ilogic che mi esporta il dxf delle varie lamiere all'interno di un assieme in inventor
'define the active document as an assembly file
dim oasmdoc as assemblydocument
oasmdoc = thisapplication.activedocument
oasmname = left(oasmdoc.displayname, len(oasmdoc.displayname) -4)
'check that the active document is an assembly file
if thisapplication.activedocument.documenttype <> kassemblydocumentobject then
messagebox.show("please run this rule from the assembly file.", "ilogic")
exit sub
end if
'get user input
rusure = messagebox.show ( _
"this will create a dxf file for all of the asembly components that are sheet metal." _
& vblf & "this rule expects that the part file is saved." _
& vblf & " " _
& vblf & "are you sure you want to create dxf for all of the assembly components?" _
& vblf & "this could take a while.", "ilogic - batch output dxfs ",messageboxbuttons.yesno)
if rusure = vbno then
return
else
end if
opath = thisdoc.path
odatamedium = thisapplication.transientobjects.createdatamedium
ocontext = thisapplication.transientobjects.createtranslationcontext
ocontext.type = iomechanismenum.kfilebrowseiomechanism
ooptions = thisapplication.transientobjects.createnamevaluemap
'get dxf target folder path
ofolder = opath & "\" & oasmname & " dxf files"
'check for the dxf folder and create it if it does not exist
if not system.io.directory.exists(ofolder) then
system.io.directory.createdirectory(ofolder)
end if
'- - - - - - - - - - - - -
'- - - - - - - - - - - - -component - - - - - - - - - - - -
'look at the files referenced by the assembly
dim orefdocs as documentsenumerator
orefdocs = oasmdoc.allreferenceddocuments
dim orefdoc as document
'work the the drawing files for the referenced models
'this expects that the model has been saved
for each orefdoc in orefdocs
iptpathname = left(orefdoc.fulldocumentname, len(orefdoc.fulldocumentname) - 3) & "ipt"
'check that model is saved
if(system.io.file.exists(iptpathname)) then
dim odrawdoc as partdocument
odrawdoc = thisapplication.documents.open(iptpathname, true)
ofilename = left(orefdoc.displayname, len(orefdoc.displayname))
try
'set the dxf target file name
odatamedium.filename = ofolder & "\" & ofilename & ".dxf"
dim ocompdef as sheetmetalcomponentdefinition
ocompdef = odrawdoc.componentdefinition
if ocompdef.hasflatpattern = false then
ocompdef.unfold
else
ocompdef.flatpattern.edit
end if
dim sout as string
sout = "flat pattern dxf?acadversion=2004" _
+
"&outerprofilelayer=iv_outer_profile" _
+
"&interioprofileslayer=iv_interior_profiles" _
+
"&invisiblelayers=iv_tangent;iv_bend;iv_bend_down;iv_bend_up;iv_arc_centers;iv_tool_center;iv_tool_center_down;iv_feature_profiles;iv_feature_profiles_down;iv_altrep_front;iv_altrep_back;iv_unconsumed_sketches;iv_roll_tangent;iv_roll"
ocompdef.dataio.writedatatofile( sout, odatamedium.filename)
'just for check its works coretcly
'i=messagebox.show(odatamedium.filename, "title",messageboxbuttons.okcancel)
'messagebox.show(i,"title",messageboxbuttons.ok)
'if i=2 then
'exit sub
'end if
ocompdef.flatpattern.exitedit
catch
end try
odrawdoc.close
else
end if
next
la regola funziona benissimo, mi esporta tutte le lamiere però io non vorrei che me le esportasse tutte (alcune di queste il cliente le ha già a magazzino quindi non deve ordinarle che è il motivo per cui faccio i dxf che verranno poi inviati al fornitore) per distinguere le lamiere da ordinare da quelle no abbiamo inserito la proprietà 'pannello' nel campo 'fornitore' nel menù iproperties. ho visto che si richiama in questo modo
param=iproperties.value("project", "vendor")
la cosa che non riesco a fare è aggiungere alla regola il fatto che se il campo fornitore è vuoto non mi crei il dxf, se presenta la scritta 'pannello' crei il dxf.
grazie mille
ho questa regola ilogic che mi esporta il dxf delle varie lamiere all'interno di un assieme in inventor
'define the active document as an assembly file
dim oasmdoc as assemblydocument
oasmdoc = thisapplication.activedocument
oasmname = left(oasmdoc.displayname, len(oasmdoc.displayname) -4)
'check that the active document is an assembly file
if thisapplication.activedocument.documenttype <> kassemblydocumentobject then
messagebox.show("please run this rule from the assembly file.", "ilogic")
exit sub
end if
'get user input
rusure = messagebox.show ( _
"this will create a dxf file for all of the asembly components that are sheet metal." _
& vblf & "this rule expects that the part file is saved." _
& vblf & " " _
& vblf & "are you sure you want to create dxf for all of the assembly components?" _
& vblf & "this could take a while.", "ilogic - batch output dxfs ",messageboxbuttons.yesno)
if rusure = vbno then
return
else
end if
opath = thisdoc.path
odatamedium = thisapplication.transientobjects.createdatamedium
ocontext = thisapplication.transientobjects.createtranslationcontext
ocontext.type = iomechanismenum.kfilebrowseiomechanism
ooptions = thisapplication.transientobjects.createnamevaluemap
'get dxf target folder path
ofolder = opath & "\" & oasmname & " dxf files"
'check for the dxf folder and create it if it does not exist
if not system.io.directory.exists(ofolder) then
system.io.directory.createdirectory(ofolder)
end if
'- - - - - - - - - - - - -
'- - - - - - - - - - - - -component - - - - - - - - - - - -
'look at the files referenced by the assembly
dim orefdocs as documentsenumerator
orefdocs = oasmdoc.allreferenceddocuments
dim orefdoc as document
'work the the drawing files for the referenced models
'this expects that the model has been saved
for each orefdoc in orefdocs
iptpathname = left(orefdoc.fulldocumentname, len(orefdoc.fulldocumentname) - 3) & "ipt"
'check that model is saved
if(system.io.file.exists(iptpathname)) then
dim odrawdoc as partdocument
odrawdoc = thisapplication.documents.open(iptpathname, true)
ofilename = left(orefdoc.displayname, len(orefdoc.displayname))
try
'set the dxf target file name
odatamedium.filename = ofolder & "\" & ofilename & ".dxf"
dim ocompdef as sheetmetalcomponentdefinition
ocompdef = odrawdoc.componentdefinition
if ocompdef.hasflatpattern = false then
ocompdef.unfold
else
ocompdef.flatpattern.edit
end if
dim sout as string
sout = "flat pattern dxf?acadversion=2004" _
+
"&outerprofilelayer=iv_outer_profile" _
+
"&interioprofileslayer=iv_interior_profiles" _
+
"&invisiblelayers=iv_tangent;iv_bend;iv_bend_down;iv_bend_up;iv_arc_centers;iv_tool_center;iv_tool_center_down;iv_feature_profiles;iv_feature_profiles_down;iv_altrep_front;iv_altrep_back;iv_unconsumed_sketches;iv_roll_tangent;iv_roll"
ocompdef.dataio.writedatatofile( sout, odatamedium.filename)
'just for check its works coretcly
'i=messagebox.show(odatamedium.filename, "title",messageboxbuttons.okcancel)
'messagebox.show(i,"title",messageboxbuttons.ok)
'if i=2 then
'exit sub
'end if
ocompdef.flatpattern.exitedit
catch
end try
odrawdoc.close
else
end if
next
la regola funziona benissimo, mi esporta tutte le lamiere però io non vorrei che me le esportasse tutte (alcune di queste il cliente le ha già a magazzino quindi non deve ordinarle che è il motivo per cui faccio i dxf che verranno poi inviati al fornitore) per distinguere le lamiere da ordinare da quelle no abbiamo inserito la proprietà 'pannello' nel campo 'fornitore' nel menù iproperties. ho visto che si richiama in questo modo
param=iproperties.value("project", "vendor")
la cosa che non riesco a fare è aggiungere alla regola il fatto che se il campo fornitore è vuoto non mi crei il dxf, se presenta la scritta 'pannello' crei il dxf.
grazie mille