Monday, January 10, 2011

Custom Line Types with Data Connect

A number of users have been asking about using custom line types in their maps with features from the data connect, both in the AUGI forums and the Map3D Discussion Group. I would answer with a yes BUT replied. Why? Cause it’s not as simple as loading a lin file like you can with AutoCAD objects then set that object’s layer to use those line types from that lin file. So can it be done? YES. Here’s how in some simple as I can make steps. It takes a little preplanning but here is what I want to do in my example.
I have a SDF file (line type) that represents a 3 phase electrical power line, I want to display it with 3 vertical tic marks (perpendicular).
3Phase_Standard
The original display.
  • First enable enhanced stylization in Map3D.
  • Add your feature data (line type) using the enhanced stylization.
  • Save that data layer to a layer file.
  • Edit the layer file.
  • Then add that layer file back into your map.
So to start we need to edit the windows registry to enable the enhanced stylization. To do this edit the key in the registry named;
“KEY_CURRENT_USER\Software\Autodesk\AutoCAD\R18.0\ACAD-8002:409\Applications\AcMapDataConnectUI”  Note: the numbers may vary depending on the version of Map3D or Civil 3D you are using.
Set the value to 1 to enable it.
Next open up Map3D and make the connection to the SDF file, but instead of using the Add To Map or Add to Map With Query , we now have an additional  option “Add to Map with Enhanced Style”.
AddToMap
Add the SDF data with the Enhanced Style option. Notice if you try to style that SDF layer using the normal style editor you will see that everything is grayed out and you can not change how it is displayed, add a scale range or create labels . As of right now there is no graphic users interface (GUI) to edit it.
Next step is to save the SDF layer out to a layer file. Right click on the layer in the display manger and select Save Layer.
SaveLayer
Save the layer to a location you can get to easily for now while you are experimenting with this and give it a new name.
SaveLayerAs
  Now remove the SDF layer from the Map display and disconnect from the SDF data file.
Next we start to edit the layer file we just saved, the layer file is in xml format and we can open and edit it with Windows Notepad. I suggest users stay away from some of the XML editors out there and edit with Notepad. With the layer file open scroll down to the line:
<Geometry> M 0.0, 0.0 h 4.0 </Geometry>
Layer
This is where we start editing the file. The geometry tag is telling Map3D how to display or draw the line for this data feature. It starts at 0,0 and draws a straight line 4 units horizontal. The syntax is a little different than what you use in creating a line definition for a lin file, but the same principal. The “m” stands for move to  0.0,0.0. It is the coordinate to start drawing the line at. The next part is “h” for a horizontal line then the 4.0 is for 4 units. That is all, a simple straight horizontal line 4 units long. What I want is a line with 3 vertical lines in the center of it.  First I change the 4.0 to 10.0 to make my line longer so the vertical lines are not too close to the end points.  Next I use the “m” to move to a new starting place of 4.5, -0.5, or 4.5 units to the right of the starting point of the line and 0.5 units under the line. Now I tell it to go vertical one unit up by using “v” 1.0. That draws the first vertical line one half of  a unit left from the center of the horizontal line up one unit. Next I use M 5.0, –0.5 V 1.0 for the second line and for the last line M 5.5, -0.5 V 1.0.
Edits
If you notice my screen capture of the edited file I formatted it to make it easier to read and edit, that’s what I like about Notepad other xml editors may give you errors when you try it this way.
Now there’s one other edit we need to make to get this new line to look right, I changed the length of the first horizontal line from 4 units to 10 units. So I need to change how often the line repeats though out the line segments in Map3D. Scroll down to the <Repeat> 4.0 </Repeat> tag and change the 4.0 to 10.0. I also changed the color to a red tint, the color tags <Linecolor>xxxxxxxx</Linecolor> uses a HEX value so if you need to change the color you need to know the HEX color values.
Edits_2
There is my editted layer file, now save the file and drop and drag onto the display manager or load it into Map3D with the load layer command. The results look like this:
OurStyle
The edited display.
So there you have it, custom line types for a data connect line feature. But don’t leave yet there’s more to follow in the next few weeks, not only can we create lines types like above we can create custom point markers or use a point marker in a line definition or create flow arrows in your lines and how about depression marks for contour lines?  More to come and if you try this you may notice your lines features may need some more editing to get them just right.

No comments:

Post a Comment