VrOne/Python Programming

ON-LINE REFERENCE DOCUMENTATION

CARDINAL SYSTEMS, LLC

386-439-2525   

www.cardinalsystems.net   
 

Text Class Reference (PyVrText)

 

The VrOne/Python Text class holds and manipulates VrOne text data.  More…

 

Members

 

 


Detailed Description

The VrOne/Python Text class is used to define VrOne Text label data.  A text consists of a header, an xyz coordinate and a text label string.  An existing Text class may be loaded from disk.  Header information may be defined by a Python script or may be inherited from a VrOne Function Key.  The user of this class should understand the VrOne Data Structure.

 

Example:

# Loads all the text in the current workspace, changes the text

# label to the elevation of the entity.

# Filename: ChangeText.py

# WARNING: Changes data but is undoable

 

Ws    = PyVrWs()    # VrOne workspace manager object

Text  = PyVrText()  # VrOne text object

WsNum = Ws.Aws()    # Current workspace

 

Ws.UndoBegin (WsNum, "ChangeText")              # Begin undo

 

for TextNum in range (0, Ws.GetTextCount (WsNum)):

 

      Text.Load (WsNum, TextNum)                # Load text

      Text.Erase()                              # Erase it from graphics

      (x, y, z) = Text.GetCoord()

      Text.SetText ("Elevation=%.3f" % z)

      Text.ReRec()                              # Re-record it

      Text.Plot()                               # Re-plot it

 

Ws.UndoEnd (WsNum)                              # End undo

 


Member Function Documentation

Init ()

Initializes the text to default values.  This is useful when reusing the text class.

Example           Text.Init()

Load (WsNum, TextNum)

Loads a text from disk

WsNum           Workspace number (0-255)

TextNum          Text number (0-?)

Returns             Text number loaded. -1 = Ws number or text number is out of range.

Example           Text.Load (WsNum, TextNum)

LoadLast ()

Loads the last saved text.  If a Python script is run as a Function Key’s OnEnd command it is possible for the script to further process the text that was just saved.  See the AddPosts.py example.

Return  s           0=Ok   -1=There is no last text

Example           Text.LoadLast ()

Rec (WsNum, DispFlag=-1)

Records a text at the end of a workspace.

WsNum           Workspace number to record to (0-255)

DispFlag           Optional display flag (-1=Don’t condition 0=Do not display 1=Display)

Returns             Text number  -1=Workspace number is out of range

Example           Text.Rec (WsNum)

ReRec (DispFlag=-1)

Re-records a previously loaded text by marking the original location as deleted and placing the text at the end of the workspace.

DispFlag           Optional display flag (-1=Don’t condition 0=Do not display 1=Display)

Returns             0=Ok -1=Could not record text

Example           Text.ReRec ()

Del ()

Deletes the text by marking its layer number as a negative number on disk.  Pack Vr removes deleted entities from a workspace.

Returns             0=Ok -1=Could not delete text.  Text was never loaded.

Example           Text.Del ()

Id (WsNum=-1)

Allows the interactive selection of a text.  Returns a text number that may be used to load the text from disk.

WsNum           Workspace number to search (0-255 -1=Search all open workspaces)

Returns             Text number selected (-1=Text not selected)

Example:

# Select (Id) a text and print some information

Ws      = PyVrWs()              # VrOne workspace manager

Text    = PyVrText()            # VrOne text object

 

if (Text.Id() != -1):           # Did we get a text?

 

      print "Layer     ", Text.GetLayer()

      print "Height    ", Text.GetHgt()

      print "Width     ", Text.GetWdt()

      print "Rotation  ", Text.GetRot()

      print "Text label", Text.GetText()

Copy (TargetText)

Copies the current text to the target text passed.

TargetText        Text object to copy to

Example:

# Copy Text

Ws      = PyVrWs()              # VrOne workspace manager

Text    = PyVrText()            # VrOne text object

