samifox Posted January 1, 2014 Posted January 1, 2014 Hi as a part of the lisp i need to move the last drawn object 25 units, im using (command "move" "" "L" "" "" 25) its not working and i would like to know why any way i dont like to use command inside the lisp , how can i do it another way? Quote
ymg3 Posted January 1, 2014 Posted January 1, 2014 (command "move" "L" "" "" 25) or you could use entmod. But there is nothing wrong with using "command for this case. Quote
Tharwat Posted January 1, 2014 Posted January 1, 2014 What was the last entity and how did you create it ? Quote
samifox Posted January 1, 2014 Author Posted January 1, 2014 What was the last entity and how did you create it ? it was entmakex is there any way to move rather to use a command entry? Quote
samifox Posted January 1, 2014 Author Posted January 1, 2014 (command "move" "L" "" "" 25) or you could use entmod. But there is nothing wrong with using "command for this case. command way is much slower Quote
Tharwat Posted January 1, 2014 Posted January 1, 2014 it was entmakex is there any way to move rather to use a command entry? Sure , and what is the entity name of that object ? Quote
Tharwat Posted January 1, 2014 Posted January 1, 2014 Here are four ways demonstrating how to move a Circle object 25 units on the X grid . (setq e (entmakex (list '(0 . "CIRCLE") '(10 0. 0. 0.) '(40 . 1.0)))) ; First (entmod (append (entget e) '((10 25. 0. 0.)))) ; Second (entmod (subst '(10 25. 0. 0.) (assoc 10 (entget e)) (entget e)) ) ; Third (vlax-invoke (vlax-ename->vla-object e) 'move '(0. 0. 0.) '(25. 0. 0.) ) ; Forth (vla-move (vlax-ename->vla-object e) (vlax-3d-point '(0. 0. 0.)) (vlax-3d-point '(25. 0. 0.)) ) Quote
samifox Posted January 1, 2014 Author Posted January 1, 2014 Here are four ways demonstrating how to move a Circle object 25 units on the X grid . (setq e (entmakex (list '(0 . "CIRCLE") '(10 0. 0. 0.) '(40 . 1.0)))) ; First (entmod (append (entget e) '((10 25. 0. 0.)))) ; Second (entmod (subst '(10 25. 0. 0.) (assoc 10 (entget e)) (entget e)) ) ; Third (vlax-invoke (vlax-ename->vla-object e) 'move '(0. 0. 0.) '(25. 0. 0.) ) ; Forth (vla-move (vlax-ename->vla-object e) (vlax-3d-point '(0. 0. 0.)) (vlax-3d-point '(25. 0. 0.)) ) you are STRONG! Thanks:) Quote
Tharwat Posted January 1, 2014 Posted January 1, 2014 you are STRONG!Thanks:) Haha ... you're welcome . Quote
Snownut Posted January 1, 2014 Posted January 1, 2014 Tharwat, How do those methods perform with Blocks containing attributes ? Quote
Tharwat Posted January 1, 2014 Posted January 1, 2014 Tharwat, Strong like .....? Do you think this reply or phrase is accepted ? Quote
Snownut Posted January 1, 2014 Posted January 1, 2014 Tharwart, sorry if I offended, samifox's choice of words is just a bit off, since this is a www website I should be a bit more understanding of members trying to use the english language, I would be no better trying to use his. Quote
Tharwat Posted January 1, 2014 Posted January 1, 2014 I don't think that samifox's reply obtain any meaning in that regard , but I guess that he wanted to bring a message of powerful or very qualified person and things like that , but not a strong like metallic or concreate or even animals . Back to your question in post No# 11 , you can use the third and the forth answers that I already given to samifox and you can not use the entmod with Attributed blocks which would behave oddly , try it yourself to find out . Quote
Lee Mac Posted January 1, 2014 Posted January 1, 2014 How do those methods perform with Blocks containing attributes? Since the attribute references are separate entities to the parent block reference entity, if using entmod to modify the DXF data of the block reference you would also need to modify the DXF data of each attribute reference accordingly, e.g.: (defun moveblk ( ent pt1 pt2 / enx ins vec ) (setq enx (entget ent) ins (assoc 10 enx) vec (mapcar '- pt2 pt1) ) (if (entmod (subst (cons 10 (mapcar '+ (cdr ins) vec)) ins enx)) (entupd ent) ) (if (= 1 (cdr (assoc 66 enx))) (progn (setq ent (entnext ent) enx (entget ent) ) (while (= "ATTRIB" (cdr (assoc 0 enx))) (if (and (zerop (cdr (assoc 72 enx))) (zerop (cdr (assoc 74 enx))) ) (setq ins (assoc 10 enx)) (setq ins (assoc 11 enx)) ) (if (entmod (subst (cons (car ins) (mapcar '+ (cdr ins) vec)) ins enx)) (entupd ent) ) (setq ent (entnext ent) enx (entget ent) ) ) ) ) ) Testing program: (defun c:test ( / ent pt1 pt2 ) (if (and (setq ent (ssget "_+.:E:S" '((0 . "INSERT")))) (setq pt1 (getpoint "\nBasepoint: ")) (setq pt2 (getpoint "\nNext point: " pt1)) ) (moveblk (setq ent (ssname ent 0)) (trans pt1 1 ent) (trans pt2 1 ent) ) ) (princ) ) When using the vla-move ActiveX method or the move command, the attribute references are automatically translated with the block reference. Quote
Snownut Posted January 1, 2014 Posted January 1, 2014 Lee - Thanks that works perfectly. Tharwat - Your 3rd & 4th examples work fine also for blocks with entities. For a one size fits all approach this would be the options to use. Bruce Quote
Snownut Posted January 1, 2014 Posted January 1, 2014 One last question or point, will the VLA functions fail if objects are not on the graphical screen when called. The entmod function has no such limitation (all works fine whether on screen or not). Quote
Tharwat Posted January 2, 2014 Posted January 2, 2014 Tharwat - Your 3rd & 4th examples work fine also for blocks with entities. For a one size fits all approach this would be the options to use. Bruce Happy to hear that . One last question or point, will the VLA functions fail if objects are not on the graphical screen when called. AFAIK no , but let us know how you do use the code and what is the code you use to move objects . Quote
Lee Mac Posted January 2, 2014 Posted January 2, 2014 will the VLA functions fail if objects are not on the graphical screen when called. No, the ActiveX methods can successfully operate on any drawing object, visible on-screen or hidden in any drawing layout (even in unopened drawings, using ObjectDBX). 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.