Help with CSV Cogo export script

Help with CSV Cogo export script

carl3ZPF6
Enthusiast Enthusiast
638 Views
6 Replies
Message 1 of 7

Help with CSV Cogo export script

carl3ZPF6
Enthusiast
Enthusiast

I am trying to edit a script that I have to also write the COGO custom property from below:

carl3ZPF6_0-1706825690502.png

 

Here is my code. everything works except for the (setq bearing (vlax-get-property cogo 'Bearing)) line. Is there a way to export these custom properties in 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)
	  (setq line "CAD Index, x, y, z, ," )
	  (write-line line f)
      (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 / num northing easting elev rawDesc layer)
  (setq num (vlax-get-property cogo 'Number))
  (setq easting (rtos (vlax-get-property cogo 'Easting) 2 3))
  (setq northing (rtos (vlax-get-property cogo 'Northing) 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 bearing (vlax-get-property cogo 'Bearing))
  (strcat (itoa num) "," easting  "," northing "," elev "," rawDesc "," layer "," bearing)
  )

 

 

 

 

0 Likes
Accepted solutions (1)
639 Views
6 Replies
Replies (6)
Message 2 of 7

tcorey
Mentor
Mentor

'Bearing is not a property of a COGO Point. You might need to use an angle function to calculate the angle between points. What is it you're going for with Bearing?



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Platinum Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 3 of 7

carl3ZPF6
Enthusiast
Enthusiast

This is a custom property, I am looking for the text string that was assigned to the Bearing property in the image above, not rotation.

0 Likes
Message 4 of 7

Jeff_M
Consultant
Consultant

@carl3ZPF6 is the Bearing property a UserDefinedProperty? Can you post a drawing with a few of these points in it?

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 5 of 7

carl3ZPF6
Enthusiast
Enthusiast

Yes user defined. See attached drawing.

0 Likes
Message 6 of 7

Jeff_M
Consultant
Consultant
Accepted solution

Ok, 2 things need to be done. First, you must assign the Classification to a PointGroup the points are in...in this drawing's case, the "_All Points" group (note that older releases of C3D did not allow assigning the classification to this group). If the points are not in a group with the Classification set you will get an error.

2024-02-02_12-09-32.png

Second, change the line to get the Bearing to this:

(setq bearing (vlax-invoke cogo 'getuserdefinedpropertyvalue "Bearing"))

 

Note that if you want to get other UDP values the UDPs are case sensitive. This fact has caused others much frustration in the past.

Jeff_M, also a frequent Swamper
EESignature
Message 7 of 7

carl3ZPF6
Enthusiast
Enthusiast

Thank you Sir!

0 Likes