Archive for the 'Tips or Trick' Category

Plain Text from Object Data

Have you ever imported ESRI SHP files or other GIS files and need to create some simple text labels for that data? Do you have some object data attached to entities that you now need to display that data in the drawing? One method of displaying or labeling those entities is by using Map Annotation Blocks or use FDO. But what if you need something quick and as plain text?

I see questions on how to do this or can Map3D do this. Yes it can be done. You can use the Map3D display manager to query the current drawing then create a “Map3D” text style in the display manager.  

So lets look at the drawing I have for the example.

OD_Info

It’s a simple parcel map imported from an SHP file and object data was created on the import. What I need is to label each parcel  from that object data with the Watershed1 value.

The first step is opening the Map3D Task Pane and using the Display Manager tab. If the task pane is not open use the command MAPWSPACE and select ON at the command line.

Add_Layer

Now click on the Data icon in the display manager, scroll down to “Add Drawing Data”  then select “Query Current Drawing”

The Define Query dialog will open allowing you to define the query. I want to query on my object data so I select “Data” for the query type. The Data Condition dialog will open allowing me to select the data to query on. I select “Object Data” make sure I have the correct Table listed (Parcels), select the field I want the label to display (Watershed1) then for the Operator and Value I use = (equal sign) and * (the wildcard expression).

query

As soon as I click OK it populates the upper part of the Define Query dialog. Clicking OK in this dialog takes me back to my drawing.

I now have a new object or a Map3D Display Manager Layer listed in the Task Pane.

new_Layer

The next step is to add  a text style to display the text that is being queried in on that new layer. TIP: When we say Layer in Map3D Display Manager it is NOT an AutoCAD layer and has no relationship to the layer manager or any of the AutoCAD layers.

To create our text style for our data labels we right click on the layer name in the Display Manager and select “Add Style” then “Text”.

Add_TextStyle

We now have another object in the Display Manager under the “Current Drawing Element” layer named “Text Style”.  Highlight the “Text Style” in the Display Manager and look at the properties of it in the property palette. (Right Click and select Properties to open the property palette.)  This is where we tell it to display the values from the Object Data table.

Select the Value- Text Label to show the ellipsis icon (the 3 dots) Click on the icon to open the Expression Chooser. 

TextStyle_default

In the Expression Chooser, expand the tree to get to the Object Data field to label from. Select the field and click OK.

expression 

Back it the Property Palette set the Height as needed and any other property you wish. Notice I changed the Height to 10 and provided a better fitting name for the text style.

Text_Final

Notice as you start to make changes in the property palette for the Text Style the labels change instantly allowing you to see the changes as you make them.

Labed_Drawing

Now back in the drawing we have labels for all of the parcels and they are plain AutoCAD text objects. No FDO text style, no Civil3D label and no Map Annotation blocks.

Using AutoCAD MAP3D Document View

As promised here is a sample of using the Document View functions in Map3D. To set the stage for this we set the scenario as so. We GPSed the utility power line with a handheld GPS unit. As we GPS the pole we also took a picture of the pole, we tag or named the image file the same as the pole number. When we got back into the office we downloaded the images into their own folder on the server alone with the GPS points and data we collected in the field. We then imported the points and created the object data tables from the point data. So now we want to link those images to our points or poles block in the map so as we click on a pole we can view the photo we took in the field.

This is a good example of using the document view tool. The first step is making sure the OD table has the correct information and fields in it and that the images are in a folder that we can get to.

OD_Table

Image_Folder

Looking at my example we see the OD table has a field value that matches the image file names.

Once those two steps are complete we have to define the Document View. In order to do this we need to be in the Classic Map workspace. Looks like whoever created the default Ribbons for Map3D forgot these commands or thought we didn’t need them. Using the Map menu pulldown select the Define Document View from the Object Data section.

menu

In the Define Document View Dialog (Yes the old style dialog that you can not resize) We set up the parameters Map3D uses to open/display the images.

Define

1. Give the definition a name and description.

2. For the expression in my example I use the PoleNumber field from my Pole_No_OD Object Data Table. You can use the Expression button to browse and select your expression. (Do not confuse that with the FDO expression builder)

3. Select the folder where your documents are stored, you can use the browse button to get to it.

4. Type in the file extension for the type of document you want to view. In my example its jpg but you can also use word documents or (almost) any type of document to view.

5. Next you need to provide the command line for the application used to open and view the documents. Again use the browse button and browse to the exe file that will open the document. With my example and images as my documents I selected my installed IrfanView application, I could used Paintbrush as well but I like the speed of IrfanView.

6. Click the ADD button to add it to the list at the top.

