regroup a group you have ungrouped in AutoLisp

regroup a group you have ungrouped in AutoLisp

Anonymous
Not applicable
3,688 Views
27 Replies
Message 1 of 28

regroup a group you have ungrouped in AutoLisp

Anonymous
Not applicable

I hope you enjoyed the title

 

Hello, I'm new to my job and I'm asked to rotate an object inside a group, without rotating it as a whole.

The only way I'm seeing is to ungroup it, rotate the said object and regroup the objects once more.

The problem is, I don't know how to identify every member of the group before ungrouping, so i could make a list to regroup later.

 

I hope you understood my problem and any parallel thinking is welcome, since this is my third day using AutoLisp

0 Likes
Accepted solutions (2)
3,689 Views
27 Replies
Replies (27)
Message 21 of 28

ВeekeeCZ
Consultant
Consultant

@ronjonp wrote:

@ВeekeeCZ wrote:

@ronjonp wrote:

@ВeekeeCZ wrote:

Yep, pickadd is 2. (acad 2020)

Tried all values, no relation to the issue.


You're right .. I was picking the objects individually and not a crossing selection.


No, no... can't select them either way.

What type of entities are on your gif, are they polylines? That could work. But not if they are lines or anything else


Yup .. that's the issue. I had all polylines in the group. Other items do not work. That seems a bit half baked ;/


That's a different feature. Ctrl allows you to select a segment of a polyline. I use that a lot to remove a segment. Unfortunately, not many more functions support this... not even explode... So still half baked.

0 Likes
Message 22 of 28

ronjonp
Mentor
Mentor

So if that's the case and @martin_leiter has rectangles ( closed plines ) then the cntrl selection should work right? Either way setting PICKSTYLE to 0 gives the opportunity to modify any object within a group easily.

0 Likes
Message 23 of 28

ВeekeeCZ
Consultant
Consultant

@martin_leiter wrote:

Hello rperez,
I have another question about this useful Lisp.
With the object selection in this Lisp one can select only one object.
How can I select multiple objects in the same group?

can you show me this?
Thank you!

Greetings Martin


 

Feeling generous today 😉

 

(defun c:GIRotate (/ pcf pst)
  (setq pcf (getvar 'pickfirst)) (setvar 'pickfirst 0)
  (setq pst (getvar 'pickstyle)) (setvar 'pickstyle 0)
  (command-s "_.ROTATE")
  (setvar 'pickfirst pcf)
  (setvar 'pickstyle pst)
  (princ)
  )
0 Likes
Message 24 of 28

ronjonp
Mentor
Mentor

Haha .. I just penned the same thing:

(defun c:foo (/ *error* s v)
  (defun *error* (m)
    (and v (setvar 'pickstyle v))
    (or (wcmatch (strcase m) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " m " **")))
    (princ)
  )
  (setq v (getvar 'pickstyle))
  (setvar 'pickstyle 0)
  (if (setq s (ssget ":L"))
    (command "_.ROTATE" s "")
  )
  (setvar 'pickstyle v)
  (princ)
)
0 Likes
Message 25 of 28

ronjonp
Mentor
Mentor

And at the risk of beating this dead horse to a bloody pulp 🙂 , can also do something like this so that native editing commands can be used.

(defun c:foo nil
  ;; List of commands to fire *psreactor* reactor
  (setq *pscmdlst* (strcase "ERASE,MOVE,ROTATE,ARRAY"))
  (or *psreactor*
      (setq *psreactor*
	     (vlr-command-reactor
	       nil
	       '((:vlr-commandwillstart . strtcmd)
		 (:vlr-commandended . endcmd)
		 (:vlr-commandcancelled . cnclcmd)
		 (:vlr-commandfailed . faldcmd)
		)
	     )
      )
  )
  (setq *savedpsvar* (getvar 'pickstyle))
  (defun strtcmd (calling-reactor strtcmdinfo / name)
    (cond
      ((wcmatch (car strtcmdinfo) *pscmdlst*) (setvar 'pickstyle 0) (princ "\nPickstyle set to 0"))
    )
  )
  (defun endcmd	(calling-reactor endcmdinfo / thecmdend)
    (cond ((and *savedpsvar* (wcmatch (car endcmdinfo) *pscmdlst*))
	   (setvar 'pickstyle *savedpsvar*)
	   (princ (strcat "\nCommand ended Pickstyle restored to " (itoa *savedpsvar*)))
	  )
    )
  )
  (defun cnclcmd (calling-reactor cnclcmdinfo / thecmdcncl)
    (cond ((and *savedpsvar* (wcmatch (car cnclcmdinfo) *pscmdlst*))
	   (setvar 'pickstyle *savedpsvar*)
	   (princ (strcat "\nCommand cancelled Pickstyle restored to " (itoa *savedpsvar*)))
	  )
    )
  )
  (defun faldcmd (calling-reactor faldcmdinfo / thecmdfald)
    (cond ((and *savedpsvar* (wcmatch (car faldcmdinfo) *pscmdlst*))
	   (setvar 'pickstyle *savedpsvar*)
	   (princ (strcat "\nCommand failed Pickstyle restored to " (itoa *savedpsvar*)))
	  )
    )
  )
  (princ)
)

 

0 Likes
Message 26 of 28

marko_ribar
Advisor
Advisor

I only accidently read this topic and all I can see is very unneccessary attempts to answer to question that is somewhat cumbersome... There is no need to code anything... I am using ACAD for years and never had this problem... I also didn't know for the tip my coleague showed me long time ago... All you need is to temporarily deactivate grouping selection and reactivate it again when task finished... To activate/deactivate grouping selection secret key combination is ctrl+shift+A... That's all needed and I use it very often while working with groups...

Regards, M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 27 of 28

ronjonp
Mentor
Mentor

ctrl+shift+A that's the magical key combo! Thanks Marko 🙂

0 Likes
Message 28 of 28

martin_leiter
Advocate
Advocate

Hello Ronjonp,
this reactor could be very useful when executing the copy command and the copied objects into the group
be integrated from which they were copied.
That would be very helpful with this great reactor.

Warm greetings
Martin

0 Likes