BlackAlnet Posted January 26, 2010 Posted January 26, 2010 I'm very new to lisp, and doesnt have much time to study, Whats the problem with this? (defun c:se (/ ent obj d delta dx dy se) (vl-load-com) (if (setq ent (entsel "\nSelecione a LINHA: ")) (progn (setq obj (vlax-ename->vla-object (car ent))) (setq d (vla-get-delta obj)) (setq delta (vlax-safearray->list (vlax-variant-value d))) (setq dx (car delta)) (setq dy (cdr delta)) (setq se ( / dy dx)) (princ se) ) ) ) I just want the "delta x" and "delta y" values, but, the lisp is returning the values "doubled". How can i fix it? I'm very grateful fr any help. Thanks!! Quote
gile Posted January 26, 2010 Posted January 26, 2010 Hi, Try: (setq delta (vlax-get obj 'delta)) Quote
BlackAlnet Posted January 26, 2010 Author Posted January 26, 2010 gile, many thanks for your post, but i get the same error. The error is: the list is duplicated, like this : "(-20.0 5.0 0.0)(-20.0 5.0 0.0)" And when i do "(car delta)", it returns : "-20.0-20.0" and "(cdr delta)" returns "5.05.0" How can i fix it? Quote
Lee Mac Posted January 26, 2010 Posted January 26, 2010 This seems to work fine for me? (defun c:test (/ ent obj) (vl-load-com) (while (progn (setq ent (car (entsel "\nSelect Line: "))) (cond ( (eq 'ENAME (type ent)) (if (vlax-property-available-p (setq obj (vlax-ename->vla-object ent)) 'Delta) (print (vlax-safearray->list (vlax-variant-value (vla-get-Delta obj)))) (princ "\n** Invalid Object **")))))) (princ)) Quote
Lee Mac Posted January 26, 2010 Posted January 26, 2010 Ahh, bear in mind that princ will print the values to the screen, but then the return of the princ function will be those values that have just been printed. Hence you will need to follow it with perhaps another princ. Quote
LEsq Posted January 26, 2010 Posted January 26, 2010 gile, many thanks for your post, but i get the same error. The error is: the list is duplicated, like this : "(-20.0 5.0 0.0)(-20.0 5.0 0.0)" And when i do "(car delta)", it returns : "-20.0-20.0" and "(cdr delta)" returns "5.05.0" How can i fix it? What do you mean by list? That looks to me to be a string, if it is that, use read to converted to list and then use car for the x and cadr for the y values. See if helps. Quote
Lee Mac Posted January 26, 2010 Posted January 26, 2010 This: (defun c:se (/ ent obj d delta dx dy se) (vl-load-com) (if (setq ent (entsel "\nSelecione a LINHA: ")) (progn (setq obj (vlax-ename->vla-object (car ent))) (setq d (vla-get-delta obj)) (setq delta (vlax-safearray->list (vlax-variant-value d))) (setq dx (car delta)) (setq dy (c[color=Red][b]a[/b][/color]dr delta)) (setq se ( / dy dx)) (princ se) ) ) [color=Red][b](princ)[/b][/color] ) Quote
LEsq Posted January 26, 2010 Posted January 26, 2010 or... simple remove the princ call at all, that way it will return the last value on the command line. Quote
Lee Mac Posted January 26, 2010 Posted January 26, 2010 or... simple remove the princ call at all, that way it will return the last value on the command line. Or that - yes BlackAlnet, Just for your own benefit, I recommend you read this article in the Visual LISP Editor help files: Quote
BlackAlnet Posted January 26, 2010 Author Posted January 26, 2010 @ LEEMAC Your code is elegant as always. I'm still missing on small things, i think it's because my little experience on LISP. Many thanks for your help mate Quote
BlackAlnet Posted January 26, 2010 Author Posted January 26, 2010 Or that - yes BlackAlnet, Just for your own benefit, I recommend you read this article in the Visual LISP Editor help files: Yes, i always goes on this help, but the lacking of examples make it harder to learn.But is trying the best way to learn, isnt it? =) I'm very grateful for your help. Thanks!! Quote
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.