insane Posted December 21, 2014 Share Posted December 21, 2014 (edited) Hello people i am new in autolisp programing, i have simple question. how to show x and y coordinates and block name of selected shape in alertbox? my example(not working): (defun c:get (/ pt) (setq pt (getpoint (entsel "\nSpecify point: "))) (alert pt) (princ) ) Edited December 22, 2014 by SLW210 Code Tags Quote Link to comment Share on other sites More sharing options...
hmsilva Posted December 21, 2014 Share Posted December 21, 2014 Welcome to CADTutor, insane! Your code revised (defun c:get (/ pt) (if (setq pt (getpoint "\nSpecify point: ")) (alert (strcat "X = " (rtos (car pt)) "\nY = " (rtos (cadr pt)))) ) (princ) ) And the block and the x,y coordinates (vl-load-com) (defun c:demo ( / ins name obj ss) (if (setq ss (ssget "_+.:E:S" '((0 . "INSERT")))) (progn (setq obj (vlax-ename->vla-object (ssname ss 0)) name (vla-get-effectivename obj) ins (vlax-get obj 'insertionpoint) ) (alert (strcat "Block Name = " name "\nX = " (rtos (car ins)) "\nY = " (rtos (cadr ins)) ) ) ) ) (princ) ) Henrique Quote Link to comment Share on other sites More sharing options...
insane Posted December 21, 2014 Author Share Posted December 21, 2014 Well big thank you ! almost forgot to ask (if (setq ss (ssget "_+.:E:S" '((0 . "INSERT")))) what does this line? and this (setq obj (vlax-ename->vla-object (ssname ss 0)) name (vla-get-effectivename obj) ins (vlax-get obj 'insertionpoint) ) Quote Link to comment Share on other sites More sharing options...
hmsilva Posted December 21, 2014 Share Posted December 21, 2014 You're welcome, insane. ;; if select a single block (if (setq ss (ssget "_+.:E:S" '((0 . "INSERT")))) (progn ;; Transforms the firts selected object to a VLA-object (setq obj (vlax-ename->vla-object (ssname ss 0)) ;; get the effective name from the block object name (vla-get-effectivename obj) ;; get the insertionpoint from the block object ins (vlax-get obj 'insertionpoint) ) Henrique Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 21, 2014 Share Posted December 21, 2014 Here is a little lisp that allows you to pick a object and see its properties it can be used with VLisp to Vla-get a property or VLA-put a new property. If you pick a block you will see the "Insertionpoint" "Scale" "Rotation" etc A point is normally made up of 3 parts X Y Z using x=car y=Cadr and z=Caddr you can get the individual info, another method is nth, x= nth 0 pt, y=nth 1 pt, Z=nth 2 pt. ;; Dump all methods and properties for selected objects ; ;;;===================================================================; ;;; DumpIt ; ;;;-------------------------------------------------------------------; ;;;===================================================================; (defun C:DumpIt ( / ent) (while (setq ent (entsel)) (vlax-Dump-Object (vlax-Ename->Vla-Object (car ent)) T ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Faouweb Posted December 30, 2014 Share Posted December 30, 2014 Hi How can I ad Z value to this code: (defun c:get (/ pt) (if (setq pt (getpoint "\nSpecify point: ")) (alert (strcat "X = " (rtos (car pt)) "\nY = " (rtos (cadr pt)))) ) (princ) ) Thank you Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 30, 2014 Share Posted December 30, 2014 Hi How can I ad Z value to this code: Replace this part (strcat "X = " (rtos (car pt)) "\nY = " (rtos (cadr pt)) "\nZ = " (rtos (caddr pt))) Quote Link to comment Share on other sites More sharing options...
Faouweb Posted December 30, 2014 Share Posted December 30, 2014 Thank you very much Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 30, 2014 Share Posted December 30, 2014 Thank you very much You are welcome All credit goes to Henrique Quote Link to comment Share on other sites More sharing options...
hmsilva Posted December 30, 2014 Share Posted December 30, 2014 All credit goes to Henrique Nice what you've said, my friend. But all the credits for the modification are going to you Tharwat. Cheers Henrique Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 31, 2014 Share Posted December 31, 2014 Tharwat You can lead a horse to water but it may not drink, in my post z=caddr given 237 posts would have thought starting to learn. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 31, 2014 Share Posted December 31, 2014 Tharwat ............. , in my post z=caddr given 237 posts would have thought starting to learn. Be more clear and straight to the point please , I am listening . 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.