TarText = PyVrText()            # Text to copy to

 

if (Text.Id() != -1):           # Did we get a text label?

   print TarText.GetLayer()     # Print the current layer of TarText

   Text.Copy (TarText)          # Copy the identified text to TarText

   print TarText.GetLayer()     # Print new layer of TarText

GetWsNum ()

When a text is loaded, the workspace number in which the text was loaded from is stored in the object.

Returns             Workspace number (0-255  -1=Text was never loaded from disk)

Example

# Select (Id) a text and print its workspace and text number

Ws      = PyVrWs()              # VrOne workspace manager

Text    = PyVrText()            # VrOne text object

 

if (Text.Id() != -1):           # Did we get a text?

   print “Workspace  ”, Text.GetWsNum()

   print “Text number”, Text.GetTextNum()

 

GetTextNum ()

When a text is loaded, its text number is stored in the object

Returns             Text number (0-?  -1=Text was never loaded from disk)

Example

# Select (Id) a text and print its workspace and text number

Ws      = PyVrWs()              # VrOne workspace manager

Text    = PyVrText()            # VrOne text object

 

if (Text.Id() != -1):           # Did we get a text?

   print “Workspace  ”, Text.GetWsNum()

   print “Text number”, Text.GetTextNum()

 

SetLayer (Layer)

Sets the layer of the text.

Layer               Layer number (1-10,001)

Example           Text.SetLayer (23)

SetPenNum (PenNum)

Sets the pen number of a text, which determines the color to use when drawing a text label.  NOTE: If a Pen Table is active this command has no effect.

PenNum           Pen number (1-256)

Example           Text.SetPenNum (2)

SetNpoint (Npoint)

Sets the Non-graphic pointer of the text.

Npoint              Non-graphic pointer (-2,147,483,648 to 2,147,483,648)

Example           Text.SetNpoint (1278)

SetLink (Link)

Sets the Link of the text

Link                 Text link (-2,147,483,648 to 2,147,483,648)

Example           Text.SetLink (4512)

SetFc (Fc)

Sets the Feature Code of the text

Fc                    Feature code (Up to 48 characters)

Example           Text.SetFc (“Material=Wood”)

SetConstr (Constr)

Sets the Construction display flag of the Text.  The display of text labels that have their construction flags set to 1 may be turned off.

Constr              Construction flag (0-1)

Example           Text.SetConstr (0)

 

SetFontNum (FontNum)

Sets the font for the text label.

FontNum          Text font number (1-12)

1

CI

Complex Italic

2

CR

Complex Roman

3

CS

Complex Script

4

DR

Duplex Roman

5

GE

Gothic English

6

GG

Gothic German

7

GI

Gothic Italic

8

HS

Standard

9

SR

Simplex Roman

10

SS

Simplex Script

11

TI

Triplex Italic

12

TR

Triplex Roman

Example           Text.SetFont (9)

SetJustX (JustX)

Sets the text X-axis justification.

JustX                X Justification (1=Left 2=Center 3=Right 4=Decimal)

Example           Text.SetJustX (2)

SetJustY (JustY)

Sets the text Y-axis justification.

JustX                Y Justification (1=Lower 2=Center 3=Upper)

Example           Text.SetJustX (2)

SetHgt (Hgt)

Sets the text height

Hgt                   Text height in ground units (double precision)

Example           Text.SetHgt (1.234)

SetWdt (Wdt)

Sets the text width for one character.

Wdt                 Text width in ground units (double precision)

Example           Text.SetWdt (1.234)

SetSize (Size)

Sets the text height and width.  This is useful if the text size and width are the same.

Size                  Text size in ground units (double precision)

Example           Text.SetSize (1.234)

SetRot (Rot)

Sets the text rotation.  The rotation is counterclockwise with zero being along the X-axis.

Rot                   Text rotation in degrees (0-360, double precision)

Example           Text.SetRot (24.0)

SetSlt (Slt)

