PyVrLine

Top  Previous  Next

Vr Mapping

ON-LINE REFERENCE DOCUMENTATION

CARDINAL SYSTEMS, LLC

www.cardinalsystems.net

Layer Class Reference (PyVrLine)

Holds and manipulates VrOne line data More…

Members

Initialization

Init ()
Reset ()

 

File Operations

Load (WsNum, LineNum, DispFlag=-1)
LoadLast ()
Rec (WsNum, DispFlag=-1)
ReRec (DispFlag=-1)
Del ()
Id (WsNum=-1)
GetIdPoint ()
Copy (TargetLine)

 

Set Line Attributes

SetLayer (Layer)
SetMode (Mode)
SetGpoint (Gpoint)
SetPenNum (PenNum)
SetNpoint (Npoint)
SetLink (Link)
SetFc (Fc)
SetConstr (Constr)
SetWidth (Width)
SetOrient (Orient)
SetSide1 (Side)
SetSide2 (Side)
SetPointFlags (PntNum, p=-1, a=-1, c=-1, f=-1, m=-1)
GetFkeyParams (FkeyName)

 

Get Line Attributes

GetWsNum ()
GetLineNum()
GetNumXyz ()
GetLayer ()
GetMode ()
GetGpoint ()
GetPenNum ()
GetNpoint ()
GetLink ()
GetFc ()
GetConstr ()
GetWidth ()
GetOrient ()
GetSide1 ()
GetSide2 ()
GetPointFlags (PntNum)

 

Coordinate Input Output

AddPoint (x, y, z. p=0, a=0, c=0, f=0, m=0)
InsPoint (PntNum, x,  y,  z, p=0, a=0, c=0, f=0, m=0)
ChgPoint (PntNum, x, y, z=0.0, p=0, a=0, c=0, f=0, m=0)
GetPoint (PntNum)
Backup ()
DelPoint (PntNum)
DelPoints (Begin, End, Mode)
ShowPoints ()

 

Geometry

Reverse ()
Offset (OfsDist)
Move (Dx, Dy, Dz)
Scale (PivotX, PivotY, SclFac)
Rotate (PivotX, PivotY, RotAng)
MirrorX (PntNum)
MirrorY (PntNum)
Length (Mode)
Area ()
Direction ()
ZRange ()
Mbr ()
Azimuth ()
ClosestEnd (x, y)
IsClosed ()
CloseDist ()
Close (CloseMode)
ClosePoint (x, y)
SnapPoint (SnapX, SnapY)
SnapPointAdd (SnapX, SnapY, SnapZ, p=0, a=0, c=0, f=0, m=0)
AddPointDist (Dist, StoreCmd)
IsPointInside (x, y)

 

Graphics

Plot ()
Erase ()

 


Description

The VrOne/Python Line class defines VrOne line data. A line consists of a header and a list of xyz points. An existing line 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 lines in current workspace, change the layers

# and graphic pointers and re-records them.

# Filename: ChangeLines.py

# WARNING: Changes data but is undoable

 

Ws   = PyVrWs()   # VrOne workspace manager object

Line = PyVrLine() # VrOne line object

WsNum = Ws.Aws()   # Current workspace

 

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

 

for LineNum in range (0, Ws.GetLineCount (WsNum)):

 

    Line.Load (WsNum, LineNum)               # Load line

    Line.Erase()                             # Erase it from graphics

    Line.SetLayer (23)                       # Change the layer

    Line.SetGpoint (15)                       # Change the graphic pointer

    Line.ReRec()                             # Re-record it

    Line.Plot()                               # Re-plot it

 

Ws.UndoEnd (WsNum)                             # End undo

 


Member Function Documentation

Init ()

Initializes a line by setting its header data to default values and setting its coordinate data to no points. This is useful when reusing a line class.

Reset ()

Resets a line by setting its coordinate data to no points. The line header is not modified. This is useful when reusing a line class.

Load (WsNum, LineNum)

Loads a line from disk.

WsNum

Workspace number (0-255).

LineNum

