TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: pedroantonio on October 16, 2014, 04:27:51 AM
-
Hi . I have a litle problem and a need your help.
My template units is
format --> units
decimal
Grags --> clockwise
meters
genetic
Direction --> North
I use a *.fas file for a long time . The problem is that after "run " the *.fas file and use it ,change my template units to:
format --> units
decimal
Grags --> clockwise
meters
genetic
Direction --> East
I ask from the gay who write this *.fas to help me and he sent me a file that is not working and giving me an error like this
Command: (LOAD "C:/topocad/GRD.fas") C:GRD
Command: grd
Deleting block "grd".
1 block deleted.
; error: quit / exit abort
I dont know why.
So i want to ask if is posible to run this *.fas file through lisp and then to change again the units
I try to write a code
(defun c:test nil
(setq units(getvar "lunits"))
(setvar "lunits" 2) ; decimal
(setq units(getvar "aunits"))
(setvar "aunits" 2) ; grads
(setq units(getvar "angbase"))
(setvar "angbase" 0)
(setq units(getvar "angdir"))
(setvar "angdir" 1) ; clockwise
(princ)
)
I dont know how to change the direction to North
Any ideas ?
Thank
-
Maybe this code will works:
(defun c:test (/ err)
(if (vl-catch-all-error-p
(setq err (vl-catch-all-apply
(function
(lambda ()
(load "C:/topocad/GRD.fas")
(command "grd")
) ;_ end of lambda
) ;_ end of function
) ;_ end of vl-catch-all-apply
) ;_ end of setq
) ;_ end of vl-catch-all-error-p
(princ (strcat "\n Error loading and executing grd.fas : " (vl-catch-all-error-message err)))
) ;_ end of if
(foreach item '(("lunits" . 2)
("aunits" . 2)
("angbase" . 0)
("angdir" . 1)
)
(if (vl-catch-all-error-p
(setq err (vl-catch-all-apply
(function
(lambda ()
(setvar (car item) (cdr item))
) ;_ end of lambda
) ;_ end of function
) ;_ end of vl-catch-all-apply
) ;_ end of setq
) ;_ end of vl-catch-all-error-p
(princ
(strcat "\n Error settings \""
(car item)
"\" SysVar to value "
(vl-princ-to-string (cdr item))
" : "
(vl-catch-all-error-message err)
) ;_ end of strcat
) ;_ end of princ
) ;_ end of if
) ;_ end of foreach
(princ)
) ;_ end of defun
-
I don't play around with units much, BUT is NORTHDIRECTION variable something to consider ?
-
hi kpblc thank you for your time.
I check your lisp file and gives me this error
Command: (LOAD "C:/Users/Prodromos/Desktop/test.lsp") C:TEST
Command: test
grd Unknown command "GRD".
I can not understand why because the command is the grd
-
And what will happens if you type "grd" at command line after loading fas by my code?
You can change (command "grd") to one of these:
1. (vl-cmdf "grd")
2. (command-s "grd") ; only at ACAD2015
3. (c:grd).
-
with this change work
(defun c:test (/ err)
(if (vl-catch-all-error-p
(setq err (vl-catch-all-apply
(function
(lambda ()
(load "C:/topocad/GRD.fas")
(c:grd)
) ;_ end of lambda
) ;_ end of function
) ;_ end of vl-catch-all-apply
) ;_ end of setq
) ;_ end of vl-catch-all-error-p
(princ (strcat "\n Error loading and executing grd.fas : " (vl-catch-all-error-message err)))
) ;_ end of if
(foreach item '(("lunits" . 2)
("aunits" . 2)
("angbase" . 0)
("angdir" . 1)
)
(if (vl-catch-all-error-p
(setq err (vl-catch-all-apply
(function
(lambda ()
(setvar (car item) (cdr item))
) ;_ end of lambda
) ;_ end of function
) ;_ end of vl-catch-all-apply
) ;_ end of setq
) ;_ end of vl-catch-all-error-p
(princ
(strcat "\n Error settings \""
(car item)
"\" SysVar to value "
(vl-princ-to-string (cdr item))
" : "
(vl-catch-all-error-message err)
) ;_ end of strcat
) ;_ end of princ
) ;_ end of if
) ;_ end of foreach
(princ)
) ;_ end of defun
but the direction still East. I want the direction be North
Thanks
-
East is the norm, try listing a line and see if it gives you the direction you're looking for.
-
My template have the North ath the beginning
Then i run the grd.fas and gives me East
I want to change it again to North when lisp stop .
The test.lsp code gives me East !!!!
How to change it to North ??
Thanks
-
My template have the North ath the beginning
Then i run the grd.fas and gives me East
I want to change it again to North when lisp stop .
The test.lsp code gives me East !!!!
How to change it to North ??
Thanks
Why don't you change the NORTHDIRECTION (http://help.autodesk.com/view/CIV3D/2015/ENU/?guid=GUID-ABD3783D-4D11-40B0-9499-4FC7F42E155D) system variable as Kerry suggested.
-
You can add any system variables editing list
'(("lunits" . 2)
("aunits" . 2)
("angbase" . 0)
("angdir" . 1)
)
Every string is dotpair: first element is system variable name, second - value to be setted. I think is's simplest way.
-
(defun topodwg (/)
(setvar "angdir"1)
(setvar "angbase"(/ pi 2))
(setvar "aunits"2)
(setvar "dimaunit"2)
(setvar"dimadec"4)
(setvar "dimdec"2)
(setvar "auprec"6)
(setvar"insunits"6)
)
-
I think changing
(setvar "angdir"1)
(setvar "angbase"(/ pi 2))
(setvar "aunits"2)
(setvar "dimaunit"2)
(setvar"dimadec"4)
(setvar "dimdec"2)
(setvar "auprec"6)
(setvar"insunits"6)
to(foreach item (list '("angdir" . 1)
(cons "angbase" (/ pi 2))
("aunits" . 2)
("dimaunit" . 2)
("dimadec" . 4)
("dimdec" . 2)
("auprec" . 6)
("insunits" . 6)
) ;_ end of list
(setvar (car item) (cdr item))
) ;_ end of foreach
is more simply to undestand and changing in future.
Why do you not use foreach or mapcar functions? It's easy!
-
I simply use two very basic command lisps to change the direction if it ever gets screwed up:
;
; Lisp to modify drawing so north is 0 and clockwise angles, for some lisp routines
; to work correctly.
;
; P Bourke (Metrix Surveys) 07/04
;------------------------------------------------------------------------
(defun C:met-n0 ()
(setvar "CMDECHO" 0)
; change direction to 270 and clockwise to y
(command "units" "" "" "" "" "90" "y")
(prompt "\n North = 0")
(setvar "CMDECHO" 1)
(princ)
)
;
; Lisp to modify drawing so East is 0 and clockwise angles, for some lisp routines
; to work correctly.
;
; P Bourke (Metrix Surveys) 07/04
;------------------------------------------------------------------------
(defun C:met-e0 ()
(setvar "CMDECHO" 0)
; change direction to 0 and clockwise to n
(command "units" "" "" "" "" "0" "n")
(prompt "\n East = 0")
(setvar "CMDECHO" 1)
(princ)
)
-
thank you