Now the Update button is nice if you need to go back and change one of the parameter. Nice to have for the first few tries, you do not have to start over if something does work the first time, edit and update.

Now that you have the document view defined, to use it select the View Associated Document from the Map menu Object Data section and select the object with the OD table attached. If everything works you should have that document open up in it’s own application.

 

The sample in action.

Greek or Nerd (Using links in OD Tables)

To start I’ll say I’m one of those geo-cache hunters that spends my free time looking for Tupperware hidden out in the woods using million dollar satellites. If you don’t know what a geocaching is here is a link. So thinking I would tie it into AutoCAD MAP3D and have a little advance over the next guy, I like viewing those little hidden treasure location in a map and see them all at once and in relation to each other.  As doing so I figured I would share a little solution that many Map3D users have asked over the years. That is how can I open a hyperlink from my data.

To start here’s a look at my map and the object data I have attached to my geocache points.

OD_Data

The points are the standard AutoCAD points with object data attached. The data contains a field with a value to a web site page. So how can I open the web page up to view it with out the old copy from the OD table and open my web browser and paste the value into it. Simple. Just use a little lisp routine that I’ll show you how you can customize to fit your Object Data table and fields names.

Here’s my version of the lisp file;

(defun c:FL (/)
  (setq ent (car (entsel “\nSelect point to follow link”)))
  (setq link (ade_odgetfield ent “waypoints” “url” 0))
  (command “Browser” link)
)