Line number.

returns

 

Line number loaded. -1 = workspace or line number out of range.

 

LoadLast ()

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

 

returns

0 = OK.

-1 = No last line.

Rec (WsNum, DispFlag=-1)

Records a line at the end of a workspace.

WsNum

Workspace number to record (0-255).

DispFlag

Optional display flag.

-1 = Do not condition.

 0 = Do not display.

 1 = Display.

returns

 

Line number. -1 = Workspace number out of range.

 

ReRec (DispFlag=-1)

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

DispFlag

Optional display flag.

-1 = Do not condition.

 0 = Do not display.

 1 = Display.

returns

 

0 = OK.

1 = Could not record line.

 

Del ()

Deletes a line 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 line. Line was never loaded.

 

Id (WsNum=-1)

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

WsNum

Workspace number to search (0-255).

returns

 

Line number. -1 = Line not selected.

Example:

# Select (Id) a line and print it

Ws      = PyVrWs()              # VrOne workspace manager

Line    = PyVrLine()            # VrOne line object

 

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

  # Print the points on the line

  for i in range (0, Line.GetNumXyz()):

     (x, y, z) = Line.GetPoint (i)

     print ("%d %.3f %.3f %.3f" % (i, x, y, z))

GetIdPoint ()

Returns the line point that was identified during the last Line.Id(). A Line.Id() must be called before GetIdPoint().

returns

 

Line point number. -1 = No point available.

 

Example:

# Select (Id) a line and print the line point number that was locked onto.

Ws      = PyVrWs()              # VrOne workspace manager

Line    = PyVrLine()            # VrOne line object

 

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

  print “The line point we locked onto was”, Line.GetIdPoint()

 

Copy (TargetLine)

Copies the current line to the target line.

TargetLine

Line to which to copy the current line.

 

Example:

# Copy line

Ws      = PyVrWs()              # VrOne workspace manager

Line    = PyVrLine()            # VrOne line object

TarLine = PyVrLine()            # Line to copy to

 

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

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

  Line.Copy (TarLine)          # Copy the identified line to TarLine

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

SetLayer (Layer)

Sets the layer of the line.

Layer

Layer number (1-10001).

 

SetMode (Mode)

Sets the mode of the line. Mode 1 is a line and mode 2 is splined line.

Mode

Line mode (1-2).

 

SetGpoint (Gpoint)

Sets the graphic pointer of the line. The graphic pointer determines the graphic representation of a line such as a fence or a tree line.

Gpoint

Line graphic pointer (1-1000).

 

SetPenNum (PenNum)

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

PenNum

Pen number (1-256).

 

SetNpoint (Npoint)

Sets the line's non-graphic pointer.

Npoint

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

 

SetLink (Link)

Sets the link of the line.

Link

Line link (-2,147,483,648 to 2,147,483,648).

 

SetFc (Fc)

Sets the Feature Code of the line.

Fc

Feature code (up to 48 characters).

 

SetConstr (Constr)

Sets the Construction display of the line. The display of lines that have their construction flags set to 1 may be turned off.

Constr

Construction flag.

Constr             Construction flag (0-1)

Example           Line.SetConstr (0)

SetWidth (Width)

Sets the width of the line. A line width defines the number of lines that will be drawn to the left and right of the centerline. The distance between these lines may be defined in Vr Configuration.

Width

Line width (0-255).

 

SetOrient (Orient)

Sets the orientation of the line if used by VrMosaic.

Orient

Line orientation.

-1 = Auto.

0  = Horizontal.

1 = Vertical.

SetSide1 (Side)

If used by VrMosaic, sets the image side of the first image.

Side

-1 = Auto

0 = Bottom or Left

1 = Top or Right

 

SetSide2 (Side)

If used by VrMosaic, sets the image side of the second image.

Side

-1 = Auto

0 = Bottom or Left

1 = Top or Right

SetPointFlags (PntNum, p=-1, a=-1, c=-1, f=-1, m=-1)

