Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LISP to extract Cogo Point Description?

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
jroot
5145 Views, 12 Replies

LISP to extract Cogo Point Description?

I'm looking for a LISP that could extract the point description from a cogo point as a piece of MTEXT ot DTEXT.

A bonus would be to select a group of points, have each description extracted as MTEXT individually and placed very near the point marker.

Has anyone seen one that can do this?

Thanks!

12 REPLIES 12
Message 2 of 13
Jeff_M
in reply to: jroot

No, but with all of the sample code here (for Cogopoints) and the Autocad customization forum (for the Mtext portion), you could probably piece one together without too much trouble. Give it a try and post back with your code if you get stuck.
Jeff_M, also a frequent Swamper
EESignature
Message 3 of 13
jroot
in reply to: Jeff_M

I can cobble together and tweak some easy stuff but creating this from scratch is beyond me.

From here:  http://forums.autodesk.com/t5/autocad-civil-3d-customization/extract-aecc-cogo-point-information/m-p...

I found a good piece.  I think my code would at least include something like this:

 

(defun c:desc ()

    (foreach pnt selectedPnts
(setq descr (vlax-get (vlax-invoke pnts 'findpnt) 'fulldescription)
eastng (vlax-get (vlax-invoke pnts 'find pnt) 'easting)
northng (vlax-get (vlax-invoke pnts 'findpnt) 'northing)
 )
 (command "text" "c" eastng,northng "E" descr)

  (princ)
)

 

but how do I select the points?

 

-Joe

Message 4 of 13
Jeff_M
in reply to: jroot

Since you are getting more than one proerty from the cogopoint, save it to a variable instead of having multiple calls to the 'Find method. Here's an updated version for you to ponder:

(defun c:desc (/ c3d c3ddoc descr eastng northng pntobj pnts selectedpnts)
  (vl-load-com)
  (setq	C3D (strcat "HKEY_LOCAL_MACHINE\\"
		    (if	vlax-user-product-key
		      (vlax-user-product-key)
		      (vlax-product-key)
		    )
	    )
	C3D (vl-registry-read C3D "Release")
	C3D (substr
	      C3D
	      1
	      (vl-string-search "." C3D (+ (vl-string-search "." C3D) 1))
	    )
	C3D (vla-getinterfaceobject
	      (vlax-get-acad-object)
	      (strcat "AeccXUiLand.AeccApplication." C3D)
	    )
  )
  (setq	c3ddoc	     (vlax-get c3d 'activedocument)
	pnts	     (vlax-get c3ddoc 'points)
	selectedPnts (vlax-invoke c3ddoc 'selectpoints)
  )

  (foreach pnt selectedPnts
    (setq pntobj (vlax-invoke pnts 'find pnt))
    (setq descr	  (vlax-get pntobj 'fulldescription)
	  eastng  (vlax-get pntobj 'easting)
	  northng (vlax-get pntobj 'northing)
    )
    (command "text" "c" (list eastng northng) "E" descr) ;;this will fail if the current style has a 0 text height
  )
  (vlax-release-object c3d)

  (princ)
)

 

 

Jeff_M, also a frequent Swamper
EESignature
Message 5 of 13
Jeff_M
in reply to: Jeff_M

ANother method that doesn't require the AeccApplication:

(defun c:desc2 (/ descr eastng idx northng pnt pntobj ss)
  (if (setq ss (ssget '((0 . "AECC_COGO_POINT"))))
    (progn
      (setq idx -1)
      (while (setq pnt (ssname ss (setq idx (1+ idx))))
	(setq pntobj (vlax-ename->vla-object pnt))
	(setq descr	  (vlax-get pntobj 'fulldescription)
	  eastng  (vlax-get pntobj 'easting)
	  northng (vlax-get pntobj 'northing)
    )
    (command "text" "c" (list eastng northng) "E" descr) ;;this will fail if the current style has a 0 text height
	)
      )
    )
  (princ)
  )

 

Jeff_M, also a frequent Swamper
EESignature
Message 6 of 13
jroot
in reply to: Jeff_M

desc2 is just what I'm looking for - thanks again Jeff!

Message 7 of 13
nmessina
in reply to: Jeff_M

Jeff,

 

I'm looking for a method in LISP to select Cogo Points by Point Number, as you would on the command line such as 'PN.

 

I'm planning to write a LISP program that can prepare Radial Stake Out reports, since Autodesk Civil 3D Reports fails to produce such reports because it uses HTML langauge and it will not work on IE9+.

 

 

The program itself should be relatively simple just as it was for LDD.  The math and logic for LISP should be very easy. The only difficulties I may have is selecting the Cogo points by number and parcing out Foresight Point entries such as 100,113-125.  My first thought would be to have the FS points in a Point Group before running the program, thus having the user select the Point Group to grab all of the points within the group.

 

 

(setq BS-Az     (angle OC-PT BS-Pt)

         BS-Dist  (itoa (distance OC-PT BS-PT))

         FS-Az     (angle OC-PT BS-Pt)

         FS-Dist   (itoa (distance OC-PT FS-PT))

         AngleRT (angtos (- FS-Az BS-Az) 4 6)

);set

 

Command: Enter Occupied Point: 1

Command: Enter Backsight Point:  2

Command: Enter Foresight (Stakeout) Points: 100,113-125

 

Result

 

-------------------------------- Radial Stake Out Report ---------------------------------

 

                            Pt#    Northings       Eastings         Elevation   Description

Occupied Point:     1      50000.0000   50000.0000  100.00       Iron Pipe

Backsight Point:     2      50500.0000   50000.0000  100.00       Iron Rod

 

Backsight Direction:     N 00d00'00" E

Backsight Distance:     500.00'

 

---------------------------------------------------------------------------------------------------

Pt#     Angle Right  Distance    Northings     Eastings        Elev      Description

---------------------------------------------------------------------------------------------------

100    90d00'00"    125.22'    50000.0000  50125.2200  100.00  Hub

113    90d00'00"    155.22'    50000.0000  50155.2200  100.00  Hub

125    90d00'00"    175.22'    50000.0000  50175.2200  100.00  Hub

 

Any help you can offer will be appreciated.

 

Nicholas, Messina Jr., PSM
Message 8 of 13
Jeff_M
in reply to: nmessina

Nicholas, this should've been started as a new thread rather than tacking on to a thread that is only partially relevant.

 

I had actually started something like this years ago and got sidetracked so it never got completed. I looked at it again today, added in your thoughts on the output formatting, and think the result is useable. It should have some sort of error catching in case the user inputs invaild point numbers/ranges. But as long as the user is careful, it seems to work well. If the user enters a point that doesn't exist for either the Ocupied or Backsight points, it just exits. The stakeout is output to a file of the user's choice for a name, but I've hardcoded the path to be the same as the drawing. That could obviously be changed however you like.

 

One other thing to note....I don't think this will work with point numbers > 62,000 or so (limitations of the INT type in autolisp).

 

Jeff_M, also a frequent Swamper
EESignature
Message 9 of 13
nmessina
in reply to: Jeff_M

Jeff,

 

Thanks for the program, the one I began to create is very similar is structure.  I know I should have started a new thread, and I will start one soon.  I also run into the same issues your program does when it comes to Angle Rights.  Unfortunately Autocad does not think like surveyors do, angles in AutoCAD and LISP always seem to return the accute angle and/or Left Angles (counterclockwise) instead of the angle turning to the right or (clockwise).   In the stakeout result posted below the Angle Right should have been 225d0'0".   I have explored trying to set ANGBASE to 90d00'00" so that North is 0d00'00" and tried to change ANGDIR to clockwise, however I still seemed to get the angle turning counterclockwise.   Ultimately I believe the best solution is to convert the BS & FS Directions to Azimuths, by converting them to Surveyors Units to evaulate which quadrant each of them are.

 

 

 

 

Command: STAKEOUT
Occupied point number: 1
Backsight point number: 4
Point numbers to stake: 5


Filename for output: g:\lisp\txt.txt


------------------------Radial Stakeout---------------------------
   PtNum  Northing     Easting     Elevation   Description
Occupied Pt:      1      1065.2199       1073.5198  8.76 IRON PIPE
Backsight Pt:       4 1065.2199    1560.5141   0.00   SET HUB
BS Direction:  E
BS Distance:   486.99
----------------------------------------------------------------------------------------------
Pt#      Angle Right  Distance     Northing    Easting        Elev          Description
----------------------------------------------------------------------------------------------
5  135d0'0"     324.63  1294.7652      843.9745      8.99  SET HUB
; error: bad argument type: streamp nil
Command:

Nicholas, Messina Jr., PSM
Message 10 of 13
Jeff_M
in reply to: nmessina

OK, I had planned to check that and obviously neglected to do so. I think that this version is now working correctly.

 

 

Jeff_M, also a frequent Swamper
EESignature
Message 11 of 13
tyler.youngZKNVG
in reply to: Jeff_M

Thanks Jeff,

 

This worked perfectly and has set me on the right path to extract more info from cogo points.

 

Regards,

 

Tyler Young

Message 12 of 13
nmessina
in reply to: tyler.youngZKNVG

Jeff,

 

Is there a way to extract Civil 3D Labels to text or better yet Multileaders?

 

Thanks.

Nicholas, Messina Jr., PSM
Message 13 of 13
norman.yuan
in reply to: nmessina

In case you know/do .NET API programming and have not noticed this:

 

http://drive-cad-with-code.blogspot.ca/2016/11/extract-autocad-civil3ds-label-text.html

 

 

Norman Yuan

Drive CAD With Code

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report