CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Mesh Generation & Pre-Processing Software > Pointwise & Gridgen

script - transform a connector

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 23, 2014, 10:32
Post script - transform a connector
  #1
Member
 
Vanessa Herwig
Join Date: May 2014
Posts: 36
Rep Power: 12
v_herw is on a distinguished road
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
v_herw is offline   Reply With Quote

Old   May 23, 2014, 11:49
Default
  #2
Senior Member
 
Chris Sideroff
Join Date: Mar 2009
Location: Ottawa, ON, CAN
Posts: 434
Rep Power: 22
cnsidero is on a distinguished road
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
The best thing to do is read the documentation for each step in the main body. For example, "pwu::Entity transform" requires a matrix as an argument which can be created by "pwu::Transform transform" which in turn requires the translation vector created by subtracting the begin point from the end point with "pwu::Vector3 subtract"

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.
cnsidero is offline   Reply With Quote

Old   June 1, 2014, 18:28
Default
  #3
Senior Member
 
John Chawner
Join Date: Mar 2009
Location: Fort Worth, Texas, USA
Posts: 275
Rep Power: 18
jchawner is on a distinguished road
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
jchawner is offline   Reply With Quote

Reply

Tags
connector, scripting, transform


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 08:34.