General HydroStatics
Ship Stability Software
Command of the Week
(New or interesting aspects of GHS that you may not know about)

Variables in Part Maker


John Bonn noticed the example in COW016, and he became very excited about the advantages of embedding variables and expressions in his geometry definitions. But he came to us complaining that COW016 was actually no help to him because it didn't tell him where and how to define variables and when to use PMX vs. PM.

Well, we had to agree with him.

John suggested that we make another stab at it, keeping it as simple as possible -- which we've done, and here it is.

PM can make use of variables defined in the GHS main program. For example,


 variable diam=10
 enter pm
 create ball
  class hull
  sphere 0 0 0  {diam}
 /
 write ball.gf
 quit pm
The reason this works is not obvious. Before handing the PM portion of the run file off to Part Maker, GHS processes it, substituting variable values where indicated.

But variables can be defined in Part Maker, making the pre-processing unnecessary. Pre-processing can be turned off by including the /DIRECT parameter. For example,


 enter pmx /direct
 real diam:=10
 create ball
  class hull
  sphere 0, 0, 0, diam
 /
 write ball.gf
 quit pm
Notice that this uses PMX, which requires separators between parameters (not just spaces). This makes it possible to use arithmetic expressions. For example,

 enter pmx /direct
 real radius:=5
 create ball
  class hull
  sphere 0, 0, 0, radius*2
 /
 write ball.gf
 quit pm
The /DIRECT is optional in these examples because there is nothing for the pre-processing to change. But if macros are involved, without the /DIRECT they will disappear and be replaced by their contents. This usually works, but it limits what the macros can do. For example,

 enter pmx /direct
 macro make
  create %1
   class hull
   sphere 0, 0, 0, 10
  //
 /
 str name:="ball"
 .make name
 write ball.gf
 quit pm
Without the /DIRECT, the name will not be "ball" as intended because "name" will be passed as a literal.

Questions, comments, or requests?
Contact Creative Systems, Inc.

support@ghsport.com

USA phone: 360-385-6212 Fax: 360-385-6213
Office hours: 7:00 am - 4:00 pm Pacific Time, Monday - Friday

Mailing address:
PO Box 1910
Port Townsend, WA 98368 USA

www.ghsport.com

Click here for an index to this and previous COWs