alde67
Guest
buongiorno a tutti, uso inventor 2024 pro.
utilizzo questa regola per estrarre i dxf delle lamiere. funziona bene ma mi piacerebbe che nel nome del file ci sia lo spessore della lamiera.
qualcuno che riesca ad implementarla?
grazie!
'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
try
customname =iproperties.value(ofilename, "custom", "pf_prt_znr")
catch
customname ="astra srl" 'wert, wenn ipropertie pf_prt_znr nicht existiert
end try
odatamedium.filename = ofolder & "\" & customname & " " & 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"
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
utilizzo questa regola per estrarre i dxf delle lamiere. funziona bene ma mi piacerebbe che nel nome del file ci sia lo spessore della lamiera.
qualcuno che riesca ad implementarla?
grazie!
'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
try
customname =iproperties.value(ofilename, "custom", "pf_prt_znr")
catch
customname ="astra srl" 'wert, wenn ipropertie pf_prt_znr nicht existiert
end try
odatamedium.filename = ofolder & "\" & customname & " " & 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"
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