Sets the point flags to a line coordinate. If the point number is out of range then nothing is done. See the VrOne Data Structure for information on the p (Pen command), a (Arc flag), c (Code), f (Flags), and m (Mosaic width) parameters.

PntNum

Point number. (0 - Line.getNumXyz()-1)

p, a, c, f, m

 

Flags. If a parameter is passed as 01, the original number is not changed.

 

GetFkeyParams (FkeyName)

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

FkeyName

Function key name.

returns

 

0 = OK.

-1 = Function key does not exist.

 

GetWsNum ()

Returns the workspace number from which a loaded line was retrieved.

returns

 

Workspace number (0-255. -1 = Line was never loaded from disk).

Example

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

Ws      = PyVrWs()              # VrOne workspace manager

Line    = PyVrLine()            # VrOne line object

 

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

  print “Workspace  ”, Line.GetWsNum()

  print “Line number”, Line.GetLineNum()

GetLineNum ()

Returns the line number of a loaded line.

returns

 

Line number (0-?. -1 = Line was never loaded from disk).

Example

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

Ws      = PyVrWs()              # VrOne workspace manager

Line    = PyVrLine()            # VrOne line object

 

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

  print “Workspace  ”, Line.GetWsNum()

  print “Line number”, Line.GetLineNum()

GetNumXyz ()

Returns the number of points on the line.

returns

 

Number of points on line 0 - 2,147,483,648, memory permitting.

 

GetLayer ()

Returns the line's layer.

returns

 

Layer number (1-10,001). A negative return layer represents a deleted entity.

GetMode ()

Returns the mode of the line.

returns

 

Line mode .

1 = Line.

2 = Splined line.

 

GetGpoint ()

Returns the line's graphic pointer. The graphic pointer determines the graphic representation of a line such as a fence or a tree line.

returns

 

Line graphic pointer (1-1000).

GetPenNum ()

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

returns

 

Line pen number (1-256).

GetNpoint ()

Returns the non-graphic pointer of the line.

returns

 

Line non-graphic pointer (-2,147,483,648 to 2,147,483,648).

 

GetLink ()

Returns the link of the line.

returns

 

Line link (-2,147,483,648 to 2,147,483,648).

 

GetFc ()

Returns the feature code of the line

returns

 

Line feature code (up to 48 characters).

 

GetConstr ()

Returns the construction flag of the line.  Lines with construction flags set to 1 may have their displays turned off.

returns

 

Line construction flag (0-1).

 

GetWidth ()

Returns the width of the line. A line width defines the number of lines that will be drawn to the left and right of the centerline. The distance between these lines may be defined in Vr Configuration.

returns

 

Line width (0-255).

 

GetOrient ()

If used by VrMosaic, returns line orientation.

returns

 

Line orientation.

-1 = Auto.

0 = Horizontal.

1 = Vertical.

GetSide1 ()

If used by VrMosaic, returns the image side of the first image.

returns

 

Line orientation.

-1 = Auto.

0 = Bottom or left.

1 = Top or right.

 

GetSide2 ()

If used by VrMosaic, returns the image side of the second image.

returns

 

Line orientation.

-1 = Auto.

0 = Bottom or left.

1 = Top or right.

GetPointFlags (PntNum)

Returns the point flags to a line coordinate. If the point number requested is out of range, all parameters are returned as 0. See the VrOne Data Structure for information on the p (Pen command), a (Arc flag), c (Code), f(Flags), and m(Mosaic width) parameters.

PntNum

 

Point number (0 - Line.GetNumXyz()-1)

returns

 

p, a, c, f, m flags

 

AddPoint (x, y, z, p=0, a=0, c=0, f=0, m=0)

Adds a coordinate point to the line at the end of line. See the VrOne Data Structure for more information on the p (Pen command), a (Arc flag), c (Code) , f(Flags), and m(Mosaic width) parameters. The p,a,c,f,m parameters are optional and default to 0.

x,y,z

 

Coordinate to add to the line (double precision)

p

 

Pen code.

0 = None.

1 = Up.

2 = Continue.

