OMEGA-ThundeR Posted January 5, 2018 Share Posted January 5, 2018 Hi, I made an lisp that places an cicle at a certain X and Y plain with a manual input for the Z value. So i made this (code comment is Dutch): (setq aantal (getint "\nHoeveel cirkels plaatsen?<50>: ")) (if (null aantal) (setq aantal 50)) ;; Indien gewoon op enter wordt gedrukt bij deze vraag wordt het standaard aantal 50 gebruikt (setq max aantal) ;; Defineer het maximum aantal circels dat geplaatst wordt (repeat aantal ;; Herhaal de code totdat het max aantal circels is bereikt (setq XYZpunt (getpoint (strcat "\nWaar wil je de cirkel hebben? (nog: " (rtos aantal 2 0)"/"(rtos max 2 0)")"))) (setq Z (getint "\nOp welke hoogte moet deze komen?: ")) (setq X (rtos (car XYZpunt) 2 10)) ;; Zet coordinaat X om in STRING (setq Y (rtos (cadr XYZpunt) 2 10)) ;; Zet coordinaat Y om in STRING (setq Z (rtos Z 2 3)) ;; Zet coordinaat Z om in STRING (setq XYZ (strcat X "," Y "," Z)) ;; Combineert SETQ X Y en Z naar coordinaten STRING ;;(princ "\nXYZ: ") ;; Debug check ;;(princ XYZ) ;; Debug check (command "CIRCLE" XYZ "0.05") ;; Plaatst cirkel op gekozen coordinaat met handingevoerde hoogte (princ "\nCirkel geplaatst") (setq aantal (1- aantal)) ;; Haalt van het aantal aangegeven punten-nog-te-doen 1 punt af. ) ) Without comments (might me nicer to read) (setq aantal (getint "\nHoeveel cirkels plaatsen?<50>: ")) (if (null aantal) (setq aantal 50)) (setq max aantal) (repeat aantal (setq XYZpunt (getpoint (strcat "\nWaar wil je de cirkel hebben? (nog: " (rtos aantal 2 0)"/"(rtos max 2 0)")"))) (setq Z (getint "\nOp welke hoogte moet deze komen?: ")) (setq X (rtos (car XYZpunt) 2 10)) (setq Y (rtos (cadr XYZpunt) 2 10)) (setq Z (rtos Z 2 3)) (setq XYZ (strcat X "," Y "," Z)) (command "CIRCLE" XYZ "0.05") (princ "\nCirkel geplaatst") (setq aantal (1- aantal)) ) ) In the middle of nowhere in my drawing (not using a snap point) the given z-value is added right, but when i use a snap function to place the cicle at the end of a line, the z-value of that snap point is used. That seems weird to me, since i f*cked up the code so much that the coordinates are like you would enter them manually (string)... So how is the Z-value of the snappoint being used instead of the getint value? It does the same thing when i use 'getstring' instead of 'getint', but in the debug section it outputs the same anyway. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted January 5, 2018 Share Posted January 5, 2018 Check that your OSNAPZ variable is set to 0. Quote Link to comment Share on other sites More sharing options...
OMEGA-ThundeR Posted January 5, 2018 Author Share Posted January 5, 2018 Its set to 0 (was 0) Quote Link to comment Share on other sites More sharing options...
ronjonp Posted January 5, 2018 Share Posted January 5, 2018 Not enough coffee yet ... you need to disable snaps. Quote Link to comment Share on other sites More sharing options...
OMEGA-ThundeR Posted January 5, 2018 Author Share Posted January 5, 2018 Not enough coffee yet ... you need to disable snaps. That would fix my issue, but then i don't get the right coordinates. i noticed that when snapping to an endpoint of a line the Z-value stays 0 (with a 0 elevation line) but does adapt my given Z-value when i snap to the center of a circle or arc... Edit; using a manual snappoint does work (enter 'END' or 'MID' when OSNAP is off). Now find the lisp command to shut OSNAP on and off again . Quote Link to comment Share on other sites More sharing options...
ronjonp Posted January 5, 2018 Share Posted January 5, 2018 The easiest fix is to remove the command call like so: (defun c:foo (/ p z) (and (setq p (getpoint "\nSpecify center point for circle: ")) (setq z (getreal "\nEnter Z value: ")) (entmakex (list '(0 . "circle") '(8 . "Circle") (cons 10 (list (car p) (cadr p) z)) '(40 . 0.05)) ) ) (princ) ) You also don't need to convert the point to a string when using a command call ... (command "_.circle" (getpoint) 0.05) will work as well. Quote Link to comment Share on other sites More sharing options...
FranknBeans Posted January 6, 2018 Share Posted January 6, 2018 ..Now find the lisp command to shut OSNAP on and off again . you can turn off snaps when the circle is placed.. [size=2](command "CIRCLE" [color=red]"none"[/color] XYZ "0.05")[/size] Quote Link to comment Share on other sites More sharing options...
OMEGA-ThundeR Posted January 8, 2018 Author Share Posted January 8, 2018 The easiest fix is to remove the command call like so: I might have made my code a bit to 'difficult' or elaborate , but i learn a lot this way. But thanks for the input . you can turn off snaps when the circle is placed.. [size=2](command "CIRCLE" [color=red]"none"[/color] XYZ "0.05")[/size] Hot damn! That worked like a charm . (Defun c:PCH (/ aantal max XYZpunt Z X Y XYZ) (setq aantal (getint "\nHoeveel cirkels plaatsen?<50>: ")) (if (null aantal) (setq aantal 50)) ;; Indien gewoon op enter wordt gedrukt bij deze vraag wordt het standaard aantal 50 gebruikt (setq max aantal) ;; Defineer het maximum aantal circels dat geplaatst wordt (repeat aantal ;; Herhaal de code totdat het max aantal circels is bereikt (setq XYZpunt (getpoint (strcat "\nWaar wil je de cirkel hebben? (nog: " (rtos aantal 2 0)"/"(rtos max 2 0)")"))) (setq Z (getstring "\nOp welke hoogte moet deze komen?: ")) (setq X (rtos (car XYZpunt) 2 10)) ;; Zet coordinaat X om in STRING (setq Y (rtos (cadr XYZpunt) 2 10)) ;; Zet coordinaat Y om in STRING (setq XYZ (strcat X "," Y "," Z)) ;; Combineert SETQ X Y en Z naar coordinaten STRING (command "CIRCLE" [color=red]"none"[/color] XYZ "0.05") ;; Plaatst cirkel op gekozen coordinaat met handingevoerde hoogte (princ "\nCirkel geplaatst") (setq aantal (1- aantal)) ;; Haalt van het aantal aangegeven punten-nog-te-doen 1 punt af. ) ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.