Sets the text slant.  A text slant of zero is no text slant.

Slt                    Text slant in degrees (-180 to 180, double precision)

Example           Text.SetSlt (-20.0)

SetText (Text)

Sets the text label

Text                 Text label (up to 512 characters)

Example           Text.SetText (“VrOne/Python Programming”)

SetCoord (x, y, z)

Sets the text coordinate value.

x, y, z               Text coordinate value (double precision)

Example           Text.SetCoord (x, y, z)

GetLayer ()

Returns the layer of the text.

Returns             Layer number (1-10,001).  A return layer number that is 0 or less than 0 represents a deleted entity.

Example           Layer = Text.GetLayer()

GetPenNum ()

Returns the pen number of the text.  The pen number determines the color to use when drawing a text.

Returns             Text pen number (1-256)

Example           PenNum = Text.GetPenNum()

GetNpoint ()

Returns the non-graphic pointer of the text.

Returns             Text non-graphic pointer (-2,147,483,648 to 2,147,483,648)

Example           Npoint = Text.GetNpoint()

GetLink ()

Returns the link of the text.

Returns             Text link (-2,147,483,648 to 2,147,483,648)

Example           Link = Text.GetLink()

GetFc ()

Returns the feature code of the text

Returns             Text feature code (up to 48 characters)

Example           Fc = Text.GetFc()

GetConstr ()

Returns the construction flag of the text.  The display of text labels that have their construction flags set to 1 may be turned off.

Returns             Text construction flag (0-1)

Example           Constr = Text.GetConstr()

GetFontNum ()

Returns the font number of the text

Returns             Font number

1

CI

Complex Italic

2

CR

Complex Roman

3

CS

Complex Script

4

DR

Duplex Roman

5

GE

Gothic English

6

GG

Gothic German

7

GI

Gothic Italic

8

HS

Standard

9

SR

Simplex Roman

10

SS

Simplex Script

11

TI

Triplex Italic

12

TR

Triplex Roman

Example           FontNum = Text.GetFontNum()

GetJustX ()

Returns the text X-axis justification.

Returns             X Justification (1=Left 2=Center 3=Right 4=Decimal)

Example           JustX = Text.GetJustX()

GetJustY ()

Returns the text Y-axis justification.

Returns             Y Justification (1=Lower 2=Center 3=Upper)

Example           JustY = Text.GetJustY()

GetHgt ()

Returns the text height.

Returns             Text height in ground units (double precision)

Example           Hgt = Text.GetHgt()

GetWdt ()

Returns the text width.

Returns             Text width in ground units (double precision)

Example           Wdt = Text.GetWdt()

GetSize ()

Returns the text size, which is a combination of the text height and width.  The text height and width are averaged to form the text size.

Returns             Text size in ground units (double precision)

Example           Size = Text.GetSize()

GetRot ()

Returns the rotation of the text.  The rotation is counterclockwise with zero being along the X-axis.

Returns             Text rotation in degrees

Example           Rot = Text.GetRot()

GetSlt ()

Returns the slant of the text.  A text slant of zero is no text slant.

Returns             Text slant in degrees (-180 to 180, double precision)

Example           Slant = Text.GetSlt()

GetText ()

Returns the text label

Returns             Text label (up to 512 characters)

Example           TextLabel = Text.GetText()

GetFkeyParams (FkeyName)

Fills the text header data from a previously defined VrOne function key.  If the function key requested does not exist, the text header is filled with default parameters.

FkeyName       Function key name

Returns             0=OK  -1=Function key does not exist

Example           RetVal = Text.GetFkeyParams (“Pole”)

GetCoord ()

Returns a coordinate value from the text

Returns             x, y, z (double precision)

Example           (x, y, z) = Text.GetCoord()

Plot ()

Plots the text label to all open graphics devices.  The current header parameters are used.

Example           Text.Plot()

Erase ()

Erases the text label from all open graphics devices.

Example           Text.Erase()