Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Monday, 18 April 2011

Civil3d Quick Pipe Edit

Coming up on almost 2 years ago Christopher at Civil3dReminders wrote some code to have the start, end and slope information of pipes displayed within Civil3d using the TransientGraphicsAPI.
I have extended Christopher’s code below in order to create a Quick Pipe Edit (QPE) command along the lines of the built in featureline Quick Elevation Edit command available in Civil3d.   
To use the code download the compiled dll from here https://sites.google.com/site/c3dxtreme/home/PipeSample.dll?attredirects=0&d=1
or source code from here and compile it
https://sites.google.com/site/c3dxtreme/home/Pipeedit-V1.zip?attredirects=0&d=1

1. Type Netload at the commandline browse to and load the download project .dll
2. Type QPE at the command line.
Note: Using this command may trigger event viewer to stop the event viewer displaying see the post have http://caddmando.blogspot.com/2008/12/turn-off-event-viewer-in-civil-3d.html
3. Hover the cursor near the start, end or centre of the pipe you want to edit.
4. Information on the specified location is displayed.
5. DoubleClick the mouse button to edit the displayed pipe information.
Note: The slope is always back calculated from the start invert and the end invert adjusted accordingly.
6. Once you have finished type QPEE to end the command and remove the events handlers
The code works as demonstrated in the following screen capture.
Unable to display content. Adobe Flash is required.
Being version 1 of the code  it has limited error trapping and it works for me but is not perfect so use it at your own risk. 
My ultimate goal was the mimic the behaviour of the featureline Quick Elevation Edit command. However I have fallen short in a number of areas.
1. To edit the pipe information a doubleclick is required instead of a single click.
I have not been able to find out now to capturer the event when the user just clicks the left mouse button once. According to the online help there is no leftclick event exposed
http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer%27s%20Guide/index.html

I have in the past used an operating system hook to capture the Mouse Click Event similar to the process documented here
http://www.vbforums.com/showthread.php?t=358556
but there must be a simpler way with .net now.
2. The pipe information is displayed as text in the drawing and not next to the cursor.
I found a code example here how to do it in C# with and undocumented API call and managed to get it up and running but it needs more work and I would like to convert all the code to vb.net instead of having to reference a separate C# .dll with the code
http://forums.autodesk.com/t5/NET/Dynamic-Input/td-p/1339772
While researching this issue I initially thought I had to display the information in the tooltip. But a tooltip only displays the information temporarily. Here are some links I found on adding information to the tool tip for reference anyway.
http://through-the-interface.typepad.com/through_the_interface/2009/07/providing-information-on-autocad-objects-in-a-tooltip-using-net.html
VB.net version
http://forums.autodesk.com/t5/NET/Pointmonitor-for-VB-net/m-p/2891662/highlight/true#M22368

3. You have to end the command by firing another command to remove the event handlers in use.
The initial command sets up a number of event handlers these need to be removed with you are finished with the code. You should be able to use another event like endcommand or esc key press to target a rountine to close the event handlers automatically but I do not know how to implement this at this stage.

Any feedback/comments on how I could implement these changes would be appreciated.

Wednesday, 13 April 2011

Back from the Pacific

Just returned from a 2 week break in Rarotonga at the beautiful
PacificResort attending my sisters wedding and revisiting the island my wife and I got married on almost eleven years ago with the Kids. So no I was not allowed to take my laptop.

I did however pickup a couple of computer books on root at Border’s book store in Auckland at their big non-fiction clearance sale to read on the plane.

Publishing a blog with Blogger
This is a pretty straight forward text that shows you how to do pretty much everything with blogger. I would recommend it for anyone wanting to start up a blog with blogger. I use blogger with Windows Live Writer 2011 which I have found to be a great mix for publishing information to the net simply and easily.

Head First Object-Oriented Analysis & Design
Picked up this book in an effort to improve the structuring of my code so it is organised in a more object oriented way to enable more efficient reuse of sections of code I have written. Although written for Java it provides great tips in an interested writing style.

