|
[Sponsors] |
May 23, 2014, 10:32 |
script - transform a connector
|
#1 |
Member
Vanessa Herwig
Join Date: May 2014
Posts: 36
Rep Power: 12 |
Hi,
I am looking for a script, which transforms a connector. Journaling gives me the following - but this is really cumbersome Code:
################################################ pw::Application clearClipboard pw::Application setClipboard[list $_CN(23) $_CN(24)] pw::Application markUndoLevel {Copy} set _TMP(mode_1) [pw::Application begin Paste] set _TMP(PW_1) [$_TMP(mode_1) getEntities] set _TMP(mode_2) [pw::Application begin Modify $_TMP(PW_1)] pw::Entity transform [pwu::Transform translation [pwu::Vector3 subtract[list 0 0 -3][list 3.592982456140399e-5 1.0950441942103595e-17 0.0]]] [$_TMP(mode_2) getEntities] $_TMP(mode_2) end unset _TMP(mode_2) $_TMP(mode_1) end unset _TMP(mode_1) ############################################### Thanks for your help Vanessa |
|
May 23, 2014, 11:49 |
|
#2 |
Senior Member
Chris Sideroff
Join Date: Mar 2009
Location: Ottawa, ON, CAN
Posts: 434
Rep Power: 22 |
Here's it cleaned up with a comment for each step:
Code:
package require PWI_Glyph 2.17 ## TRANSLATE COPIED CONNECTOR 3 units in the z-dir ## # modify for your script set cons [pw::Grid getByName "con-1"] # begin point of translation set pt1 "0 0 0" # end point of translation set pt2 "0 0 3" ## START COPY/PASTE/TRANSLATE ## # make sure clipboard is empty pw::Application clearClipboard # copy connectors to clipboard pw::Application setClipboard $cons # create paste mode set mode(paste) [pw::Application begin Paste] # store copied connectors set xformCons [$mode(paste) getEntities] # copied connectors modify mode set mode(mod) [pw::Application begin Modify $xformCons] # translation vector set transVect [pwu::Vector3 subtract $pt2 $pt1] # translation matrix set xformMatrix [pwu::Transform translation $transVect] # translate copied connectors pw::Entity transform $xformMatrix $xformCons # end modify mode $mode(mod) end # end paste mode. copied connectors now translated $mode(paste) end When you script some commands and don't understand the methods used, find it the documentation. Most have examples. -Chris Last edited by cnsidero; June 2, 2014 at 11:38. |
|
June 1, 2014, 18:28 |
|
#3 |
Senior Member
John Chawner
Join Date: Mar 2009
Location: Fort Worth, Texas, USA
Posts: 275
Rep Power: 18 |
Hi Vanessa:
Chris has already answered your question. But keep in mind that while journaling is a good learning tool, it does things primarily to ensure the script can be played back. Therefore, it looks a lot more complex than one you'd write yourself.
__________________
John Chawner / jrc@pointwise.com / www.pointwise.com Blog: http://blog.pointwise.com/ on Twitter: @jchawner |
|
Tags |
connector, scripting, transform |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[ICEM] Script: problems with face names | Maweil | ANSYS Meshing & Geometry | 3 | April 16, 2019 10:10 |
[ICEM] Problem with ICEM Script Meshing | asal | ANSYS Meshing & Geometry | 2 | March 23, 2013 20:11 |
CentFOAM Python Script Installation: Error | socon009 | OpenFOAM Installation | 2 | May 26, 2012 10:36 |
Perl script for intialisation | pratik mehta | CFX | 2 | September 10, 2008 04:09 |
scripting gridgen: why a connector is not saved?? | Tim | Siemens | 2 | July 28, 2007 17:11 |