Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VLA-MOVE a Selection Set

8 REPLIES 8
Reply
Message 1 of 9
mike
3732 Views, 8 Replies

VLA-MOVE a Selection Set

I wrote a lisp program which creates a selection set using ssget. Then I use the bounding box commands to get the lowest point of that selection set. Now I want to move that selection set as a whole using the vla-move command. I am having trouble doing this. Is this possible? Can we vla-move a selection set? Is there a workaround? Thanks.

8 REPLIES 8
Message 2 of 9
Anonymous
in reply to: mike

It should I just tried this and it worked.

 

(vla-move myCircle maxpoint minpoint)

 

You just need to adjust the variables to what you are using.

Message 3 of 9
_Tharwat
in reply to: mike

If you show your codes that would be much better  , anyway here is one way of using vla-move function .

 

(vla-move  (vla-object) (vlax-3d-point p1) (vlax-3d-point p2))

 

I guess according to what you have said , your codes did not work maybe because you did not converted them to vla .

 

Tharwat

Message 4 of 9
Kent1Cooper
in reply to: mike


@mike wrote:

I wrote a lisp program which creates a selection set using ssget. .... Now I want to move that selection set as a whole using the vla-move command. I am having trouble doing this. Is this possible? Can we vla-move a selection set? Is there a workaround? ....


It seems (vla-move) wants a single VLA object.  Selection sets can apparently only contain entity names [at least, (ssadd) won't add a VLA object to a selection set].  So it looks to me like it isn't possible, directly.

 

The workaround that comes to mind, if you must use (vla-move), is to make the selection set into a list of VLA objects, and (vla-move) them all individually from the list.  [For a lark, I tried (vla-move) on a whole list of VLA objects all together, and that didn't work, either.]

 

Or, use Move in a (command) or (vl-cmdf) function, which can move a selection set all together.

Kent Cooper, AIA
Message 5 of 9
dgorsman
in reply to: mike

The (vla-Move...) function is different from the "MOVE" command.  Its actually a method of an Entity-type object, therefore you need to call it for each entity in turn (after you convert it to a vla-type object, of course).  You could accomplish this by looping over the contents of the selection set, in turn converting each entity and then calling the Move method.  If you are doing other things with the entities in the selection set, it might make more sense to convert that selection set to a list of vla-type objects first then work the list for each set of operations needed to save the overhead of converting entities each time.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 6 of 9
_Tharwat
in reply to: mike

(if 
(and (setq p1 (getpoint "\n Specify Base point :")) (setq p2 (getpoint "\n Specify Next point :")) (setq ss (ssget "_:L")) ) (repeat (setq i (sslength ss)) (vla-move (vlax-ename->vla-object (ssname ss (setq i (1- i)))) (vlax-3d-point p1) (vlax-3d-point p2)) ) (princ) )

 

Tharwat

 

Message 7 of 9
Lee_Mac
in reply to: _Tharwat

This may be a little more efficient:

 

(defun c:test ( / p1 p2 sel )
    (if
        (and
            (ssget "_:L")
            (setq p1 (getpoint "\nBase Point: "))
            (setq p2 (getpoint p1 "\nDisplacement: "))
        )
        (progn
            (setq p1 (vlax-3D-point (trans p1 1 0))
                  p2 (vlax-3D-point (trans p2 1 0))
            )
            (vlax-for obj
                (setq sel (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
                (vla-move obj p1 p2)
            )
            (vla-delete sel)
        )
    )
    (princ)
)
(vl-load-com)

 

Message 8 of 9
_Tharwat
in reply to: Lee_Mac

Really very clever and efficient your codes below Lee  ....

 

 (vlax-for obj
                (setq sel (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
                (vla-move obj p1 p2)
            )
            (vla-delete sel)

 

Message 9 of 9
Lee_Mac
in reply to: _Tharwat

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost