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

added variable the logical roule

  • Thread starter Thread starter silvia_cherry
  • Start date Start date

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." _&gt; vblf &gt; "this rule expects that the part file is saved." _&gt; vblf &gt; " " _&gt; vblf &gt; "are you sure you want to create dxf for all of the assembly components?" _&gt; vblf &gt; "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 &gt; "\" &gt; oasmname &gt; "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 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.fulldocumentame, len(orefdoc. fulldocument) - 3) &gt; 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 &gt; "\" &gt; ofilename &gt; ".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
 
hi, be careful with ilogic shortcuts, the access you show is to the active document, for example if you need access to the property of a display template file, you should perform another access method.
This is why I ask you, where is the property "vendor"? in the display pattern file found on the sheet?
 
@sergio.d.suarez the "vendor" popility corresponds to the 'supplier' that is located between the iproperties of the 3d model, but I don't think that's the answer to your question
 
un metodo più sicuro per accedere alle proprietà dei documenti è quello che ti mostro di seguito.
devi specificare il documento in cui si trova la proprietà di cui hai bisogno. penso che dovresti presentare questo approccio nella tua regola.

dim odoc as document = thisdoc.document
dim ovendor as string = odoc.propertysets.item("design tracking properties").item("vendor").value

ora, per adattare la tua regola, penso che dovresti trovare qualcosa di simile al seguente

'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
'- - - - - - - - - - - - -
dim ovendor as string
'work the the drawing files for the referenced models
'this expects that the model has been saved
for each orefdoc as document in oasmdoc.allreferenceddocuments
topdor = orefdoc.propertysets.item("design tracking properties).item("vendor).value if ovendor = "pannello" then

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
end if end ifnext

I highlighted the lines I added in red.
by this method you will look for the value of the "supplier" property of each file of parts and if this property is equal to "panel", it will be converted to dxf when you need it. (if you need the opposite simply replace = with signs <> to create the "different")
I also carried out a reorganization, through the "tab" button, this to make the code more readable and easy to understand at first sight. if it is not reorganized, it is not known at first sight where it begins and ends a specific instruction.
I hope the code's contribution is clear. you can consult this information for more details about access to properties, it is the vba language, but it can be easily adapted to the ilogical.
https://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html I hope something here can help you.
Goodbye
 
Excuse me, I'm new in the forum and I could verify that here you can't make corrections with the tab key, when entering the spaces are deleted. greetings
 
Thank you so much! I'll try and let you know tomorrow. Thanks again, very kind!
 

Forum statistics

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

Members online

No members online now.
Back
Top