All you need to do  change the table name and field name to meet your meets. In my sample my table name is WAYPOINTS and field name is URL. Just write your lisp file with those changes after the (ade_odgetfield ent in line 3 of my example. Save the lisp file, load it in your drawing, then use the command FL to Follow your Links.

Now if you need to link to a image file or another file on your network I will post about using the object data document view tools that works for those later.

A quick video of it in action.

AutoCAD Map3D 2011 and Raster Design OE

Anyone that uses MrSID image files in their Map3D or Civil 3D know that you  need to install the Raster Design Object Enabler or Raster Design installed to insert them with the Map image insert command. Problem is right now there is no Raster Design OE for the 2011 versions. However thanks to a geeky customer there is a work around.

The first step is you need a working version of an AutoCAD 2010 installed on your workstation. This can be Map3D, Civil 3D, Standard AutoCAD of the vanilla favor or even the water down application named TrueView. Now if you are running on a 64bit OS I was told you can skip the 2010 products but with a 32 bit OS you need one of those install.

Next download and install the 2010 version of the Raster Design OE. Located here http://usa.autodesk.com/getdoc/id=DL13023431. A reminder you need administrator rights to install it and follow the standards to install any of AutoCAD applications, in other words shut down any apps you have running and shut down you anti-virus software for the installs.

The next step is you need to open the windows registry. To do this the simple way is from the START button > Run and type in regedit for the “open”  then click the OK button. Now a disclaimer, if you don’t feel comfortable working with the registry then call some that does. Do not blame the Murph if your PC starts to act up later because you messed up the registry.

With the registry open navigate/browse to the

“HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R18.0\AdImaging” 

key. Select it, right click, and select Export. Save the exported registry key to a folder that you can get to, the name for it can be any name of your choice (provide you follow the naming convections enforced by Microsoft).

export_key

Now browse to the folder you saved the exported key to and open it in a text editor (Notepad works best). With the file open edit the first line (not the top header line) so it reads as 

[HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R18.1\AdImaging]

Just change the R18.0 to read R18.1. Save the file and close it.

regedit

Next step is to double click on the file in Windows Explorer. This will import the registry key into the registry.  If you get the Warning Message / Registry Editor

warning

just click the OK button.

Now if everything worked you should be able to open up Map3D or Civil 3D 2011 and use the Mapiinsert to insert a MrSID format image into you projects like you could before.

NOW A BIGGER DISCLAIMER(s):

First this is a hack to get the SID files in the 2011 versions, it is not supported by Autodesk so if something goes wrong don’t expect help from your support team. Second anyone that knows what all those numbers mean in the registry will see that the imported registry key is for the 2011 version but still points to 2010 Raster Design OE, if you try to install the supported version of Raster Design OE when it gets released you may get the message saying it is already installed. You may have to delete that key for the official supported version to install and work properly .

AutoCAD Menus and stuff….

I got a few questions from users on how to make AutoCAD MAP 3D users interface look like standard AutoCAD. I normally just create a new workspace and set the menus and toolbars that I need or use the Map Classic workspace. But that may not work all the time for all the users as easy as it seems. So thankfully Michael Schlosser, an Autodesk employee came up with a easy way to load the AutoCAD menu in Map3D and blogged about it in his blog GeoExpressions he even links to a video on how to do it. So for the Map 3D user that needs to work as an AutoCAD user take look.

Do you leave your car running all day long?

You do not drive into work every morning, park your car (SUV, truck or Harley) in the parking lot running all day long knowing you may want to drive it to lunch or when it comes quitting time back home. You don’t think that if you leave it running  it saves you a few seconds of having to start it up again and warm up before you put it in drive to drive off do you? OK so it would be nice this time of the year to go out and get in a nice  warm vehicle when we head home for the day. Or for those in the southern hemisphere  a nice air conditioned vehicle this time of the year. No, we do not do that or think about doing that because we know the risk involved of not only wasting fuel and adding to  global warming but we also know we may not have a car sitting there waiting for us when we come out to drive off.

So why would would you do that with your AutoCAD software? I’m talking about users that come in to work and start up their computers start AutoCAD thinking they may need to open a drawing some time during the day. Sure the first time you start up AutoCAD it takes a few minutes to load and you have to wait especially if you do not have an optimized workstation.  But, do you know it is wasting resources sitting there minimized to the taskbar while it is not being used? Just like leaving your car idleing all day long it’s is not only using fuel but the power steering pump is keeping the fluid pressure build up, the oxygen sensors are still sending readings to the on board computer, the fuel gauge, oil pressure gauge are still using resources, the tachometer is still reading the RPMs of the engine. All that and more is happening because you do not want to wait for your vehicle to warm up at quitting time. Sounds a little dumb doesn’t it? Well the same thing is happening to your computer when you have AutoCAD running and minimized. All the functions inside AutoCAD are sitting there running, the operating system is sitting there listening for a mouse click wondering if your are wanting to issue a line command in AutoCAD or read some email. All those support folders on the server are getting pinged making sure they are still connected, all those connections to the printers are still connected, and more.

So what does all this mean? It means when you do get ready to open a dwg file in AutoCAD that it (AutoCAD) already has taken up a lot of those resources and you may get those Fatal Errors or out of memory errors. Prior versions of AutoCAD are know to have memory leaks or hoard memory that it is not using causing errors or other issues when you do try to use the program. The fix for it short of upgrading to a more powerful workstation is do not open AutoCAD until you need to use it, if you have been running AutoCAD for a few hours then close it out and reopen it after a few minutes, give it time to release some of those resources. A few minutes of waiting for AutoCAD to open is better than a few hours of complaining to your IT, boss or your software support team.

Points to Blocks

With the survey tab of the map task pane we can bring points into a map and style them with our blocks to get the look that we may need, or when we import a point type shape file or any other format we can assign a block to the points on the import. (provide block name matches the attributes) But what if you have existing drawings that you have been using for the past few years that have AutoCAD points or they are standard AutoCAD drawing, or from some one else. ? What is the easy and quick way to insert blocks at those points? Well if those points are on there respective layers the Display Manger maybe the quick and easy way. Here is how.

Looking at my sample waterline map we have points that represent wells, both active and abandoned that reside on their own layers. 

points

First we start by creating a few new “Map Layers” in the display manager. To do this switch to the Display Manager tab, and select ” Add Drawing Data > Drawing Layer”. 

AddDWGLayer

Select one of drawing layers the points reside.

Layer1

Then click OK, we want to create the map layers separately so when we assign a block to the points we can control what blocks goes to what points. repeat to create all the new map layers as needed.

 

mapLayers

Once we have the map layers created we style them with a symbol by right clicking on the map layer and select “Add Style > Symbol”.

AddStyle

The symbol used is a default symbol of a square with and X inside it. To change it to the block we want we select the “Symbol Style” element in the display manager under the map layer and select properties.

StyleProperties

In the property palette for that element we chose the block to use for that map layer.

SetBlock

You can also set the scale of the block to your scale, leaving the scale at the default of (* 20 (VIEWSCALE)) will scale the block 20 times the view scale. The default scale will scale the block up/down as you zoom in and out of the drawing and regenerate. Change the name of the element to represent the blocks. Repeat the steps for the remaining map layers.

To go a another step further in the display manager we can change the symbol shown in the display manger and for a legend if you decide to create one later on.   Do this by selecting the map layer in the display manager and go to it’s properties in the property palette.

setSymbol_legend

 

In the property palette, change the Thumbnail Preview to Block and select your block.

Thumbnail LegendBlocks

Repeat for your remaining map layer.

Now your points display as your blocks.

blocks

If you need to share the map to standard AutoCAD users you can use the tool icon and Save Current Map to DWG.

The Sample Folder or A Few LISP Files to Use

When was the last time you looked at the files in the Sample folder that gets created in the Program Files/ AutoCAD Map3D 20xx ? If you have not looked in years then let me point out a few lisp files (.lsp) that are there and may be of some use to you. Some of them are just samples and meant to be samples of what you can do with lisp programing and Map3D, however there are a few that you may want to use once in a while.

The first one I like is the makegrid.lsp.  What this does is create a grid from rectangular polylines with numbers/text inside each rectangle. It allows you to select the base point for the grid, the number of rows and columns and the size of each. With the number inside the rectangles it allows you to add a prefix and the number of digits for the number. So what do I use it for? A number of different uses but one is for creating a grid for a mapbook. Other times I may use it to create a grid if I’m creating a new line type or AutoCAD shape. Having a grid of 1×1 makes it easy to know when and where my pen up or pen down will be writing out the file.

The next one I like and use every once in a while is the copy_OD.lsp. This allows you to copy object data from one object to another. If you ever exploded a multi-segment pline to individual lines you found out the OD attached doesn’t get copied. This sample allows you to copy that OD to each line segment afterwards.

The listpt.lsp writes out the vertices of a polyline to the command line. If you use it notice it has the points inside parenthesizes  ( ), this is an “Autolisp list” but you can still it if you need to check the vertices of a polyline.

Need to see what direction an object  is going or where the start point is? Then the dirarrow.lsp is what you need to use. This sample will show a directional arrow pointing in the direction the object (Lines, Plines, Arcs) is headed. The sample uses the grdraw function which draws the directional arrow on the screen and not in the dwg file, A regen or redraw action removes the arrows from the screen.

If you are not familiar with using a lisp file with these you can drop and drag them from windows explorer into the AutoCAD editor window and the command to use them is printed to the command line. Done of them have a fancy dialog box or any help files on using them remember they are just samples but you might find some use for them. Or if you like to get into learning lisp they make  a good starting point. 

Transparency of Images

If you tried to set an image transparent with the normal transparent tools you found out it only works with one color. If fact all it does is turn off that color you select and is not really making anything transparent. Transparent as defined by Merriam-Webster is “fine or sheer enough to be seen through”. There is no see though when you just turn off a color. Using the data connect with FDO we can make polygon features transparent should we be able to do the same for images? Well we can with a little trick.

First we need to use the data connect to add the image to our map. Then save the image layer to “LAYER” file. When you save the layer it creates a file with an extension of layer,  If you are not aware of what a layer file is, it’s an xml file that contains information on the data file as to how it is connected to the map, the data it contains (spatial & data),  and how it is displayed or theme. Once you saved the image file to a Layer remove that image layer from the display manager and disconnect from the file(s) in the data connect palette.

Now browse to the image.layer file you created and open it in “Notepad”. Scroll down until you see the tags;

 “<FeatureName>rasters:Name</FeatureName>”  “<Geometry>Image</Geometry> “

Now insert between the two tags

<Opacity>0.5</Opacity>

layer_edit

Save the file after you edited it. The number 0.5 is the amount of transparency with the larger the number the more transparent the image will be. 0.9 is almost translucent and 0.1 is of little transparency. Now use the Load Layer tool from the Data Icon in the Display Manager to add the image to the map.

So why would anyone need an image to be transparent to start with when we can place it at the bottom of the draw order and make all the other layers transparent?  First off, how often have you reopened the map to find out the draw order was not as you had it set when you closed the map drawing? Another reason you may want to set an image to be transparent would be if you have overlapping images in the map. Maybe you have an current aerial image and an aerial of the same are that is 10 yeas ago and you need to do a time lapse study of the area. Toggling the images on and off can get frustrating after a while, where as having one transparent will allow you to see though it to do the analysis a lot easier.

Here are a few before and after screen captures of the results.

Normal 

How we normally do it with the image layer at the bottom of the display draw order and the polygon with transparency.

image_Transparency

Here is with the image with transparency at 0.5 and the image layer at the top of the display draw order.

closer_look

A closer look of the above. Notice how the street centerlines show though the image file.

If you look close enough you will see a grid pattern in the image after we make it transparent, I only guess that is the way Map3D renders the image but after a test print of the map the grid is not getting plotted so I see no harm in it being there. Also do not forget about the MAPPLOTTRANSPARENCY command if you want to plot with transparency.

Negative Buffer Values

A while back the question came up if anyone used negative values to create a buffer in another forum. I thought WHAT? Most of  the buffers I create are with point or line type objects, if you do a -10 distance buffer of a point or line object what do you get? Nothing! However you can create a negative buffer from a polygon object. Michael Schlosser from  the Autodesk north of the border team shows how to use it and provides a good example of why you might want to here on his blog.


Archives

Readers Locations

Top Rated posts

Chat room


Follow

Get every new post delivered to your Inbox.

Join 30 other followers