CAD Transformation Toolbar

Created:7/20/2001
Description:

When CAD files are added to ArcMap they are not necessarily in the same coordinate space as the rest of the data being used. To solve this problem the Transformation tab on the Properties dialog of the layer can be used to add transformation information. The code in this sample provides tools to accomplish the same thing as the Transformation tab in a more automated fashion. Tools for repositioning the CAD file include: fit to display, rotate, scale, shift, and add links. Rubbersheeting or warping of the CAD file is not currently possible, so only two links can be added for repositioning the file. Once the desired transformation has been achieved, the results can be applied to the other CAD layers in the map or saved out to a world file.

Options on the toolbar include:

  • Fit to Display - Moves the CAD file into the current map extent
  • Flip Horizontal - flips the image on a horizontal plane (since you can only have two registration points, the results aren't great)
  • Flip Vertical - flips the image on a vertical plane (since you can only have two registration points, the results aren't great)
  • Flip Vertical - flips the image on a vertical plane (since you can only have two registration points, the results aren't great)
  • Rotate Left - rotates the file 90 degrees to the left.
  • Rotate Right - rotates the file 90 degrees to the right.
  • Delete Control Points - remove any links that may have been added with the Link Tool (does not reset the transformation, though)
  • Reset Transformations - removes any transformation that may have been set for the file.
  • Apply to All - Apply the current transformation to all other CAD files in the map (be careful with this one).
  • Save World File - Writes out the current transformation to a *.wld file based on the name and path of the file being transformed. The next time you add this CAD file to the map, the world file will be used automatically.
  • Rotate Tool - Interactively rotates the file. Pressing "a" when this tool is active allows you to type in a relative angle. Rotation is based on the centroid of the current extent of the file unless a link has been added (in which case the To point of the link is used as the rotation anchor).
  • Shift Tool - Interactively pans the file.
  • Scale Tool - Interactively scales the file. Pressing "s" or "f" when this tool is active allows you to type in a scale factor to use. Scaling is based on the centroid of the current extent of the file unless a link has been added (in which case the To point of the link is used as the scale anchor).
  • Link Tool - Allows the user to interactively add links for transforming the file. The first link will move the file based on the from and to points that are specified. Adding a second link will cause the file to be scaled and rotated so that the from and to points of both links match.


  • How to use:
    1. Register the TransCadExt extension class under the ESRI Mx Extensions category using Categories.exe (browse for the Component Category Manager topic in the Developers Help if you need more information on registering an extension).
    2. Browse and select the file TransCadBarPrj.dll using the 'Add From File' button on the customization dialog. This will add a new toolbar and a set of tools to ArcMap.
    3. Turn on the CAD Transformation toolbar.
    4. The name of the first CAD file in the map will display in the combo box on the toolbar. If you don't have a CAD file in your map then you will need to add one. Change the name of the selected CAD file as necessary. The file selected in the combo box is the one that will be transformed.
    5. In most cases you will need to being the transformation be repositioning the CAD file within the extents of your other data. To do this zoom/pan to an appropriate area and select the "Fit to Display" option from the CAD Transformation pulldown.
    6. Apply some of the other buttons on the toolbar to reposition your CAD file accordingly.
    
    Application:
    ArcMap

    Requires: CAD layer

    Difficulty: Advanced


    Visual Basic
    File Description
    frmResources.frm Form containing the tool icons.
    modUtils.bas Basic module for dimensioning global variables and housing key routines.
    TransCadBar.cls Class containing the toolbar definition.
    TransCadExt.cls Class containing the extension that controls the toolbar.
    TransCadMenu.cls Class defining the options on the CAD Transformation pulldown.
    TransCadPulldown.cls Class containing code for the buttons on the pulldown menu.
    TransFlipRotMenu.cls Class defining the options on the Flip/Rotate pull right option.
    TransFlipRotPulldown.cls Class containing the code for the Flip/Rotate menu.
    TransLayer.cls Class defining the combo box containing the available CAD layers in the map.
    TransLink.cls Class containing the Link Tool code.
    TransRotate.cls Class containing the Rotate Tool code.
    TransScale.cls Class containing the Scale Tool code.
    TransShift.cls Class containing the Shift Tool code.


    Key CoClasses: CADLayer, CADFeatureLayer, RotateTracker, ScaleTracker, SelectionTracker
    Key Interfaces: ICadTransformations, IRotateTracker, IScaleTracker, ISelectionTracker
    Key Members: ICadTransformations::TransformMode, ICadTransformations::SetFromToTransform, IRotateTracker::AddGeometry, IRotateTracker::Angle, IScaleTracker::AddGeometry, IScaleTracker::ScaleFactor, ISelectionTracker::Geometry