home products news downloads documentation support gallery online maps resellers search
TNTmips Downloads Menu

HOME

CONTACT US

CURRENT RELEASE
  TNT 2013

DEVELOPMENT VERSION
  TNT 2014

TNTmips Pro
PRIOR RELEASES
  TNT 2012

FREE SOFTWARE
  TNTmips Free
  TNTatlas
  TNTsdk

MORE DOWNLOADS
  HASP Key Driver
  Screen Recorder
  TNT Language Kits
  Sample Geodata
  TNT Scripts

DOCUMENTATION
  TNTmips Tutorials
  Tutorial Datasets
  Technical Guides
  Scripts
  Quick Guides

MORE INFO
  Download FAQs
  FTP
  Download Managers
  Find Reseller

SITE MAP


CAD.sml


# CAD.SML
# Sample script for tutorial "Writing Scripts with SML".
# Examples of CAD functions.

clear();

# Get input raster and find its geographic extents in map
# coordinates defined by its last-used georeference object.
class RASTER R;
GetInputRaster(R);
class GEOREF rGeoref;
rGeoref = GetLastUsedGeorefObject(R);
numeric xMin, yMin, xMax, yMax;
GetObjectExtents(R,xMin,yMin,xMax,yMax,rGeoref);

# Print raster georeference parameters to console.
printf("Raster coord system = %s\n", rGeoref.Projection.System);
printf("Zone = %s\n", rGeoref.Projection.Zone);
printf("Datum = %s\n\n", rGeoref.Projection.Datum);

# Compute geographic center of input raster.
numeric halfdX, centX, halfdY, centY;
halfdX = (xMax - xMin) / 2;
centX = xMin + halfdX;
halfdY = (yMax - yMin) / 2;
centY = yMin + halfdY;
print("Map X of raster center =",centX);
print("Map Y of raster center =",centY);

# Get new output CAD object and create implied georeference
# using parameters from input raster.
class CAD CADout;
GetOutputCAD(CADout);

class GEOREF georefC;
CreateImpliedGeoref(CADout,rGeoref.Projection);
georefC = GetLastUsedGeorefObject(CADout); 

# Add circle to CAD centered at raster center and
# tangent to closest extents boundary.
numeric radius;
radius = SetMin(halfdX,halfdY);
CADWriteCircle(CADout,1,centX,centY,radius);

# Add line to CAD from center to edge of circle at -45 degree angle.
numeric addX, addY;
addX = radius * cosd(-45);
addY = radius * sind(-45);

array numeric xpoints[2];  # arrays for line vertex coordinates.
array numeric ypoints[2];

xpoints[1] = centX;				ypoints[1] = centY;
xpoints[2] = centX + addX;		ypoints[2] = centY + addY;

CADWriteLine(CADout,1,2,xpoints,ypoints);

# Add box to CAD with lower left corner at center
# of circle, 2000 m X 2000 m.
CADWriteBox(CADout,1,centX,centY,centX+2000,centY+2000);

# Add identical box rotated 180 degrees.
CADWriteBox(CADout,1,centX,centY,centX+2000,centY+2000,180);

# Read coordinates of lower left and upper right corners
# of box and print to console.
numeric lastelem;
numeric lowerleftX, lowerleftY, upperrightX, upperrightY, rot;
lastelem = CADNumElements(CADout,1); # number of last-added element.
CADReadBox(CADout,1,lastelem,lowerleftX,lowerleftY,upperrightX,upperrightY,rot);

print("Coordinates of rotated box:");
print("Lower left corner X:" ,lowerleftX);
print("Lower left corner Y: ",lowerleftY);
print("Upper right corner X: ",upperrightX);
print("Upper right corner Y: ",upperrightY);

CloseCAD(CADout);








Back Home ©MicroImages, Inc. 2013 Published in the United States of America
11th Floor - Sharp Tower, 206 South 13th Street, Lincoln NE 68508-2010   USA
Business & Sales: (402)477-9554  Support: (402)477-9562  Fax: (402)477-9559
Business info@microimages.com  Support support@microimages.com  Web webmaster@microimages.com

25 March 2009

page update: 26 May 11