VrOne/Python Programming
|
ON-LINE REFERENCE DOCUMENTATION CARDINAL SYSTEMS, LLC 386-439-2525 |
The VrOne/Python Line class holds and manipulates VrOne line data. More…
Initialization
File Operations
Set Line Attributes
Get Line Attributes
Coordinate Input Output
Geometry
Graphics
The VrOne/Python Line class is used to define VrOne line data. A line consists of a header and 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
Initializes a line by settings its header data to default values and setting its coordinate data to no points. This is useful when reusing a line class.
Example Line.Init()
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.
Example Line.Reset()
Loads a line from disk
WsNum Workspace number (0-255)
LineNum Line number (0-?)
Returns Line number loaded. -1 = Ws number or line number is out of range.
Example Line.Load (WsNum, LineNum)
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=There is no last line
Example Line.LoadLast ()
Records a line 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 Line number -1=Workspace number is out of range
Example Line.Rec (WsNum)
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=Don’t condition 0=Do not display 1=Display)
Returns 0=Ok -1=Could not record line
Example Line.ReRec ()
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.
Example Line.Del ()
Allows the interactive selection of a line. Returns a line number that may be used to load the line from disk.
WsNum Workspace number to search (0-255 -1=Search all open workspaces)
Returns Line number selected (-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))
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()
Copies the current line to the target line passed.
TargetLine Line object to copy to
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
Sets the layer of the line.
Layer Layer number (1-10,001)
Example Line.SetLayer (23)
Sets the mode of the line. Mode 1 is a line and mode 2 is splined line.
Mode Line mode (1-2)
Example Line.SetMode (1)
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-1,000)
Example Line.SetGpoint (123)
Sets the pen number of a line which determines the color to use when drawing a line. NOTE: If a Pen Table is active this command has no effect.
PenNum Pen number (1-256)
Example Line.SetPenNum (2)
Sets the Non-graphic pointer of the line.
Npoint Non-graphic pointer (-2,147,483,648 to 2,147,483,648)
Example Line.SetNpoint (1278)
Sets the Link of the line.
Link Line link (-2,147,483,648 to 2,147,483,648)
Example Line.SetLink (4512)
Sets the Feature Code of the line.
Fc Feature code (Up to 48 characters)
Example Line.SetFc (“Material=Wood”)
Sets the Construction display line of the line. The display of lines that have their construction flags set to 1 may be turned off.
Constr Construction flag (0-1)
Example Line.SetConstr (0)
Sets the width of the line. A line width defines the number of lines that will be drawn to the left and the right of the centerline. The distance between these lines may be defined in Vr Configuration.
Width Line width (0-255)
Sets the orientation of the line if used by VrMosaic.
Orient -1=Auto,0=Horizontal,1=Vertical
Example Line.SetOrient (0)
Sets the image side of the first image if used by VrMosaic.
Side -1=Auto,0=Bottom or Left,1=Top or Right
Example Line.SetSide1 (0)
Sets the image side of the second image if used by VrMosaic.
Side -1=Auto,0=Bottom or Left,1=Top or Right
Example Line.SetSide2 (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 –1 then the original number is not changed
Example Line.SetPointFlags (PntNum, PenCode, ArcFlag, Code, BitFlags, MosaicWidth)
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
Example RetVal = Line.GetFkeyParams (“Pole”)
When a line is loaded, the workspace number in which the line was loaded from is stored in the object.
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()
When a line is loaded, its line number is stored in the object
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()
Returns the number of points on the line.
Returns 0-2,147,483,648 (memory permitting)
Example PointCount = Line.GetNumXyz()
Returns the layer of the line.
Returns Layer number (1-10,001). A return layer number that is 0 or less than 0 represents a deleted entity.
Example Layer = Line.GetLayer()
Returns the mode of the line.
Returns Line mode (1=Line 2=Splined line)
Example Mode = Line.GetMode()
Returns the graphic pointer of the line. The graphic pointer determines the graphic representation of a line such as a fence or a tree line.
Returns Line graphic pointer (1-1,000)
Example Gpoint = Line.GetGpoint()
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)
Example PenNum = Line.GetPenNum()
Returns the non-graphic pointer of the line.
Returns Line non-graphic pointer (-2,147,483,648 to 2,147,483,648)
Example Npoint = Line.GetNpoint()
Returns the link of the line.
Returns Line link (-2,147,483,648 to 2,147,483,648)
Example Link = Line.GetLink()
Returns the feature code of the line
Returns Line feature code (up to 48 characters)
Example Fc = Line.GetFc()
Returns the construction flag of the line. The display of lines that have their construction flags set to 1 may be turned off.
Returns Line construction flag (0-1)
Example Constr = Line.GetConstr()
Returns the width of the line. A line width defines the number of lines that will be drawn to the left and the right of the centerline. The distance between these lines may be defined in Vr Configuration.
Returns Line width (0-255)
Example Width = Line.GetWidth ()
Returns orientation of the line if used by VrMosaic.
Returns -1=Auto,0=Horizontal,1=Vertical
Example Orient = Line.GetOrient ()
Returns the image side of the first image if used by VrMosaic.
Returns -1=Auto,0=Bottom or Left,1=Top or Right
Example Side1 = Line.GetSide1 ()
Returns the image side of the second image if used by VrMosaic.
Returns -1=Auto,0=Bottom or Left,1=Top or Right
Example Side2 = Line.GetSide2 ()
Returns the point flags to a line coordinate. If the point number requested is out of range then 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
Example (p, a, c, f, m) = Line.GetPointFlags (PntNum)
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=Mid point 3=Point on arc)
c Code (0-255)
f Bit encoded flag (0-255)
m Mosaic width (0-255)
Example Line.AddPoint (x, y, z)
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, then the command is ignored.
PntNum Point number to store point after (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=Mid point 3=Point on arc)
c Code (0-255)
f Bit encoded flag (0-255)
m Mosaic width (0-255)
Returns 0=Ok -1=PntNum is out of range
Example Line.InsPoint (Pnum, x, y, z)
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, then the command is ignored.
PntNum 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=Mid point 3=Point on arc)
c Code (0-255)
f Bit encoded flag (0-255)
m Mosaic width (0-255)
Returns 0=Ok -1=PntNum is out of range
Example Line.ChgPoint (PntNum, x, y, z)
Returns a coordinate point from the line. If the point number requested is out of range then the coordinate position is returned as 0.
PntNum Point number to return (0-Line.GetNumXyz()-1)
Returns x, y, z (double precision)
Example (x, y, z) = Line.GetPoint (PntNum)
Backs the line up by deleting the last point on the line.
Returns 0=Ok -1=No more points
Example RetVal = Line.Backup()
Deletes a point from the line. If the point number requested is out of range then nothing is done.
Returns 0=OK -1=Point number is out of range
Example RetVal = Line.DelPoint (PntNum)
Deletes a group of points from a line.
Begin Begin line point number
End End line point number
Mode Delete mode
0=Delete points specified (default)
1=Move point range specified to the beginning of the line resulting in Begin and End
as first and last points on the line.
Returns 0=OK -1 Begin or end out of range or End is greater than begin.
Example: RetVal = Line.DelPoints (Begin, End, 0)
Prints the coordinate points on the line to the standard output device. This is useful when debugging.
Example Line.ShowPoints()
Reverses the direction of the line.
Example Line.Reverse()
Offsets the line by a defined distance. Line segment intersections are mitered.
OfsDist Offset distance in ground units
Example Line.Offset(12.4)
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
Example Line.Move (Dx, Dy, Dz)
Scales the line from the point sent.
PivotX Scale origin X
PivotY Scale origin Y
SclFac Scale factor
Example Line.Scale (x, y, 1.0001)
Rotates the line about the point sent.
PivotX Rotation origin X
PivotY Rotation origin Y
RotAng Rotation angle clockwise in radians
Example Line.Rotate (x, y, RotAng)
Mirrors the line in the X direction about a line point.
PntNum Line point number to mirror line about.
Example Line.MirrorX (PntNum)
Mirrors the line in the Y direction about a line point.
PntNum Line point number to mirror line about.
Example Line.MirrorY (PntNum)
Returns the length of the line.
Mode Length type to return 0=Slope distance 1=Horizontal distance
Returns Line length in ground units.
Example LineDist = Line.Length (0)
Returns the area of the line
Returns Area of line in square ground units. If the line is open it will be closed for the area calculations.
Example LineDist = Line.Length (0)
Returns the direction of the line.
Returns Line direction 0=Clockwise 1=Counterclockwise
Example LineDir = Line.Direction()
Returns the Z range of the line.
Returns Minimum and maximum elevation of the line.
Example (MinZ, MaxZ) = Line.ZRange()
See also Mbr()
Returns the XY MBR (Minimum Bounding Rectangle) of the line.
Returns Minimum and Maximum coordinates of the line
Example (MinX, MinY, MaxX, MaxY) = Line.Mbr()
See also ZRange()
Returns the mean azimuth of the line.
Returns Azimuth clockwise north up in radians
Example LineAzi = Line.Azimuth()
Returns the closest line end to the point sent.
X, y Coordinate position to check against line ends.
Returns Closest end 0=Beginning of line 1=End of line
Example NearEnd = Line.ClosestEnd (x, y)
Returns the closure status of the line.
Returns Closure status 0=Line is not closed 1=Line is closed
Example Closed = Line.IsClosed()
Returns the distance between the two endpoints on a line
Returns Distance in ground units.
Example Dist = Line.CloseDist()
Closes the line.
CloseMode Close method
0=Move endpoint onto start point
1=Mean endpoints.
2=Add line segment between endpoint and start point
3=Intersect end segments.
Example Line.Close (2)
Returns the closest line point number to the coordinate sent.
X, y Coordinate position
Returns Closest point line number
Example ClosePntNum = Line.ClosePoint (x, y)
Snaps the point sent to the line.
SnapX Coordinate X to be snapped to the line
SnapY Coordinate Y to be snapped to the line
Returns RetX = Return X coordinate transformed to line
RetY = Return Y coordinate transformed to line
RetZ = Return Z coordinate transformed to line
Dist = Distance from Snap coordinate to Ret coordinate
Example (RetX, RetY, RetZ, Dist) = Line.SnapPoint
(SnapX, SnapY)
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 Coordinate X to be snapped to the line
SnapY Coordinate Y to be snapped to the line
SnapZ Coordinate Z to be snapped to line. If zero is sent then the elevation will be interpolated.
p Pen code (0=None 1=Up 2=Continue 4=End)
a Arc flag (0=None 1=Beginning, end or PRC 2=Mid point 3=Point on arc)
c Code (0-255)
f Bit encoded flag (0-255)
m Mosaic width (0-255)
Returns Line point number of new point
Example NewPntNum = Line.SnapPointAdd (SnapX, SnapY,
SnapZ)
Adds a point to the line based on a distance from beginning of the line.
Dist Distance from the beginning of the line to compute point.
StoreCmd Store command 0=Do not store point on line 1=Store point on line
Returns RetX = Return X coordinate transformed to line
RetY = Return Y coordinate transformed to line
RetZ = Return 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 is not stored.
Example (RetX, RetY, RetZ, PntNum) =
Line.AddPointDist (Dist, 1)
Tests if the point sent is inside the line polygon. The line may be open; it will be closed for this calculation.
X, y Coordinate position to test
Returns 0=Point is not within line polygon 1=Point is within line polygon
Example Inside = Line.IsPointInside (x, y)
Plots the line to all open graphics devices. The current header parameters are used.
Example Line.Plot()
Erases the line from all open graphics devices.
Example Line.Erase()