COGO points to civilcad AS5

COGO points to civilcad AS5

richard_saunders42BV4
Explorer Explorer
2,354 Views
15 Replies
Message 1 of 16

COGO points to civilcad AS5

richard_saunders42BV4
Explorer
Explorer

Has anyone tried to export from Civil3d to Civilcad AS5.  I have some very old customisation that take an AS5 and process it in Autocad to produce a detail survey with very little interaction. It would take a great deal of time , money and expertise, none of which we have at the moment, to update these routines to function with Civil3d cogo points. ( i dont even know where to find them in the mess of folders and files- it all just gets copied from computer to computer as it gets added to over 30 years). 

So I have a lisp that exports the points to a CSV with the right format for AS5 (see below) but I am having trouble with the first part which is the list of Layers.  Here how it should look:

[VERSION]
1.0
[LAYERS]
L=$$DEFAULT,SC=0.000,P1=-1,P2=-1,T=8192
L=4,SC=0.000,P1=-1,P2=-1,T=8192
L=603,SC=0.000,P1=-1,P2=-1,T=8192
L=950,SC=0.000,P1=-1,P2=-1,T=8192

[POINTS]
ID=c9,X=1969.1270000,Y=4981.9790000,Z=0.0000000,C=
L=603,P=15,S=0,XS=1.000,YS=1.000,R=0.000,T=0
ID=c8,X=1939.1290000,Y=4977.0060000,Z=0.0000000,C=
L=603,P=15,S=0,XS=1.000,YS=1.000,R=0.000,T=0
ID=c736,X=1950.1760000,Y=4966.3660000,Z=0.0000000,C=
L=950,P=15,S=0,XS=1.000,YS=1.000,R=0.000,T=0

 

