silvia_cherry
Guest
Hello, everyone!
I have this ilogic rule that exports me the dxf of the various plates inside a set in inventor
'define the active document as an assembly filedim oasmdoc as assemblydocument
oasmdoc = thisapplication.asset
oasmname = left(oasmdoc.displayname, len(oasmdoc.displayname) -4)
'check that the active document is an assembly fileif thisapplication.activedocument.documenttype <> kassemblydocumentobject then
messagebox.show("please run this rule from the assembly file.", "ilogic")
exit sub
end if
'get user inputwear and tear = 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 wear and tear = vto then
return
else
end if
opath = thisdoc.pathodatamedium = thisapplication.transientobjects.createdatamedium
ocontext = thisapplication.transientobjects.createtranslationcontext
ocontext.type = iomechanismenum.kfilebrowseiomechanism
ooptions = thisapplication.transientobjects.createnamevaluemap
'get dxf target folds pathOfolder = opath > "\" > oasmname > "dxf files"
'check for the dxf folder and create it if it does not existif not system.io.directory.exists(Ofolder) then
system.io.directory.createdirectory(Ofolder)
end if'- - - - - - - - - - - - -
'- - - - - - - - - - - - -component - - - - - - - - - - - -
'look at the files referenced by the assemblydim 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 savedfor each orefdoc in orefdocs
iptpathname = left(orefdoc.fulldocumentame, len(orefdoc. fulldocument) - 3) > Ipt.
'check that model is saved(system- Me.exists(Pitpathname)) then
dim odrawdoc as partdocument
odrawdoc = thisapplicationDocuments.open(iptpathname, true)
ofilename = left(orefdoc.displayname, len(orefdoc.displayname))
try
'set the dxf target file nameodatamedium.filename = Ofolder > "\" > ofilename > ".dxf"
dim ocompdef as sheetmetalcomponentdefinition
ocompdef = odrawdoc.componentdefinition
if ocompdef.hasflatpattern = false thenocompdef.unfold
else
ocompdef.flatpattern.edit
end if
dim aid as stringaid = "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
nextthe rule works very well, it exports me all the plates but I do not want me to export them all (some of them the customer already has them in stock so you do not have to order them that is why I do the dxf that will then be sent to the supplier) to distinguish the plates to order from those we have not inserted the property 'pannello' in the field 'supplier' in the menu iproperties. I've seen you call back this way
param=iproperties.value("project", "vendor")
the thing I can't do is add to the rule the fact that if the field supplier is empty you don't make me the dxf, if it presents the word 'pannello' you create the dxf.
Thank you very much
I have this ilogic rule that exports me the dxf of the various plates inside a set in inventor
'define the active document as an assembly filedim oasmdoc as assemblydocument
oasmdoc = thisapplication.asset
oasmname = left(oasmdoc.displayname, len(oasmdoc.displayname) -4)
'check that the active document is an assembly fileif thisapplication.activedocument.documenttype <> kassemblydocumentobject then
messagebox.show("please run this rule from the assembly file.", "ilogic")
exit sub
end if
'get user inputwear and tear = 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 wear and tear = vto then
return
else
end if
opath = thisdoc.pathodatamedium = thisapplication.transientobjects.createdatamedium
ocontext = thisapplication.transientobjects.createtranslationcontext
ocontext.type = iomechanismenum.kfilebrowseiomechanism
ooptions = thisapplication.transientobjects.createnamevaluemap
'get dxf target folds pathOfolder = opath > "\" > oasmname > "dxf files"
'check for the dxf folder and create it if it does not existif not system.io.directory.exists(Ofolder) then
system.io.directory.createdirectory(Ofolder)
end if'- - - - - - - - - - - - -
'- - - - - - - - - - - - -component - - - - - - - - - - - -
'look at the files referenced by the assemblydim 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 savedfor each orefdoc in orefdocs
iptpathname = left(orefdoc.fulldocumentame, len(orefdoc. fulldocument) - 3) > Ipt.
'check that model is saved(system- Me.exists(Pitpathname)) then
dim odrawdoc as partdocument
odrawdoc = thisapplicationDocuments.open(iptpathname, true)
ofilename = left(orefdoc.displayname, len(orefdoc.displayname))
try
'set the dxf target file nameodatamedium.filename = Ofolder > "\" > ofilename > ".dxf"
dim ocompdef as sheetmetalcomponentdefinition
ocompdef = odrawdoc.componentdefinition
if ocompdef.hasflatpattern = false thenocompdef.unfold
else
ocompdef.flatpattern.edit
end if
dim aid as stringaid = "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
nextthe rule works very well, it exports me all the plates but I do not want me to export them all (some of them the customer already has them in stock so you do not have to order them that is why I do the dxf that will then be sent to the supplier) to distinguish the plates to order from those we have not inserted the property 'pannello' in the field 'supplier' in the menu iproperties. I've seen you call back this way
param=iproperties.value("project", "vendor")
the thing I can't do is add to the rule the fact that if the field supplier is empty you don't make me the dxf, if it presents the word 'pannello' you create the dxf.
Thank you very much