I have a simple string to GROUP all objects in a drawing. I would like to match the GROUP name with the DWG name (but not actually have ".dwg" in the name of the group). So Dwg "BLOCK.DWG" has a Group name "BLOCK"
(command "-group" "n" "DWG NAME HERE" "" "all" "")
I want the pick point at 0,0. I can't find a way to define the pick point of a group (?) It seems to center the pickpoint on the objects defined in the group. How do I keep the GROUP pickpoint at 0,0?
Thanks
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Solved by hmsilva. Go to Solution.
For the "DWG NAME HERE", use:
(getvar 'dwgname)
For the group point, try "0,0".
A group of all is mysterious.
Hi,
Groups hasn't a pick point, the have grip at the center of the grouped objects (the center of the extent of the grouped objects), to show that grip, you need to set PICKSTYLE system variable in the range 1-3. About the name of the drawing, you can get the name only (without extension) with:
(substr (setq dwgname (getvar "dwgname")) 1 (- (strlen dwgname) 4))
Gaston Nunez
Gaston,
I get this error message and the routine craps out
Enter a group name or [?]: (substr (setq dwgname (getvar *Invalid*
; error: Function cancelled
Enter a group name or [?]:
The problem is not from Gaston's code, is from your prompt sequence...
Try
(command "-group" "_C" (substr (setq dwgname (getvar "dwgname")) 1 (- (strlen dwgname) 4)) "" "all" "") ;; or (vl-load-com) (command "-group" "_C" (vl-filename-base (getvar "dwgname")) "" "all" "")
Henrique
Henrique, that works great! Thanks!
One more thing please. I cannot figure out why this won't ungroup objects. Thanks
(command “UNGROUP” “all” “y”)
You're welcome, m_rogoff.
I'm without AutoCAD, so untested, but try:
(command "_.ungroup" "all") (while (> (getvar 'cmdactive) 0) (command "Y") )
Henrique
Stevor,
Let me elaborate on your point "A group of all is mysterious".
I have objects inside of a block grouped into a single group. When you insert the block, it comes in on pre-defined layers. Once the block is exploded, you are left with a group of the objects with the same name as the block. Now the user can define the layer properties as needed. Hope this explains the Mystery.
Henrique,
Sorry to bother you again, but I am having trouble with this lisp. It runs fine with ACad open and run independently. However, I have a batch routine that prompts a script, which loads and runs this lisp. Then it closes ACad and re-opens the next file in the folder and runs the script and lisp again. The lisp command is failing when run as part of the entire batch routine. Please advise. Lisp is attached. Thanks
THIS IS COMMAND LINE WHEN RUN INDEPENDENTLY
Command: _.ungroup
Select group or [Name]: all
Explode 1 groups? [Yes/No] <N>: Y
1 groups exploded.
Command: nil
WHEN RUN AS PART THE BATCH ROUTINE
Command: _.ungroup
Select group or [Name]: all
Explode 1 groups? [Yes/No] <N>: Y
1 groups exploded.
Command: Y Unknown command "Y". Press F1 for help.
Command: nil
Command: Specify opposite corner or [Fence/WPolygon/CPolygon]:
Command: *Cancel*
Hi m_rogoff,
I have no AutoCAD with me at the moment, therefore fully untested...
(vl-load-com) (defun C:HARDWARE (/ groups) (command "-layer" "s" "0" "") (command "_.chprop" "all" "" "layer" "0" "c" "bylayer" "lw" "bylayer" "") (if (setq groups (vla-get-groups (vla-get-activedocument (vlax-get-acad-object)))) (vlax-for group groups (command "_.ungroup" "_N" (vla-get-name group)) ) ) (princ) )
Hope that helps
Henrique
In the above code, change
(if (setq groups (vla-get-groups (vla-get-activedocument (vlax-get-acad-object))))
to
(if (and (setq groups (vla-get-groups (vla-get-activedocument (vlax-get-acad-object)))) (> (vla-get-count groups) 0) )
Henrique
Can't find what you're looking for? Ask the community or share your knowledge.