|CAD Transformation Toolbar
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 extentFlip 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:
- 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).
- 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.
- Turn on the CAD Transformation toolbar.
- 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
- 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.
- Apply some of the other buttons on the toolbar to reposition your CAD file accordingly.
||Form containing the tool icons.
||Basic module for dimensioning global variables and housing key routines.
||Class containing the toolbar definition.
||Class containing the extension that controls the toolbar.
||Class defining the options on the CAD Transformation pulldown.
||Class containing code for the buttons on the pulldown menu.
||Class defining the options on the Flip/Rotate pull right option.
||Class containing the code for the Flip/Rotate menu.
||Class defining the combo box containing the available CAD layers in the map.
||Class containing the Link Tool code.
||Class containing the Rotate Tool code.
||Class containing the Scale Tool code.
||Class containing the Shift Tool code.
CADLayer, CADFeatureLayer, RotateTracker, ScaleTracker, SelectionTracker
ICadTransformations, IRotateTracker, IScaleTracker, ISelectionTracker
ICadTransformations::TransformMode, ICadTransformations::SetFromToTransform, IRotateTracker::AddGeometry, IRotateTracker::Angle, IScaleTracker::AddGeometry, IScaleTracker::ScaleFactor, ISelectionTracker::Geometry