GDA2020 conversion lisp

GDA2020 conversion lisp

Kate.RobinsonR9FXS
Participant Participant
199 Views
2 Replies
Message 1 of 3

GDA2020 conversion lisp

Kate.RobinsonR9FXS
Participant
Participant

Hello, need a lisp that helps me block shift all my xrefs, because of the Australian grid shift GDA94 to GDA2020.

Basically need the lisp to unload all xrefs, unlock all layers, turn all frozen layers off then thaw the frozen layers so they're only turned off, select all objects in the xref and move by coordinate shift x(0.454),y(1.445)

 

TIA

0 Likes
Accepted solutions (1)
200 Views
2 Replies
Replies (2)
Message 2 of 3

Kate.RobinsonR9FXS
Participant
Participant

Believe i may have solved this myself but let me know if you see a better way.

 

I have tested and this does the job

 

(defun c:GDA94TO2020 ()
(command "-xref" "unload" "*" "")
(command "-layer" "unlock" "*" "")
(setq lay (cdr (assoc 2 (tblnext "layer" T))))
(while lay
(if (= (cdr (assoc 70 (tblsearch "layer" lay))) 1)
(progn
(command ".-layer" "off" lay "")
(setq lay (cdr (assoc 2 (tblnext "layer"))))
)
(setq lay (cdr (assoc 2 (tblnext "layer"))))
)
)
(command ".-layer" "thaw" "*" "")
(command "_.move" "_all" "" "0,0" "0.454,1.445")
(princ)
)

0 Likes
Message 3 of 3

Moshe-A
Mentor
Mentor
Accepted solution

@Kate.RobinsonR9FXS ,

 

what you did is OK works, well done 👍

 

better way? here is my shorter version.

 

As you can see, calling (tblnext) ones as test expression for (while) is enough [no need to use (tblserach) also]

the trick here is using variable tbl 

 

(while (setq tbl (tblnext "layer" (not tbl)))

 

cause at first tbl is nil , (not tbl) returns T as the 2nd args for (tblnext) which rewind the layer table.

the next time tbl has a record and it's not nil so the loop spins until (tblnext) return nil (end of table records).

 

Moshe

 

(defun C:GDA94TO2020 (/ tbl lay)
 (command "._xref"  "_unload" "*" "")
 (command ".-layer" "_unlock" "*" "")

 ; turn all frozen layers to off 
 (while (setq tbl (tblnext "layer" (not tbl)))
   
  (if (= (cdr (assoc 70 tbl)) 1)
   (command "._layer" "_off" (cdr (assoc 2 tbl)) "") ; turn layer off
  ); if
   
 ); while
  
 (command "._layer" "_thaw" "*" "")
 (command "._move"  "_all" "" "0,0" "0.454,1.445")
  
 (princ)
); C:GDA94TO2020