March 24, 2015

Hyperlinks in ArcGIS for AutoCAD

Go figure. The morning after my daughter returned from a week-long class field trip to a winter camp she announced that she was a "vegetarian".  I was intrigued as I fished frying up a pan of bacon for breakfast and asked her to explain.  She said that she doesn't eat meat anymore.  As the bacon came out of the pan she was quick to add that she was a vegetarian; except for bacon…. and hotdogs… and …cheeseburgers.  I then asked if there was anything else, she said no, she doesn't eat any meat like fish, or other gross things.  But added, actually fish sticks are ok.
Sometimes the full meaning of GIS data is better found in another place and format, and a hyperlink on an AutoCAD entity is a good way to associate that data in ArcGIS for AutoCAD
If I have hyperlink locations already included in my ArcGIS feature attributes I can employ an advanced use of the ESRI_CALCULATEFIELD bonus tool to quickly associate the URL of my hyperlinks found in the attributes of my ArcGIS features and apply them to the associated entities as AutoCAD hyperlinks.  The ArcGIS field name containing my hyperlink is called URL in my example.  I am not actually changing the value of a field when I am using the ESRI_CALCULATEFIELD bonus tool (which is why I call this an "advanced" use of the tool, since it primary use IS to modify a field.)  I am arbitrarily specifying the "URL" field as the field I am modifying with the ESRI_CALCULATEFIELD command.  I am supplying the value of the [URL] field as the last statement in my expression so the URL field remains unchanged. 
What my AutoLISP expression does before that is to establish and AutoCAD hyperlink on each entity in my feature class because my expression invokes  the –HYPERLINK command and supplies the value of the ArcGIS attribute field value [URL] (from the URL field on each entity). 
My AutoLISP expression actually has four parts.  First it runs the PROG function that simply allows me to perform more than one AutoLISP statement as a single
expression.  Then the ESRI_CLEARSELECTION command to ensure the –HYPERLINK command processes one entity at a time.  Typically I don't need to clear the selection set to perform other AutoCAD commands in my expression, however in this case the AutoCAD –HYPERLINK command exhibits a different behavior/syntax when an existing selection set is active.
Next I include the –HYPERLINK command with its parameters that include the value of my url field designated with square brackets, [URL].  
Then finally the value of the [URL] field again all by itself.  Because this is the last statement of the AutoLISP expression, the current value of the [URL] will be returned by the overall expression which allows me to use the ESRI_CALCULATEFIELD to access and process entities using their feature attribute values, and still leave those field values unchanged.
This example assumes you are working with ArcGIS for AutoCAD and have downloaded and installed the ArcGIS for AutoCAD bonus tools.  It assumes you have valid hyperlink text values in a field called "URL" in the current ArcGIS for AutoCAD feature class :
I am not sure if there is an official classification for a bacon/burger/hotdog-eating vegetarian, perhaps someone could provide a link.
Example:
>Command: (load "afa_utilities")
AFA_ATTRIBUTE_SETVALUE

>Command: ESRI_CACULATEFIELD
("ANGLE" "REFNAME" "XSCALE" “URL”)
Enter the field name: URL
Enter a valid Expression (see documentation for syntax): (progn (command "ESRI_CLEARSELECTION") (command "-HYPERLINK" "Insert"  "Object" ESRI_CALC_ENT "" [URL] "" [URL] ) [URL])



4 Comments:

Blogger hlouie said...

Don will you be attending 2015 ESRI UC?

6:54 PM  
Blogger Don Kuehne said...

I will be attending the Esri 2015 Users Conference and AEC Summit and presenting at both. I hope to see you there.

11:42 AM  
Blogger andy zimmerman said...

Don, I apologize in advance for posting this question here, but I couldn't find a more appropriate contact for you. I work for an environmental consulting firm, and have been the GIS Manager for about 2 years. As a company, we have historically done most mapping in CAD but there has been more and more GIS/CAD integration lately. They saw the organization I brought to the GIS group, so they gave me the CAD group as well. I have no background in CAD, other than working extensively with the data in GIS. I'd like to learn as much as possible and I was wondering if you suggested any literature or courses (preferably online). I am about to enroll in a CAD 101 type course, but I'm specifically interested in CAD/GIS interoperability, CAD standards, and drawing in real world coordinates.

I've followed your blog since you started it, and I'm a big fan. Any guidance or words of wisdom would be greatly appreciated, as this is pretty daunting.

Thanks,
Andy Zimmerman
GIS/CAD Manager
EnSafe, Inc.
azimmerman@ensafe.com

9:25 AM  
Blogger Don Kuehne said...

My YouTube channel is another source for ArcGIS for AutoCAD and some other ArcGIS Desktop CAD interoperability that I also reference on this blog frequently. It is a broad topic. Esri's approach to CAD/GIS tries to keep things simple, so when approaching esri's version of interoperability a basic knowledge of plain vanilla CAD will get you a long way.

https://www.youtube.com/user/GISCADChannel

12:46 PM  

Post a Comment

<< Home

FREE hit counter and Internet traffic statistics from freestats.com