Jump to content

Recommended Posts

Posted

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?

Posted

(command "move" "L" "" "" 25)

 

or you could use entmod. But there is nothing wrong with using "command for this case.

Posted
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?

Posted
(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

Posted
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 ?

Posted

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.))
)

Posted
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:)

Posted

Tharwat, How do those methods perform with Blocks containing attributes ?

Posted
Tharwat, Strong like .....?

 

Do you think this reply or phrase is accepted ?

Posted

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.

Posted

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 .

Posted
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.

Posted

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

Posted

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).

Posted

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 .

Posted
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).

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...