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

export unfold dxf from idw file with part number instead of file name

John2020

Guest
hi sir,

recently i have copy a ilogic from autodesk forum, and actulally i wish to export the unfold pattern to dxf with part number instead of file name in ipt files. appreciate if you could help me to edit the code as below.


my sample expected: https://mega.nz/file/xf0qxloa#v5iqzzbitihin-cimbiurdeexakihiyea3b3q1hdt08


dim odoc as document = thisapplication.activedocument 'get active document
if odoc.documenttype <> documenttypeenum.kdrawingdocumentobject then exit sub 'drawings only
for each omodel as document in odoc.referenceddocuments' loop through all referenced documents
'sheet metal parts only
if omodel.documentsubtype.documentsubtypeid <> "{9c464203-9bae-11d3-8bad-0060b0ce6bb4}" then continue for
dim osmcd as sheetmetalcomponentdefinition = omodel.componentdefinition
if not osmcd.hasflatpattern then 'if it doesn't have a flat patter, create one (unfold the model)
osmcd.unfold ()
osmcd.flatpattern.exitedit ()
end if
dim fname as string = omodel.fullfilename 'get the document's path and name
fname = microsoft.visualbasic.left (fname, len (fname) - 4) & ".dxf"
dim sout as string = "flat pattern dxf? acadversion = r12 & rebasegeometry = true & outerprofilelayer = 0 & outerprofilelayercolor = 0; 0; 0 & interiorprofileslayer = 0 & interiorprofileslayercolor = 0; 0; 0 & invisiblelayers = iv_arc_centers; iv_tangent; iv_roll; iv_roll_tangent; iv_altrep_back; iv_altrep_front; iv_feature_profiles_down; iv_feature_profiles; iv_tool_center_down; digi_marker_tool_1; digi_marker_tool_2; iv_bend; iv_bend_down "'export settings
try
osmcd.dataio.writedatatofile (sout, fname) 'export
catch
end try
next
 
dear sir,
i modified the ilogic rule ti get the part number and to use that instead of the file name for the dxf name (i commented out a line and the part i added is between the "--------------"):

dim odoc as document = thisapplication.activedocument 'get active document
if odoc.documenttype <> documenttypeenum.kdrawingdocumentobject then exit sub 'drawings only
for each omodel as document in odoc.referenceddocuments' loop through all referenced documents
'sheet metal parts only
if omodel.documentsubtype.documentsubtypeid <> "{9c464203-9bae-11d3-8bad-0060b0ce6bb4}" then continue for
dim osmcd as sheetmetalcomponentdefinition = omodel.componentdefinition
if not osmcd.hasflatpattern then 'if it doesn't have a flat patter, create one (unfold the model)
osmcd.unfold ()
osmcd.flatpattern.exitedit ()
end if
dim fname as string = omodel.fullfilename 'get the document's path and name
'fname = microsoft.visualbasic.left (fname, len (fname) - 4) & ".dxf"
'--------------------------------------------------------------------------------------------------------------------
dim opartnumber as string = omodel.propertysets.item("inventor summary information").item("part number").value 'get the 3d document's part number
fname = opartnumber & ".dxf" 'assign the part number to the name variable instead of the file name
'--------------------------------------------------------------------------------------------------------------------
dim sout as string = "flat pattern dxf? acadversion = r12 & rebasegeometry = true & outerprofilelayer = 0 & outerprofilelayercolor = 0; 0; 0 & interiorprofileslayer = 0 & interiorprofileslayercolor = 0; 0; 0 & invisiblelayers = iv_arc_centers; iv_tangent; iv_roll; iv_roll_tangent; iv_altrep_back; iv_altrep_front; iv_feature_profiles_down; iv_feature_profiles; iv_tool_center_down; digi_marker_tool_1; digi_marker_tool_2; iv_bend; iv_bend_down "'export settings
try
osmcd.dataio.writedatatofile (sout, fname) 'export
catch
end try
next
 
[QUOTE = "Andrea Scarnecchia, post: 460773, member: 89736"]
dear sir,
i modified the ilogic rule ti get the part number and to use that instead of the file name for the dxf name (i commented out a line and the part i added is between the "------------ - "):

dim odoc as document = thisapplication.activedocument 'get active document
if odoc.documenttype <> documenttypeenum.kdrawingdocumentobject then exit sub 'drawings only
for each omodel as document in odoc.referenceddocuments' loop through all referenced documents
'sheet metal parts only
if omodel.documentsubtype.documentsubtypeid <> "{9c464203-9bae-11d3-8bad-0060b0ce6bb4}" then continue for
dim osmcd as sheetmetalcomponentdefinition = omodel.componentdefinition
if not osmcd.hasflatpattern then 'if it doesn't have a flat patter, create one (unfold the model)
osmcd.unfold ()
osmcd.flatpattern.exitedit ()
end if
dim fname as string = omodel.fullfilename 'get the document's path and name
'fname = microsoft.visualbasic.left (fname, len (fname) - 4) & ".dxf"
'------------------------------------------------- -------------------------------------------------- -----------------
dim opartnumber as string = omodel.propertysets.item ("inventor summary information"). item ("part number"). value 'get the 3d document's part number
fname = opartnumber & ".dxf" 'assign the part number to the name variable instead of the file name
'------------------------------------------------- -------------------------------------------------- -----------------
dim sout as string = "flat pattern dxf? acadversion = r12 & rebasegeometry = true & outerprofilelayer = 0 & outerprofilelayercolor = 0; 0; 0 & interiorprofileslayer = 0 & interiorprofileslayercolor = 0; 0; 0 & invisible_coll; iv_arenters; iv_arenters; ivarenters; iv_roll_tangent; iv_altrep_back; iv_altrep_front; iv_feature_profiles_down; iv_feature_profiles; iv_tool_center_down; digi_marker_tool_1; digi_markender_tool_2; iv_bendown 'settings
try
osmcd.dataio.writedatatofile (sout, fname) 'export
catch
end try
next[/ QUOTE] [/ QUOTE]
 
dear mr andrea,

i have tried the code as per you provided, but still doesn't work :( and what i get the error message as below here: -

--------------------------------------------------------------------------------------------------------------------------------------------------------
error in rule: rule76, in document: form support channel_test.idw

unspecified error (exception from hresult: 0x80004005 (e_fail))
 
[QUOTE = "John2020, post: 460781, member: 90568"]
dear mr andrea,

i have tried the code as per you provided, but still doesn't work :( and what i get the error message as below here: -

-------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -
error in rule: rule76, in document: form support channel_test.idw

unspecified error (exception from hresult: 0x80004005 (e_fail))[/ QUOTE]


dear andrea,

thank you very much, now my issue has been solved, just a minor changed on omodel sets.
 

Forum statistics

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

Members online

No members online now.
Back
Top