Need help to combine two routines..

Need help to combine two routines..

danglar
Advocate Advocate
420 Views
3 Replies
Message 1 of 4

Need help to combine two routines..

danglar
Advocate
Advocate

I tried to combine two different routines into one program.

First routine align selected set of objects ( blocks and texts) along one X/Y/Z axis of a reference point and second one can rotate selected set of objects to

0 angle (see attached lisp)

I use a same set of objects for these routines and don't wont' to select objects twice..

I tried to use (ssget "L") function for second routine but something goes wrong..

Another question:

Is it possible to set different rotation angle for preselected set of entities by user prompt?

Any help will be very appreciated.

 

0 Likes
421 Views
3 Replies
Replies (3)
Message 2 of 4

hmsilva
Mentor
Mentor

Hi apelbaum2014,

 

try to change the "_:L" to "_P"

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 3 of 4

Kent1Cooper
Consultant
Consultant

@apelbaum2014 wrote:

....

I use a same set of objects for these routines and don't wont' to select objects twice..

I tried to use (ssget "L") function for second routine but something goes wrong..

Another question:

Is it possible to set different rotation angle for preselected set of entities by user prompt?

.... 


One part uses ss as a variable name for a VLA selection set, and the other for a regular entity-names selection set.  One way to use the same one for both would be to change the approach in the second to use (vla) methods, but maybe it's easier to just use two variables, one as entity names and one as VLA objects, something like [untested]:

....

  (if (setq ss (ssget "_:L" '((0 . "INSERT,MTEXT,MULTILEADER,TEXT")))); entity-name selection
    (progn
      (setq ang (AT:UCSAngle))
      (vlax-for x (setq ss-vla (vla-get-activeselectionset *AcadDoc*)); VLA-object selection
....
      (vla-delete ss-vla)
....


;; (if (setq ss (ssget '((0 . "INSERT,*TEXT")))) ; omit this line [ss already exists]
(repeat (setq i (sslength ss)); using entity-name selection from before

....

 

If you really don't want the second half applied to Multileaders that may be in the original selection, since they're not in the filter list for the second half, you would need to test for entity type within the second half.

 

For the rotation question, just ask for one somewhere near the top:

(setq userang (getangle "\nRotation to force on selected object(s): "))

 

That allows typed entry in any valid angle-units format, or picking of two points on-screen.  Then wherever it "puts" 0. onto an object for rotation or textrotation, use that 'userang' variable instead.  In the case of what it does with its own 'ang' variable, you would probably need to replace:

 

  (vla-put-rotation x ang)

 

with something like [again, untested]:

 

  (vla-put-rotation x (+ ang userang))

Kent Cooper, AIA
0 Likes
Message 4 of 4

danglar
Advocate
Advocate

Thank You Kent!

All is clear..

0 Likes