Thread: Wire body transformation to sheet body


Permlink Replies: 1 - Pages: 1 - Last Post: Oct 25, 2011 2:54 AM Last Post By: bdegreve
AMBROJO

Posts: 7
Registered: 06/08/09
Wire body transformation to sheet body
Posted: Oct 24, 2011 10:20 AM
Click to report abuse...   Click to reply to this thread Reply
Hello,

I have imported a .igs file from CAD and some planar strips have been imported as wirebody.

How these wire body structures can be transformed to sheet body and then to thick microstrip to launch a simulation. (The strips are microstrips lines for a planar filter).

Thanks.
bdegreve

Posts: 4
Registered: 08/08/11
Re: Wire body transformation to sheet body
Posted: Oct 25, 2011 2:54 AM   in response to: AMBROJO in response to: AMBROJO
Click to report abuse...   Click to reply to this thread Reply
Hello,

While this is feature is missing from the user interface, it is possible to achieve this using scripting functionality.
Below, you will find a script that replaces all wirebodies by either a sheet or an extrude.

Select your operation at the bottom of the script, and execute it.
For sheets, use the line traverse_assembly(empro.activeProject.geometry(), cover_wirebody), currently commented out.
For extrudes, use the line traverse_assembly(empro.activeProject.geometry(), extrude_wirebody("5 mm"))

Hope this helps.
Feel free to ask additional questions.


def traverse_assembly(assembly, operator):
'''
Recursively applies operator to all parts in an assembly, descending in all sub assemblies.
Operator should have to following signature:
def operator(assembly, index)
The first argument is the part currently visited, the second is its containing assembly
and the third is the index of the part within that assembly.

we traverse the indices in descending order, so that it is save to remove items.
'''
for index in reversed(range(len(assembly))):
part = assembly[index]
if isinstance(part, empro.geometry.Assembly):
traverse_assembly(part, operator)
else:
operator(part, assembly, index)


def cover_wirebody(wirebody, assembly, index):
'''
covers a wirebody and turns it into a sheet.
'''
if not isinstance(wirebody, empro.geometry.Sketch):
return
model = empro.geometry.Model()
model.name = wirebody.name
cover = empro.geometry.Cover(wirebody.clone())
model.recipe.append(cover)
assembly.append(model)
assembly.remove(index)


def extrude_wirebody(extrude_height):
'''
this is a more advanced example of an operator for the traverse_assembly.
It only takes one argument (the extrude height), but it returns a function
that can be passed to traverse_assembly.
'''
def op(wirebody, assembly, index):
if not isinstance(wirebody, empro.geometry.Sketch):
return
model = empro.geometry.Model()
model.name = wirebody.name
extrude = empro.geometry.Extrude(wirebody.clone(), extrude_height)
model.recipe.append(extrude)
assembly.append(model)
assembly.remove(index)
return op


#traverse_assembly(empro.activeProject.geometry(), cover_wirebody)
traverse_assembly(empro.activeProject.geometry(), extrude_wirebody("5 mm"))

Point your RSS reader here for a feed of the latest messages in all forums