4 = End.

a

 

Arc flag.

0 = None.

1 = Beginning, end, or PRC.

2 = Midpoint.

3 = Point on arc.

c

 

Code (0-255).

f

 

Bit encoded flag (0-255).

m

 

Mosaic width (0-255).

 

InsPoint (PntNum, x,  y,  z, p=0, a=0, c=0, f=0, m=0)

Inserts a coordinate point on the line after the point number specified. See the VrOne Data Structure for information on the p (Pen command), a (Arc flag), c (Code) , f(Flags), and m(Mosaic width) parameters. The p,a,c,f,m parameters are optional and default to 0. If the point number is out of range, the command is ignored.

PntNu

 

Point number after which to store new point (0 - Line.GetNumXyz()-1)

x,y,z

 

Coordinate to add to the line (double precision).

p

 

Pen code.

0 = None.

1 = Up.

2 = Continue.

4 = End.

a

 

Arc flag.

0 = None.

1 = Beginning, end, or PRC.

2 = Midpoint.

3 = Point on arc.

c

 

Code (0-255).

f

 

Bit encoded flag (0-255).

m

 

Mosaic width (0-255).

returns

 

0 = OK.

-1 = PntNum out of range.

 

ChgPoint (PntNum, x, y, z=0.0, p=0, a=0, c=0, f=0, m=0)

Changes an existing coordinate point on the line. See the VrOne Data Structure for information on the p (Pen command), a (Arc flag), c (Code), f(Flags), and m(Mosaic width) parameters. The z, p, a, c, f,m parameters are optional and default to 0. If the point number is out of range, the command is ignored.

PntNu

 

Point number to change  (0 - Line.GetNumXyz()-1).

x,y,z

 

New coordinate (double precision).

p

 

Pen code.

0 = None.

1 = Up.

2 = Continue.

4 = End.

a

 

Arc flag.

0 = None.

1 = Beginning, end, or PRC.

2 = Midpoint.

3 = Point on arc.

c

 

Code (0-255).

f

 

Bit encoded flag (0-255).

m

 

Mosaic width (0-255).

returns

 

0 = OK.

-1 = PntNum out of range.

 

GetPoint (PntNum)

Returns a coordinate point from the line. If the point number requested is out of range, the coordinate position is returned as 0.

PntNu

 

Point number to return  (0 - Line.GetNumXyz()-1).

returns

 

x,y,z (double precision) coordinates of point.

 

 

Backup ()

Backs the line up by deleting its last point.

returns

 

0 = OK.

-1 = No more points.

DelPoint (PntNum)

Deletes a point from the line. If the point number is out of range, nothing is done.

returns

 

0 = OK.

-1 = Point number out of range.

 

DelPoints (Begin, End, Mode)

Deletes a group of points from a line.

Begin

 

Begin line point number.

End

 

End line point number.

Mode

 

Delete mode.

0 = Delete specified points and points between them (default).

1 = Turn the "Begin" and "End" points into the first and last points on the line.

returns

 

0 = OK.

-1 = "Begin" or "End" out of range, or "End" is greater than "Begin".

 

ShowPoints ()

Prints the coordinate points on the line to the standard output device. This is useful when debugging.

Reverse ()

Reverses the direction of the line.

Offset (OfsDist)

Offsets the line by a defined distance. Line segment intersections are mitered.

OfsDis

Offset distance (ground units).

 

Move (Dx, Dy, Dz)

Moves the line in the xyz direction by defined distances.

Dx

Delta X move distance.

Dy

Delta Y move distance.

Dz

Delta Z move distance.

 

Scale (PivotX, PivotY, SclFac)

Scales the line from the specified point.

PivotX

Scale origin X.

PivotY

Scale origin Y.

SclFac

Scale factor.

 

Rotate (PivotX, PivotY, RotAng)

Rotates the line about the specified point.

PivotX

Rotation origin X.

PivotY

Rotation origin Y.

RotAng

Rotation angle clockwise in radians.

 

MirrorX (PntNum)

