Jump to content

cad coders help! about: groups


bonacad

Recommended Posts

groupnk8.jpg

 

Where this value goes?

For 2 days i search this stuff.

Anyway, here is the problem:

 

I am creating UNNAMED group with Lisp.

 

1. While creating group in that way (without dial.bx), there is no option for

new groups to be selectable or not.

Command: -GROUP

Enter a group option

[?/Order/Add/Remove/Explode/REName/Selectable/Create] : c

Enter a group name or [?]: *

 

2. Because im creating unnamed grups i cannot use this after:

-GROUP Enter a group option

[?/Order/Add/Remove/Explode/REName/Selectable/Create] : s

Enter a group name or [?]: - I dont know the name -

 

3. The last value remains IN THAT check box determine are new groups selectable or not.

 

It is not system variable value.

It is not registry value, because when u open new drawing its set to ON.

It must be one of the local Lisp variables.

 

note: When open Group dialog box, that value is FLOATING, and when exiting on CANCEL or OK or CLOSE, value stays remembered!.

Link to comment
Share on other sites

Unnamed group name is string with "*A" + random number and you cannot to know it. This numbers contains into groups dictionary, for example:

 

((-1 . ) (0 . "DICTIONARY") (5 . "D") (102 . "{ACAD_REACTORS") (330 . ) (102 . "}") (330 . ) (100 . "AcDbDictionary") (280 . 0) (281 . 1) (3 . "*A1") (350 . ) (3 . "*A2") (350 . ) (3 . "dasfadsf") (350 . ))

 

More easy way - create unnamed groups with ENTMAKEX function. DXF-code 70 is “Unnamed” flag: 1 = Unnamed; 0 = Named, DXF-code 71 is Selectability flag: 1 = Selectable; 0 = Not selectable, DXF-group 300 is group description.

 

(defun c:ugr(/ grSet eLst)
(princ "\n<<< Select object to make unnamed group >>>")
 (if(setq grSet(ssget))
   (progn
     (setq eLst(append(list '(0 . "GROUP") '(100 . "AcDbGroup")
		     '(300 . "") '(70 . 1) '(71 . 1))
     (mapcar '(lambda(x)(cons 340 x))
	 (vl-remove-if 'listp
                   (mapcar 'cadr(ssnamex grSet))))
       ); end append
    ); end setq
       (entmakex eLst)
      (sssetfirst nil grSet)
     ); end progn
   ); end if
 (princ)
); end of c:ugr

Link to comment
Share on other sites

bonacad, this will return the name of a last created group

(cdr
 (assoc 3
 (reverse
   (entget
     (cdadr
       (member (cons 3 "ACAD_GROUP") (entget (namedobjdict)))
     )
   )
 )
 )
)

ASMI, groups created with your code will last as long as the document is open. close the document and groups are gone.

that's what i use.

(defun CreateGroup
	      (Name EntsList SelFlag / GroupDic EntName)
 (if (and (setq GroupDic (cdadr (member (cons 3 "ACAD_GROUP")
				 (entget (namedobjdict))
			 )
		  )
   )
   (not
     (and Name (vl-position (cons 3 Name) (entget GroupDic)))
   )
   (setq
     EntName (entmakex
	       (append (list (cons 0 "GROUP")
			     (cons 100 "AcDbGroup")
			     (cons 300 "")
			     (cons 70
				   (if Name
				     0
				     1
				   )
			     )
			     (cons 71 SelFlag)
		       )
		       (mapcar (function (lambda (e) (cons 340 e)))
			       EntsList
		       )
	       )
	     )
   )
   (entmod (append (entget GroupDic)
		   (list (cons 3
			       (if (null Name)
				 "*"
				 Name
			       )
			 )
			 (cons 350 EntName)
		   )
	   )
   )
     )
   (if	Name
     Name
     (cdadr
(member (cons 350 EntName) (reverse (entget GroupDic)))
     )
   )
 )
)
;;;(CreateGroup nil (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget)))) 1)

Link to comment
Share on other sites

> VovKa

 

You are right. "ACAD_GROUP" dictionary need to append a new group name and ename. You have nice function for group creation. There is my "ready to use" function for unnamed groups creation.

 

(defun c:ugr(/ grSet eLst nGrp grDic nNam)
(princ "\n<<< Select object to make unnamed group >>>")
 (if(setq grSet(ssget))
   (progn
     (setq eLst(append(list '(0 . "GROUP") '(100 . "AcDbGroup")
		     '(300 . "") '(70 . 1) '(71 . 1))
     (mapcar '(lambda(x)(cons 340 x))
	 (vl-remove-if 'listp
                   (mapcar 'cadr(ssnamex grSet))))
       ); end append
    ); end setq
       (setq nGrp(entmakex eLst)
      grDic(append grDic
	     (entget(cdadr(member '(3 . "ACAD_GROUP")
	      (entget (namedobjdict)))))
		(list(cons 3 "*")(cons 350 nGrp)))
      ); end setq
     (entmod grDic)
     ); end progn
   ); end if
 (princ)
); end of c:ugr

Link to comment
Share on other sites

Thank you guys very much.

Very useful informations & methods.

I appreciate that.

Now I'm able to get from my lisp exactly what i want.

Link to comment
Share on other sites

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