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: 

Exporting cogo points with layer information & marker rotation

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
mabrman
441 Views, 5 Replies

Exporting cogo points with layer information & marker rotation

Ideally I'd want to make a selection of cogo points and export them as a *.csv with the following columns:

- Northing

- Easting

- Elevation

- (RAW) Description

- Rotation (as seen in Properties of the Cogo Point, "Marker Rotation" under "Annotation")

- Layer (layer where Cogo point sits on)

 

Is this possible?

 

I've tried DATAEXTRACTION, MAPEXPORT and EXPORTPOINTS for this one, but it seems like I'm looking a little more functionality.

 

Context: Coming from a web-development background, I've been given a fairly complex landfill infrastructure drawing to make a GIS application where on-site people can quickly find a location by it's name on a map. (Basically google maps with search functionality) on their tablets/phones. This would help streamline the process as the infrastructure drawing updates periodically.

5 REPLIES 5
Message 2 of 6
hosneyalaa
in reply to: mabrman

Hi 

Attached any example drawing 

Message 3 of 6
hippe013
in reply to: mabrman

Here is a quick example on how to do this using lisp. 

(defun c:cogoExport ( / ss fileName f n)
  (setq ss (ssget '(( 0 . "AECC_COGO_POINT"))))
  (setq fileName (getfiled "Export to" "" "csv" 1))
  (if (and ss fileName)
    (progn
      (setq f (open fileName "w"))
      (setq n 0)
      (repeat (sslength ss)
	(setq cogo (vlax-ename->vla-object (ssname ss n)))
	(setq line (cogo:pntToString cogo))
	(write-line line f)
	(setq n (+ n 1))
	)
      (close f)
      (princ (strcat "\nPoints have been exported. Quantity: " (itoa n)))
      )
    (princ "\nCommand Canceled.")
    )
  (princ)
  )

(defun cogo:pntToString (cogo / northing easting elev rawDesc layer lblRot)
  (setq northing (rtos (vlax-get-property cogo 'Northing) 2 3))
  (setq easting (rtos (vlax-get-property cogo 'Easting) 2 3))
  (setq elev (rtos (vlax-get-property cogo 'Elevation) 2 3))
  (setq rawDesc (vlax-get-property cogo 'RawDescription))
  (setq layer (vlax-get-property cogo 'Layer))
  (setq lblRot (rtos (vlax-get-property cogo 'LabelRotation) 2 8))
  (strcat northing  "," easting "," elev "," rawDesc "," lblRot "," layer)
  )
Message 4 of 6
mabrman
in reply to: hippe013

This is incredible! I did a quick test to it and it was like magic!

 

I did need marker rotation thought, and with a little research and was able to get it!

I replaced your line:

 

(setq lblRot (rtos (vlax-get-property cogo 'LabelRotation) 2 8))

 

with:

 

(setq rot (rtos (* (/ (vlax-get-property cogo 'Rotation) pi) 180) 2 0))

 

 to get the marker rotation in degrees (which is what I need).

 

I made sure to replace lblRot with rot in the variable names on 'defun' line 22 too. 🙂

 

Thank you for the help hippe013 !

Message 5 of 6
hippe013
in reply to: mabrman

Excellent, I am happy I was able to help.

Message 6 of 6
mabrman
in reply to: mabrman

Dropping these here with my most recent implementation in case someone else might find it useful in the future/I forget and will have to return here 🙂

Basically exports csv of selection with the following columns: 

 

Point Number, Northing, Easting, Elevation, Raw Description, Name, Rotation, Layer, Primary Point Group Name

 

(defun getaeccApp (module / *acad* C3D) ;; module must be "Land", "Pipe", "Roadway", or "Survey"
  (vl-load-com)
  (if (and (setq *acad* (vlax-get-acad-object))
	   (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 "AeccXUi" module ".Aecc" (if (= (strcase module) "LAND") "" module) "Application." C3D)
		     )
	   )
      )
    C3D
  )
)

(defun c:cogoExport ( / ss fileName f n pgs)
  (setq ss (ssget '(( 0 . "AECC_COGO_POINT"))))
  (setq c3ddoc (vlax-get (getaeccapp "Land") 'activedocument))
  (setq defaultFileName (strcat 
      (vl-string-subst "\\Downloads\\" "\\Documents" (getvar 'MYDOCUMENTSPREFIX)) 
      (vl-string-subst "" ".dwg" (getvar "dwgname")) 
      ".csv" 
    )
  )
  (setq fileName (getfiled "Export to" defaultFileName "csv" 1))
  (if (and ss fileName)
    (progn
      (setq f (open fileName "w"))
      (setq n 0)
      (write-line "Point number,Northing,Easting,Elevation,Raw Description,Name,Rotation,Layer,PrimaryPointGroupName" f)
      (repeat (sslength ss)
        (setq cogo (vlax-ename->vla-object (ssname ss n)))
        (setq line (cogo:pntToString cogo c3ddoc))
        (write-line line f)
        (setq n (+ n 1))
      )
      (close f)
      (princ (strcat "\nPoints have been exported. Quantity: " (itoa n)))
      )
    (princ "\nCommand Canceled.")
    )
  (princ)
)

(defun cogo:getPointPrimaryPointGroup (pt c3ddoc / IDX PTGRP)
  (setq idx -1)
  (vlax-for grp	(vlax-get-property c3ddoc 'pointgroups)
    (if	(and (= (vlax-invoke-method grp 'containspoint (vlax-get-property pt 'number)) :vlax-true)
	     (> (vlax-get-property grp 'DrawPriority) idx)
	     )
      (progn
	(setq idx (vlax-get-property grp 'DrawPriority))
	(setq ptgrp grp)
      )
    )
  )
  ptgrp
)

(defun cogo:pntToString (cogo c3ddoc / northing easting elev rawDesc layer rot ptNum ptName primaryPointGroupName)
  (setq northing (rtos (vlax-get-property cogo 'Northing) 2 3))
  (setq easting (rtos (vlax-get-property cogo 'Easting) 2 3))
  (setq elev (rtos (vlax-get-property cogo 'Elevation) 2 3))
  (setq rawDesc (vlax-get-property cogo 'RawDescription))
  (setq layer (vlax-get-property cogo 'Layer))
  (setq rot (rtos (* (/ (vlax-get-property cogo 'Rotation) pi) 180) 2 0))
  (setq ptNum (vlax-get-property cogo 'Number))
  (setq ptName (vlax-get-property cogo 'Name))
  (setq primaryPointGroupName (vlax-get-property (cogo:getPointPrimaryPointGroup cogo c3ddoc) 'Name))
  (strcat (itoa ptNum) "," northing  "," easting "," elev "," rawDesc "," ptName "," rot "," layer "," primaryPointGroupName)
)

 

 

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report