but so far i only have this (adapted form code I found but can't remember where so sorry if it's yours and I don't give you credit) which gives me the list of points in the correct format but not the header and list of layers.

Alot of the fields are superfluous and/or don't exist in COGO so they are just entered as text to keep correct format and number of fields. 

(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 / ID easting northing elev rawDesc ID layer)
(setq ID (rtos (vlax-get-property cogo 'Number) 2 0))
(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))
(strcat "ID=" ID ",X=" easting ",Y=" northing ",Z=" elev ",C=" rawDesc "\n" "L=" layer ",P=15,S=0,XS=1.000,YS=1.000,R=0.000,T=0" )

 

 

 

0 Likes
Accepted solutions (1)
2,355 Views
15 Replies
Replies (15)
Message 2 of 16

richard_saunders42BV4
Explorer
Explorer
0 Likes
Message 3 of 16

Sea-Haven
Mentor
Mentor

I am a ex Civilcad State Rep, PM me can discuss more, are you in AUS ?

0 Likes
Message 4 of 16

john.uhden
Mentor
Mentor

@richard_saunders42BV4 ,

Looks like you got it.  So what's the problem?

John F. Uhden

0 Likes
Message 5 of 16

Sea-Haven
Mentor
Mentor

For any one, the AS5 format was Civilcad's version of a dxf file, its a text output of the Civilcad dwg, I am not sure why needed as Civilcad reads a Dxf and DWG. 

 

Civilcad has been superseded by Magnet.

0 Likes
Message 6 of 16

richard_saunders42BV4
Explorer
Explorer

Read the question. 

0 Likes
Message 7 of 16

richard_saunders42BV4
Explorer
Explorer

looks like none of you people read the questions. 

0 Likes
Message 8 of 16

richard_saunders42BV4
Explorer
Explorer

Yes in Aus. New boss won't buy magnet but I have 30 years of Civilcad/Magnet to AutoCAD cutomisations that make life very easy. If I could just start with an as5. I no longer have access to the authors of that code and they weren't great at documentation. It would take me years to dismantle code to rewrite (and I am not a coder). If I can just get this little thing working, I would be able to carry on as if nothing changed for the few years until I retire. But I have a hard time getting any one to read the whole question before answering. I have the bulk of it with the help of code I found on here. Just need the last piece of the puzzle as described in the original question and I am there. As I said, I am not a coder.

0 Likes
Message 9 of 16

Sea-Haven
Mentor
Mentor

Still confused Civilcad can export a dwg and yes it creates some objects that you do not want in a dwg, I got around these problems via a lisp, it changed layer names, removed the point cross, changed some of the linetypes to an equivalent CAD name, plus much more.

 

Sounds like what you want. Please let me know can provide the program. 

 

Again ex Civilcad VIC/TAS state manager understand what is in a Civilcad export dwg.

0 Likes
Message 10 of 16

richard_saunders42BV4
Explorer
Explorer

1. I do NOT have Civilcad/ Magnet anymore. New boss won't buy it.

2. I DO have a suite of routines developed over 30 years by multiple authors which use a Civilcad AS5 as a starting point and produce a detail plan in no time.

3. I have been using these routines for over 10 years and they (with me using them) are extremely efficient.

4. I have 90% of the code I need to achieve what I want. Just need someone to read the entire question and help me finish it.

5. If no one is willing the read the entire question, that's fine. I will figure it out eventually. I was just hoping I could get some help with the coding because I am old ..really b*oody old, and learning doesn't happen the way it used to.

 

0 Likes
Message 11 of 16

john.uhden
Mentor
Mentor

@richard_saunders42BV4 ,

Okay, I've read it again.

It seems you have the the POINTS written correctly.  But do you still need guidance on the LAYERS portion?

 

Are these lines always written...?

L=$$DEFAULT,SC=0.000,P1=-1,P2=-1,T=8192
L=4,SC=0.000,P1=-1,P2=-1,T=8192

 

I ask mainly because I don't see a point with a layer named 4.

I must also caution you about any rawDesc that contains one or more commas.  It could screw up your format.

You should probably introduce a variable symbol for rawDesc and add...

(while (vl-string-search "," rawDesc)(setq rawDesc (vl-string-subst ";" "," rawDesc)))

John F. Uhden

0 Likes
Message 12 of 16

richard_saunders42BV4
Explorer
Explorer
Thanks for having another look at this for me John. I appreciate it greatly. Yes that is exactly it.
L=[the layer name of the exported cogo point]. The other parameters seem to be irrelevant to what I need but still need to be written ,as is, to each line.
So there will be a single line written for each layer.
0 Likes
Message 13 of 16

Sea-Haven
Mentor
Mentor

You need a AS5 file and the corresponding dwg file so you can see how they work together. Here is a full AS5 file. Think of it as Civilcad's version of a dxf file.

0 Likes
Message 14 of 16

john.uhden
Mentor
Mentor
Accepted solution

 

@richard_saunders42BV4 ,

Here is my first try at what I think you want (untested).

You be the tester and let me know.

;|  Example
[VERSION]
A1.0
[LAYERS]
L=$$DEFAULT,SC=0.000,P1=-1,P2=-1,T=8192
L=4,SC=0.000,P1=-1,P2=-1,T=8192
L=603,SC=0.000,P1=-1,P2=-1,T=8192
L=950,SC=0.000,P1=-1,P2=-1,T=8192

[POINTS]
ID=c9,X=1969.1270000,Y=4981.9790000,Z=0.0000000,C=
L=603,P=15,S=0,XS=1.000,YS=1.000,R=0.000,T=0
ID=c8,X=1939.1290000,Y=4977.0060000,Z=0.0000000,C=
L=603,P=15,S=0,XS=1.000,YS=1.000,R=0.000,T=0
ID=c736,X=1950.1760000,Y=4966.3660000,Z=0.0000000,C=
L=950,P=15,S=0,XS=1.000,YS=1.000,R=0.000,T=0
|;

(defun cogo:pntToString (cogo / ID easting northing elev rawDesc ID)
  (setq ID (rtos (vlax-get-property cogo 'Number) 2 0))
  (setq easting (rtos (vlax-get-property cogo 'Easting) 2 4))
  (setq northing (rtos (vlax-get-property cogo 'Northing) 2 4))
  (setq elev (rtos (vlax-get-property cogo 'Elevation) 2 4))
  (setq rawDesc (vlax-get-property cogo 'RawDescription))
  (while (vl-string-search "," rawDesc)(setq rawDesc (vl-string-subst ";" "," rawDesc)))
  (setq layer (strcase (vlax-get-property cogo 'Layer)))
  (strcat "ID=" ID ",X=" easting ",Y=" northing ",Z=" elev ",C=" rawDesc "\n" "L=" layer ",P=15,S=0,XS=1.000,YS=1.000,R=0.000,T=0" )
)

;; Embellished by John Uhden for @richard_saunders42BV4 7/15/2024
(defun c:cogoExport ( / ss fileName f n layers lines)
  (setq ss (ssget '((0 . "AECC_COGO_POINT"))))
  (setq fileName (getfiled "Export to" "" "csv" 1))
  (and ss fileName
    (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))
      (setq lines (cons line lines))
      (if (not (vl-position layer layers (setq layers (cons layer layers)))))
      (setq n (+ n 1))
    )
    (setq layers (append layers (list "4" "$$DEFAULT")))
    (setq layers (mapcar '(lambda (x)(strcat "L=" x ",SC=0.000,P1=-1,P2=-1,T=8192"))(reverse layers)))
    (setq layers (cons "[LAYERS]" layers))
    (write-line "[VERSION]" f)
    (write-line "A1.0" f)
    (foreach line layers (write-line line f))
    (write-line f)
    (write-line "[POINTS]" f)
    (foreach line (reverse lines) (write-line line f))
    (close f)
    (princ (strcat "\nPoints have been exported. Quantity: " (itoa n)))
  )
)

 

John F. Uhden

0 Likes
Message 15 of 16

richard_saunders42BV4
Explorer
Explorer

Thanks @john.uhden 

A couple of syntax errors but got my head going in the right direction. Here's what I ended up with that works.

(defun cogo:pntToString (cogo / ID easting northing elev rawDesc layer)
  (setq ID (rtos (vlax-get-property cogo 'Number) 2 0))
  (setq easting (rtos (vlax-get-property cogo 'Easting) 2 4))
  (setq northing (rtos (vlax-get-property cogo 'Northing) 2 4))
  (setq elev (rtos (vlax-get-property cogo 'Elevation) 2 4))
  (setq rawDesc (vlax-get-property cogo 'RawDescription))
  (while (vl-string-search "," rawDesc)
    (setq rawDesc (vl-string-subst ";" "," rawDesc))
  )
  (setq layer (strcase (vlax-get-property cogo 'Layer)))
  (list (strcat "ID=" ID ",X=" easting ",Y=" northing ",Z=" elev ",C=" rawDesc "\n" "L=" layer ",P=15,S=0,XS=1.000,YS=1.000,R=0.000,T=0") layer)
)
 
 
(defun c:cogoExport ( / ss fileName f n layers lines result)
  (setq ss (ssget '((0 . "AECC_COGO_POINT"))))
  (setq fileName (getfiled "Export to" "" "csv" 1))
  (setq layers '())
  (setq lines '())
  (and ss fileName
    (setq f (open fileName "w"))
    (setq n 0)
    (repeat (sslength ss)
      (setq cogo (vlax-ename->vla-object (ssname ss n)))
      (setq result (cogo:pntToString cogo))
      (setq line (car result))
      (setq layer (cadr result))
      (setq lines (cons line lines))
      (if (not (vl-position layer layers))
        (setq layers (cons layer layers))
      )
      (setq n (+ n 1))
    )
    (setq layers (append layers (list "4" "$$DEFAULT")))
    (setq layers (mapcar '(lambda (x) (strcat "L=" x ",SC=0.000,P1=-1,P2=-1,T=8192")) (reverse layers)))
    (setq layers (cons "[LAYERS]" layers))
    (write-line "[VERSION]" f)
    (write-line "A1.0" f)
    (foreach line layers (write-line line f))
    (write-line "" f)
    (write-line "[POINTS]" f)
    (foreach line (reverse lines) (write-line line f))
    (close f)
    (princ (strcat "\nPoints have been exported. Quantity: " (itoa n)))
  )
  (princ)
)
0 Likes
Message 16 of 16

john.uhden
Mentor
Mentor

@richard_saunders42BV4 ,

YAY!! I am thrilled to hear of your success.  Good job! 😊

John F. Uhden

0 Likes