Week - 9 - Reflecting the geometry
Objective:
This taks objective is to create script that allows for easy mirror reflection of fea entities. I adapted this idea to my needs by extending functionality of linear translation. To determine destination cad to cad is asked by author, I wanted to make it more versatile and added node to node option, and manual selection of reflection plane. User can also decide if wants to duplicate components or only move them.
I intentionally ommited creating properties in this script, as I work with structures made of steel bended profiles welded together thickness is constant within component. Thickness is nested within component name, properties and materials are created by seperate script by the very end of model preparation. What is crucial for me is to maintain fea entites attached to midsurface geometry, what allows for easy modification and remeshing. New name should preserve core name of origin comp and by adding prefix indicating what operation lead to creation of this comp (ex lin1_source_name, mir1_source_name).
When making linear translation or reflection on multiple components I want to preserve mesh connection if present between all selected components to avoid equivalencing nodes between components later.
Problem Statement:
When working with assembly where some of parts that are identical it is very beneficial to make high quality mesh on one of them and copy it to all rest. There can be also situation when you would like to move multiple components from bigger assembly to a new place and maitain mesh continuity within selected components, but break from surrouding ones in order not to drag elements that had connection.
Two most common operations to magane are translation and reflection, they involve making duplicates of components and renaming them. Duplicate components as they appear in hypermesh will have added suffix of .1 For my needs it is curcial that name will end with ^thickness.mm, by adding prefix new name will be unique.
Tcl command explanation:
Gui for this script is divided in 5 parts:
First part has radiobutton switching between linear translation option and mirror reflection.
Next part has three buttons for determing destination and origin for operations mentioned above. Valid input for linear translation are CADtoCAD or NODEtoNODE method, and for mirror reflection user can manually define plane of reflection based on center point, or use two previous options. For CADtoCAD in first step center node is found than vector from origin node to destination node is extablished, if needed for mirror reflection a plane is set to be normal to vector and placed between two nodes.
Following part has radiobutton swithing between duplicate option and no duplicate just move comp option.
Next part presents all above selected options by displaying vaiables that later on will be passed to procedures. First field updates automatically with clicking first radiobutton. Second field activates when user provides correct info about origin/destination. This field clears each time script is executed. Last field shows if script will duplicate or only move selected components.
Eventually last part has only one button that will execute procedures in right order. If all above options are provided correctly, user has last task to select components that wants to execute script on. Here inportant note, if multiple components will be selected, their connection will be preserved, no remeshing will take place, and that is what I was looking for.
Procedures used in this script: collecting input is handled by proc OriginTarget depending on button clicked switch function selects what actions to make. If option is cad_to_cad at first user has to select origin solid geometry, second selection is for destination geometry, than center nodes are created and passed to origin_node and destin_node variables. If option node_to_node is selected user has to provide origin node and than destination node, in their places new tmp nodes are insterted and passed to origin_node and destin_node variables for further proccessing. If option center_point user has to define plane for mirror reflection.
All input options have valid check in them, ex selecting node or more than one destination cad/node will result in error message.
Main procedure Execute is invoked with execute button click. At first origin/destination variable is checked for presence, and compatibility with action option (one exception, translation cant be defined with center point). If those checks pass, panel with component selection pops up, and selected components are stored in origin_comps variable. Then those components are input for ExecuteDuplicate proc, result of it in a form of current_list of components is created and passed further. ExecuteDuplicate proc starts with creating duplicate with list of selected components, two switch options decide whether delete origin components or not, than rename duplicated components sourcing original name and with use of UniqueName proc exstablishing new unique name by adding prefix (linno_ or mirno_) to the existing name. Also components are cleared from direct and indirect property assigment, and material assigment. Procedure returns with list new list of components that will be passed to ExecuteAction procedure for final evaulation. In this proc, switch option decides what action is to be made. If components need to be translated, distance and vector is calculated, components are translated and mark is cleared. For mirror_reflection, if no plane was specified proc creates plane between origin and destination node, components are reflected and mark is cleared.
Execute proc ends with printing log concluding operations made, specifing ids of components that are result of actions taken. All variables are cleared and user can proceed from the begining.
Conclusion:
Prepared script covers my specific needs for working with rolling stock welded carbody structure. Its aim is to facititate process of discretization at early stage when I work only on geometry and mesh.
created by Adam