Mirrors the line in the X direction about a line point.

PntNum

Line point number about which to mirror line.

 

MirrorY (PntNum)

Mirrors the line in the Y direction about a line point.

PntNum

Line point number about which to mirror line.

 

Length (Mode)

Returns the line length.

Mode

Length type to return.

0 = Slope distance.

1 = Horizontal distance.

returns

Line length (ground units).

 

Area ()

Returns the line area.

returns

Line area in square ground units. If the line is open, it is closed for the area calculations.

 

Direction ()

Returns the line direction.

returns

Line direction.

0 = Clockwise.

1 = Counterclockwise.

 

ZRange ()

Returns the line Z range.

returns

Minimum and maximum line elevations.

Example           (MinZ, MaxZ) = Line.ZRange()

 

See also           Mbr()

Mbr ()

Returns the line's XY MBR (Minimum Bounding Rectangle).

returns

Minimum and maximum coordinates of the line.

Example           (MinX, MinY, MaxX, MaxY) = Line.Mbr()

See also           ZRange()

Azimuth ()

Returns the line's mean azimuth.

returns

Mean azimuth clockwise north up (in radians).

 

ClosestEnd (x, y)

Returns the closest line end to the specified point.

X,y

Coordinate poisition to check against line ends

returns

Closest end.

0 = Beginning of line.

1 = End of line.

 

IsClosed ()

Returns the closure status of the line.

returns

Closure status.

0 = Line is open.

1 = Line is closed.

 

CloseDist ()

Returns the distance between the two endpoints on a line.

returns

Distance in ground units.

 

Close (CloseMode)

Closes the line.

CloseMode

Close method.

0 = Move endpoint to startpoint.

1 = Mean endpoints.

2 = Add line segment between endpoint and startpoint.

3 = Intersect end segments.

 

ClosePoint (x, y)

Returns the closest line point number to the coordinate sent.

X,y

Coordinate.

returns

Closest line point number.

X, y                 Coordinate position

Returns             Closest point line number

Example           ClosePntNum = Line.ClosePoint (x, y)

SnapPoint (SnapX, SnapY)

Snaps the point sent to the line.

SnapX

X coordinate of point to be snapped.

SnapY

Y coordinate of point to be snapped.

returns

(RetX, RetY, RetZ, Dist)

RetX = X coordinate transformed to line.

RetY = Y coordinate transformed to line.

RetZ = Z coordinate transformed to line.

Dist = Distance from snap coordinate to ret coordinate.

SnapPointAdd (SnapX, SnapY, SnapZ, p=0, a=0, c=0, f=0, m=0)

Snaps and adds a point to the line based on the coordinate sent. The point flags of p, a, c, f, m are optional.

SnapX

X coordinate of point to be snapped.

SnapY

Y coordinate of point to be snapped.

SnapZ

Z coordinate of point to be snapped.

p

Pen code.

0 = None.

1 = Up.

2 = Continue.

4 = End.

a

Arc flag.

0 = None.

1 = Beginning, end, or PRC.

2 = Midpoint.

3 = Point on arc.

c

Code (0-255).

f

Bit encoded flag (0-255).

m

Mosaic width (0-255).

returns

Line point number of the new point.

 

AddPointDist (Dist, StoreCmd)

Adds a point to the line based on a distance from beginning of the line.

Dist

Distance from beginning of line to compute point.

StoreCmd

Store command.

0 = Do not store point on line.

1 = Store point on line.

returns

(RetX, RetY, RetZ, PntNum)

RetX = X coordinate transformed to line.

RetY = Y coordinate transformed to line.

RetZ = Z coordinate transformed to line.

PntNum = Line point number of new point (if point was stored), or line point number before return coordinate (if point was not stored).

 

IsPointInside (x, y)

Tests if the point is inside the line polygon.  If the line is open, it is closed for this calculation.

X,y

Coordinate to test.

returns

0 = Point is not within the line polygon.

1 = Point is within the line polygon.

 

Plot ()

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

 

Erase ()

Erases the line from all open graphics devices.