Monday, 13 December 2010

A little LSP selection Gem for Civil3d that keeps on giving

I wrote this little bit of lsp code way back in 2008 for the quick and easy selection of civil3d objects, before the “Select Similar” and “Select Object” functionality was introduced to Civil3d under right click on the shortcut menu in drawing space and prospector. 
However these commands have not made this code redundant, it just seems it keeps on giving time and sums up my core philosophy to using Autocad and Civil3d. If I can, I will find a quicker way.
Basically the code was born back in the day thru the frustration of having to use the “qselect” to find those pesky little diamond grading object markers in a drawing and the amount of time and clicks that it took to rebuild the same selectionset over and over again to find the little things and check if you were in the drawing or the grading in the drawing was corrupt.
Here are examples of the commands I use most frequently and how I use them in my workflow to save time.
  1. SelectGrading = SG , Type SG finds all the grading objects in a drawing. Right Click select Object View and there’s my model
  2. SelectFeaturelines = SF, Type SF and find and select all featurelines
  3. SelectAlignments =SA, Type SA select all alignments, Bring Alignments to the front, Make all Alignment Styles the same by pressing Ctrl+1 and changing the style in the property windows.
One advantage of this routine has over Select Similar is all similar Civil3d Objects in a drawing are selected even if the object styles are different. Unable to display content. Adobe Flash is required.
The code consists of 10 simple lines of code as follows:-
;************************************************************************************* ;this routine selects all the alignment objects is a drawing ;saves having to use the qselect command and clicking three or four times
(defun C:SELALIGNMENT () (ssget "_X" '((0 . "AECC_ALIGNMENT"))) (setq sset (ssget "P"))   (if sset     (progn       (sssetfirst sset sset)       ;(command "_.PROPERTIES")     )   ) ) (defun c:SA () (C:SELALIGNMENT))
;************************************************************************************** You can create more Civil3d and Autocad object selection commands by copying the block of code above and say if you were wanting to select Parcels select a parcel in a drawing and list it image  In the first line of the list you get the object type “AECC_PAREL” swap this for “AECC_ALIGNMENT” in the code block also change the SELALIGNMENT to say SELPARCEL and SA to SP. You can download the lsp file AH-Selectgrading.lsp I use here if you wish there are a few other routines included that you can delete out of the file if unwanted. https://sites.google.com/site/c3dxtreme/
If you guys like this sort of stuff leave I comment. If not tell me what you wish to know more about or what Civil3d should do you never know I may have been there and done it before.

Wednesday, 8 December 2010

Automatically Label those Road Assemblies quickly

I am a great believer in the 80/20 rule and Civil3d seems to follow this to a tee. For example 80% of civil3d objects have a labelling style and 20% of them do not. One example of those objects that do not are assemblies and sub assemblies. Anyone that works with Civil3d on a daily basis will know the hassle when  you take over someone’s corridor model and have to figure out what assemblies are what. Tony on his blog tonyscivil3dworld gave a great tip at the beginning of the year of how to label assemblies with mtexts with fields.
http://tonyscivil3dworld.blogspot.com/2010/01/assemblies-names-labels.html

As I am what one could call a lazy drafter and do not like to sit there doing time consuming labelling. I searched the web for now one could add the labels to assemblies automatically and sure enough on Kean Walmsley’s blog http://through-the-interface.typepad.com he gives and example on now to add labels with .net http://through-the-interface.typepad.com/through_the_interface/fields/ so I have combined the two tips together in the following vba code for 2010 to do the labelling automatically. Here is a link to download the vba code
https://sites.google.com/site/c3dxtreme/home
and here is quick video demonstrating of what the code does
Unable to display content. Adobe Flash is required.
and here is a link on how to embed a video with jing http://www.techsmith.com/learn/jing/tutorials/share/embed-jing-content/ for those that are interested.
Related Posts Plugin for WordPress, Blogger...