Request for Modifications on an Existing Lisp to Label Plant Blocks

Request for Modifications on an Existing Lisp to Label Plant Blocks

Anonymous
Not applicable
2,869 Views
21 Replies
Message 1 of 22

Request for Modifications on an Existing Lisp to Label Plant Blocks

Anonymous
Not applicable

Hi fellow CAD Friends,

 

I am in search of a Lisp Routine for labelling plant material in a Landscape Plan which is a regular work flow at my current job. On a typical project we have to label anywhere between 1000-5000 plants some times as groups or as individual plants.

 

My crude logic (I guess) would be: the user will preselect a Layer, Multi-leader Style and Text Style in the working drawing.

Run the Lisp: LabelBlock (LB), AssignBlockLabel (ABL) - LISP Routine Initiation command - or some thing of the Programmers Choice..

Select the Block to label

Ask User input for Plant Key : A or BB or d or cc - changes in different drawings for different plant material

Selection Window the blocks you want to label at a time - Selection can be more than one type of blocks, but the program should only count the user selected block initially.

Count the number of the 'user specified block type' inside the selected window

Program should ask the user for insertion point (the Arrow Point) of multileader)

Then the multileader will have text contents as : eg: 3-A or 5-BB or 7-d or 345-cc depending on the number of blocks selected by user. The most important point here is the Plant Key format in multileader - should be (number, hyphen, plant-key alphabet) without any spaces. This will enable us to do the check and verification for tallying number of plant blocks and number of plant labels in the drawings using Find Command.

 

I found this great lisp as a starting point - Programmed by Mike- (Thank you!!!  Mike). This lisp  is awesome. Thanks for the effort you put in helping the community. Really appreciate your good work. This lisp can be found here:

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/count-objects-and-edit-existing-text...

 

I don't know much about lisp other than the  working knowledge of using it. In this Lisp, Is there a way to give a key to the text in multileader rather than returning the entire block name in the label? So if I run this lisp it will start as intended, select the block, The lisp should ask for Block Key - (user inputs could be A or BB or a or xx or any text), window the blocks I want to count, then use the current Multi-leader style selected, insert the Multi-leader in the current layer,  and the text should read 10-A or 12-BB or 6-a or 4-xx, where these numbers are the actual blocks selected. The key here is adding a hyphen and the 'User input alphabet' with out any spaces. I don't know if we add the plant key  as an attribute to the block (when the block is inserted into the current drawing), whether the lisp can automate the process taking that info while inserting the text ( number, hyphen, plant-key (from attribute info inside block definition) format).

 

This will be great help if you can do this for me.

 

Thanks in advance.

 

VM

0 Likes
Accepted solutions (1)
2,870 Views
21 Replies
Replies (21)
Message 2 of 22

devitg
Advisor
Advisor

Please upload your true  and real DWG . State before and after 

0 Likes
Message 3 of 22

pbejse
Mentor
Mentor

@Anonymous wrote:

Hi fellow CAD Friends,

 

I am in search of a Lisp Routine for labelling plant material in a Landscape Plan ......

 

I found this great lisp as a starting point - Programmed by Mike- (Thank you!!!  Mike). This lisp  is awesome. Thanks for the effort you put in helping the community. Really appreciate your good work. This lisp can be found here:

 

...

 

Thanks in advance.

 

VM


I want to take part of this. It would be nice If you can provide a simple drawing to give us a better idea, I may not know a lot of landscape stuff but know enough of lisp to say what you're asking is doable.

 

0 Likes
Message 4 of 22

Anonymous
Not applicable

Hi all,

 

Please see the file  and the LISP routine which I currently used ( developed by mkweaver (Mike)) uploaded as requested. Please let me know if you need any other information.

 

Thanks and Regards,

 

VM

0 Likes
Message 5 of 22

pbejse
Mentor
Mentor

@Anonymous wrote:

Hi all,

 

Please see the file  and the LISP routine which I currently used ( developed by mkweaver (Mike)) uploaded as requested. Please let me know if you need any other information.

 

Thanks and Regards,

 

VM


Before I download the files, question is, Does it work for you?  Did you get the result you wanted? Say I'll run the code on the attached files, what am I expecting to see? Does it show the correct format and values? or just the current result from using the accompanying lisp code by mkweaver?

 

Surely you can tell us more 🙂  ---> and yes your name is not surely

 

0 Likes
Message 6 of 22

Anonymous
Not applicable

Hi pbejse,

 

Before I download the files, question is, Does it work for you?  Yes, but not fully. Instead of the block name , I would like to get the block attribute value to get inserted in the Multileader contents.

Did you get the result you wanted? Not fully. This is the reason for the Lisp modification/ revision request.

Say I'll run the code on the attached files, what am I expecting to see? The lisp should count the blocks selected by a selection  window, get the attribute value from the block, insert with the block count number, a hyphen, and the attribute value in the multileader contents, and ask the user for the insertion point of the multileader. Please review the requests in my original post.

Does it show the correct format and values? or just the current result from using the accompanying lisp code by mkweaver? The current list routine is giving the block name in the multileader. I would like to see the  plant key instead.

 

Hope this answers your queries.

 

Regards,

 

VM

0 Likes
Message 7 of 22

pbejse
Mentor
Mentor

@Anonymous wrote:

Hi pbejse,

....

 

The current list routine is giving the block name in the multileader. I would like to see the  plant key instead.

 

Hope this answers your queries.

 

Regards,

 

VM


I'll see what i can do....

0 Likes
Message 8 of 22

Anonymous
Not applicable

Thank you very much! Really appreciate your help.

 

Regards,

 

VM

0 Likes
Message 9 of 22

Anonymous
Not applicable

Hi pbejse,

 

I found this lisp routine online ( not sure whom to give credit to - all credits to the original programmer))  to extract the attribute info from a block. Just a starting point , I guess. Please review if this can be of any help.

 

Regards,

 

VM

0 Likes
Message 10 of 22

pbejse
Mentor
Mentor

@Anonymous wrote:

Hi pbejse,

 

.....The current list routine is giving the block name in the multileader. I would like to see the  plant key instead.

 VM


If we do this 

, and the attribute value in the multileader content

 

Does that mean we don't need to do this?

Ask User input for Plant Key 

 

The routine  below is the modified code of mkweaver, which ask for USER input

 

;;;BlockCounttoText - allows the user to select block insertions then places the number of blocks selected
;;; along with the name of a sample block selected into the text value of a selected text
;;; Note - this filters the blocks based on the selected sample block.
;;; Note - The sample block is added to the selection
;;;
;;; 10/7/15 - Added Error handler and improved prompting.
(defun c:bct2 (/  ss1 ent  bname RemoveDuplicates-mp1 _PickpointForMleader cmdecho NoMutt OldError)
;;	Block Count to Text
;;	local function definition
      (defun RemoveDuplicates-mp1 (lst / foo temp)
	;;from here: http://www.theswamp.org/index.php?topic=4144.0
	    (defun foo (x)
		  (cond	((vl-position x temp) t)
			((setq temp (cons x temp)) nil)
		  ) 
	    ) 
	    (vl-remove-if 'foo lst)
      )

;;								     ;;

(defun _PickpointForMleader ( pt / en NextPoint)
      (prompt "\nSelect text for block count: <Enter to pick point>")
      (setq en 
      (if (setq en (ssget "_+.:S:E" '((0 . "MULTILEADER"))))		
	  (ssname en 0)
	  (progn
		(setq NextPoint (getpoint pt "\nPick Next point:"))
		(command "_Mleader" pt NextPoint "")
		(entlast)
		)
	  )
      )
      )
      
;;								     ;;
      
      (setq OldError *ERROR*)
      (defun *ERROR* (msg)
	    (if	cmdecho
		  (setvar "cmdecho" cmdecho)
	    ) 
	    (setvar "nomutt" 0)
	    (setq *ERROR* OldError)
	    (princ msg)
      ) 
      ;;end local functions
      (if *push-error-using-stack*
	    (*push-error-using-stack*)
      ) 
      (while (and (setq ent1 (entsel "\nSelect sample block: "))
		  (= "INSERT"
		     (cdr (assoc 0 (setq elist (entget (car ent1)))))
		  ) 
		  (setq BlockKey (getstring "\nEnter Block Key: "))
		  (setq obj (vlax-ename->vla-object (car ent1)))
		  (princ (strcat "\nSelected "
				 (vla-get-effectivename obj)
				 ", select blocks to count: "
			 ) 
		  ) 
		  (setq	temp	  (setvar "nomutt" 1)
			cmdecho	  (getvar "cmdecho")
			temp	  (setvar "cmdecho" 0)
			ss1	  (ssget (list '(0 . "INSERT")))
			ss1	  (if (and ss1 (< 0 (sslength ss1)))
					(ssadd (car ent1) ss1)
					(ssadd)
				  ) 
			temp	  (setvar "nomutt" 0)
			blockname (vla-get-effectivename
					(vlax-ename->vla-object
					      (car ent1)
					) 
				  ) 
			blocklist (RemoveDuplicates-mp1
					(vl-remove-if-not
					      (function
						    (lambda (x)
							  (and	(= 'ename
								   (type x)
								) 
								(=    blockname
								      (vla-get-effectivename (vlax-ename->vla-object x))
								) 
							  ) 
						    ) 
					      ) 
					      (apply 'append
						     (ssnamex ss1)
					      ) 
					) 
				  ) 
		  ) 
		  (princ (strcat "\n"
				 (itoa (length blocklist))
				 " instances of "
				 blockname
				 " selected."
			 ) 
		  )
;;										;;
		  		  			
		  (setq ent (_PickpointForMleader (vlax-get obj 'InsertionPoint)))		  

;;										;;
		  
		  (vlax-property-available-p
			(setq objText
				   (vlax-ename->vla-object ent)
			)
			'textstring
		  ) 
	     ) 
	    (vla-put-textstring objText
		  (strcat (itoa (length blocklist))
			
;;			  " "
;;;			  (vla-get-effectivename
;;;				(vlax-ename->vla-object (car ent1))
;;;			  ) ;_ end of vla-get-effectivename
			
			"-" BlockKey			
		  ) 
	    ) 
      ) 
      (if *push-error-using-stack*
	    (*pop-error-mode*)
      ) 
      (setvar "cmdecho" cmdecho)
      (setvar "nomutt" 0)
      (princ)
) 

 

We can modify this code to read the attribute key of the initial block selected, and filter the selected blocks to count if the attribute key is not a match.

Is this something you need?

 

BTW: how would the user know if the blocks are already a part of an initial count? there isn't any indication that a block is indeed part of a count.

 

 

 

 

0 Likes
Message 11 of 22

Anonymous
Not applicable

Hi Pbejse,

Oh My goodness!!! You have done an Amazing Amazing Job!!! I am so excited (1) for the turn around in this request (2) how customizable it has become. Truly incredible work. Thank you very much on this both for you and mkweaver- the initial scripter.

  1. If we do this, and the attribute value in the multileader content

Does that mean we don't need to do this? Ask User input for Plant Key 

The reason I would like to keep both options is:

Let by default, the program take the attribute value ( IF the attribute value for “KEY” is present inside the Plant Block)

ELSE, ask the user for Plant Key input, just to make the Lisp more user friendly.

 

  1. The routine  below is the modified code of mkweaver, which ask for USER input

We can modify this code to read the attribute key of the initial block selected, (Please review my reply to Item 1) and filter the selected blocks to count if the attribute key is not a match. Is this something you need? (I personally do not want this because, then there will be more chance for user error, and could make the life of user difficult remembering/ checking up the Plant Keys).

  1. BTW: how would the user know if the blocks are already a part of an initial count? there isn't any indication that a block is indeed part of a count. ( Yes , I know we do not have a way to do this, but I think this is going to be not that important (because, then we may have to make a reference or connection between the already selected blocks and the ones we do not selected yet), Moreover, in my personnel work flow, I have to do plant counts sheet by sheet ( City submission requirement)

For more clarification on the Work Flow:

  1. User inserts Plant block into the current drawing, and provides attribute value to ”KEY” at prompt. So ideally at this point all the plant blocks in the drawing has the correct plant keys as attributes in respective blocks.
  2. User pre-assigns the Layer for Plant Labels
  3. User makes the Attributed Plant Block User pre-assigns the Multileader Style (Multileader is pre-stylized with correct Text Style)
  4. At this point we will Run the Lisp BCT2 
  5. Program asks for Sample Block Selection by User (Restrict to Pick only ONE Plant Block)

If No Plant Key attribute value is present in the User Selected Sample Block:

Then: the program should ask the user for a Plant Key input ( A, or BB or cc or C1 etc. any alpha numeric value can be used as a Plant Key.)

IF Plant KEY attribute is present in the selected block, 

Program returns (a) the selected Sample Plant Block’s name (b) and Plant KEY attribute value (already present attribute value, or user recently provided Key) in Command Line – for User Confirmation

 

 

(aa)        Then the program should ask the User to select the blocks he want to label (both by Window Selection and by Pick Selection). The selection can continue until the user enters the Enter Key.

 

The program should check for whether all the attribute values are same for the User selected Sample type of Plant Block present in the selection set. If there are different “KEY” attribute values for the same type of blocks selected by the user, The program should give an error message saying “Plant Keys are not the same !!! Please check and Verify the Plant Key values in Blocks.”

 

Program can again ask the user to select another set of blocks. (Same type of plant block initially selected by user as Sample Block.)

 

Then the Lisp should count the number of plant blocks included in the user’s selection set Please NOTE: only the plant type initially selected by user should be included in the count, NOT all the different kinds of blocks in the window selection)

 

Then the program should ask the user for the Insertion Point of the Multileader (ideally this will be the center point on one of the plant blocks in the user’s selection set, or where ever the user clicks)

 

The program then inserts the multileader, in the pre-assigned Layer and pre-assigned Multileader Style. (The Multileader should have plant Block Count number, followed by a Hyphen, and the Attribute Value from the Plant Block- WITHOUT any spaces in between all three.)

 

Then the program should ask “Select Another Sample Plant to Label:” < Type E to exit>

                And the program should Run Again or Exit as per User’s input.

 

This is all I can think of, as for logic. Sorry I have no expertise in programming, just was trying to explain the usual work flow here.

 

Sorry, the numbering all changed when I copy Pasted from Word. Hope you can still follow the work Flow.

 

Thanks again for your help and support. Have a blessed day!!!

VM

0 Likes
Message 12 of 22

pbejse
Mentor
Mentor

@Anonymous wrote:

 

If No Plant Key attribute value is present in the User Selected Sample Block:

Then: the program should ask the user for a Plant Key input ( A, or BB or cc or C1 etc. any alpha numeric value can be used as a Plant Key.)

  

VM


The only blocks on your sample drawing where that statement is true are:

  • "Shrub-Calgary Carpet Juniper"
  • "Shrub-Mop's Mugo Pine"
  • "Shrub-Blue Prince Juniper"
  • "Shrub-Prince of Wales Juniper"

These blocks are reported as non-attributed blocks on your sample drawingBUT when the user invokes the ATTSYNC command, then the attributes will appear and has a value of "zz" as the default.As far as I can tell, there is not a "DEC*" or "Shrub-*" block that doesn't have the KEY tag attribute. 

 

Is this by design or by accident? 


Vince_Aquarian wrote: 

 

(aa)  Then the program should ask the User to select the blocks he want to label (both by Window Selection and by Pick Selection). The selection can continue until the user enters the Enter Key. 


Blocks? This is after selecting the Sample Block Selection meaning more than one labeled block? My understanding is the USER will select which block to put the label via multileader then move on to the next until users press the Enter key. 


Vince_Aquarian wrote:  

The program should check for whether all the attribute values are same for the User selected Sample type of Plant Block present in the selection set. If there are different “KEY” attribute values for the same type of blocks selected by the user, The program should give an error message saying “Plant Keys are not the same !!! Please check and Verify the Plant Key values in Blocks.”


Does that mean to terminate the command and let the user "fix" the KEY values? The user can actually SEE what is being selected. It would look the same as the Sample Block selection but different KEY value. OR

.. Program can again ask the user to select another set of blocks. (Same type of plant block initially selected by user as Sample Block.)  

and ignore the warning and eventually forgets about it.


Vince_Aquarian wrote: 
......... 

The rest is clear. Don't get upset with all these questions VM, we're just making sure we got everything covered from the get-go and not having the OP asking "another thing..." and "another..".  

 

Answer the queries above AND some other things that you may think are important enough to add at this stage. then we'll proceed with the coding.

 

Cheers

0 Likes
Message 13 of 22

Anonymous
Not applicable

Vince_Aquarian wrote:

 

If No Plant Key attribute value is present in the User Selected Sample Block:

Then: the program should ask the user for a Plant Key input ( A, or BB or cc or C1 etc. any alpha numeric value can be used as a Plant Key.)

  

VM


The only blocks on your sample drawing where that statement is true are:

  • "Shrub-Calgary Carpet Juniper"
  • "Shrub-Mop's Mugo Pine"
  • "Shrub-Blue Prince Juniper"
  • "Shrub-Prince of Wales Juniper"

These blocks are reported as non-attributed blocks on your sample drawingBUT when the user invokes the ATTSYNC command, then the attributes will appear and has a value of "zz" as the default.As far as I can tell, there is not a "DEC*" or "Shrub-*" block that doesn't have the KEY tag attribute. 

 

Is this by design or by accident? 

Sorry, Pbejse. That was just an accident. I should have updated the default key of "zz" to the respective plant keys when I copied the block to site. So all the plant blocks in the left side (the legend) has right keys as attributes in them. I apologize for this mistake, I should have checked the drawing more carefully.


Vince_Aquarian wrote: 

 

(aa)  Then the program should ask the User to select the blocks he want to label (both by Window Selection and by Pick Selection). The selection can continue until the user enters the Enter Key. 


Blocks? This is after selecting the Sample Block Selection meaning more than one labeled block? My understanding is the USER will select which block to put the label via multileader then move on to the next until users press the Enter key. 

 

Please read that "blocks" as " group of plant blocks the user want to select that particular labelling instance" . Yes, you are correct the user will first select the Sample Block, if there is no attribute built in the selected sample block, then it will ask the user to provide Plant Key, then the program will ask the user to select all the plant blocks the user intends to label at that labelling instance. This second selection process has to be done with both drag window selection as well as pick selection. Also ( just for clarification) the "Enter Key" in the last sentence means computer's Return key, not Plant Block Key.


both with window selection as well as pick selectionVince_Aquarian wrote:  

The program should check for whether all the attribute values are same for the User selected Sample type of Plant Block present in the selection set. If there are different “KEY” attribute values for the same type of blocks selected by the user, The program should give an error message saying “Plant Keys are not the same !!! Please check and Verify the Plant Key values in Blocks.”


Does that mean to terminate the command and let the user "fix" the KEY values? Yes, You are Correct. The user can actually SEE what is being selected. .Yes. IF I understand correctly, soon after the sample block is selected, right? It would look the same as the Sample Block selection but different KEY value. OR Did not understand fully the question here, but will explain the process later again.

.. Program can again ask the user to select another set of blocks. (Same type of plant block initially selected by user as Sample Block.)  

and ignore the warning and eventually forgets about it. If I put it in another words, When the user does the second group block selection just prior to inserting multileader, the program should pre-verify all the blocks in the second group selection set has the same attribute values as with the sample blocks attribute values. If the sample block  and the blocks in the group selection set has different attribute value, the program should warn the user that some of the attribute values are different from the sample block's attributes and here the plant counts may go wrong.

 

 


Vince_Aquarian wrote: 
......... 

The rest is clear. Don't get upset with all these questions VM, we're just making sure we got everything covered from the get-go and not having the OP asking "another thing..." and "another..". I totally understand. No issues with questions. Lets make this as user friendly and robust as we can.  

 

Answer the queries above AND some other things that you may think are important enough to add at this stage. then we'll proceed with the coding.

 

Cheers

0 Likes
Message 14 of 22

Anonymous
Not applicable

Hi Pbejse,

 

Did you get some time to look into my request. You could be very busy as well. Please let me know if you need more info/ details.

 

Regards,

VM

0 Likes
Message 15 of 22

pbejse
Mentor
Mentor

@Anonymous wrote:

Hi Pbejse,

 

Did you get some time to look into my request. You could be very busy as well. Please let me know if you need more info/ details.

 

Regards,

VM


Sorry about that VM, give me a day or two to post a reply,  got sidetrack is all.

 

 

0 Likes
Message 16 of 22

Anonymous
Not applicable

Hi Pbejse,

 

No Problem. Take your time. I could imagine how busy you are. Thanks for your help.

 

Regards,

 

VM

0 Likes
Message 17 of 22

Anonymous
Not applicable

Hi Pbejse,

 

Any chance to look further into my request? did you get any time?

 

Regards,

 

VM

0 Likes
Message 18 of 22

pbejse
Mentor
Mentor

Vince

 

Apologies for seemingly running out on you, I'm working on a code now, just reviewing what was discussed earlier 🙂

 

hang on... 

0 Likes
Message 19 of 22

Anonymous
Not applicable

No Problem Pbejse. Just checking if everything is ok on your side.

 

Thanks  and regards,

 

VM

0 Likes
Message 20 of 22

pbejse
Mentor
Mentor
Accepted solution

Try this

 

;;;BlockCounttoText - allows the user to select block insertions then places the number of blocks selected	
;;; along with the name of a sample block selected into the text value of a selected text			
;;; Note - this filters the blocks based on the selected sample block.						
;;; Note - The sample block is added to the selection								
;;;
;;; 10/7/15 - Added Error handler and improved prompting.

(defun c:bct2 (/  	_SelectBlockToCount _GetBlockKey ss1 ent  bname RemoveDuplicates-mp1 en
               		cmdecho NoMutt OldError ValidselectedBlocks NextPoint pt included		)

;;								     	;;
      
(defun _SelectBlockToCount (e bn bk / ss temp bls atb)
      
;;;			TO INLCUDE ANONYMOUS NAMES			;;;
  
(and 	(setq ssv (ssadd)
                ss (ssget (list '(0 . "INSERT")(cons 2 (strcat "`*U*," bn)))))
	     (setq ss (if (ssmemb e ss)(ssdel e ss) ss))
	     (repeat (setq i (sslength ss))
			(setq ent 	(vlax-ename->vla-object (ssname SS (setq i (1- i))))
	                      blockname (strcase (vla-get-effectivename ent)))
	           
	        (if (and (eq blockname (strcase bn))
	                 (setq ValidTag (vl-some '(lambda (at)
	                                 (if (and (eq (vla-get-tagstring at) "KEY")
	                                          (eq (vla-get-textstring at) BlockKey)) at)) 
	                 					(vlax-invoke ent 'GetAttributes)))
	                 (eq bk (vla-get-textstring ValidTag))
	                 )
	                 
	                 
	            	(ssadd  (ssname SS i) ssv)
	            )
	           )
	     )
	(if (ssmemb e ss) ss  (ssadd e ss))
      )
      
(defun _GetBlockKey (e / atb f)
     (if
	   (and (minusp (vlax-get e 'HasAttributes))
      		(setq atb (mapcar '(lambda (at)(list (vla-get-tagstring at)
				 (vla-get-textstring at)))
      		(vlax-invoke e 'GetAttributes)))
		(Setq f (assoc "KEY" atb))
		)
	(cadr f)
	(getstring "\nEnter Block Key: ")
	   )
      )
	    
      
;;								     ;;
      
      (setq OldError *ERROR*)
      (defun *ERROR* (msg)
	    (if	cmdecho
		  (setvar "cmdecho" cmdecho)
	    ) 
	    (setvar "nomutt" 0)
	    (setq *ERROR* OldError)
	    (princ msg)
      ) 
      ;;end local functions
      (if *push-error-using-stack*
	    (*push-error-using-stack*)
      )
      (while (and (setq ValidselectedBlocks nil
                             ent1 (entsel (if en "\nSelect Another Sample Plant to Label: < Type E to exit >"
                                         "\nSelect sample block: ")))
                  (/= ent1 "E")
		  (= "INSERT"
		     (cdr (assoc 0 (setq elist (entget (setq esb (car ent1))))))
		  ) 
		  (setq obj (vlax-ename->vla-object esb))
		  (setq  BlockKey (_GetBlockKey obj))		  
		  (princ (strcat "\nSelected "
				 (setq blockname (vla-get-effectivename obj))
				 ", Key Value: \"" BlockKey "\", select blocks to count: " 
			 ) 
		  )
                    (setq	temp	  (setvar "nomutt" 1)
				cmdecho	  (getvar "cmdecho")
				temp	  (setvar "cmdecho" 0))
                  (progn
	                  (while
	                        (not
		                        (and
			                        (or ValidselectedBlocks
	                                            (setq ValidselectedBlocks (_SelectBlockToCount esb blockname BlockKey))
	                                            )
						(princ (strcat "\n"
							 	(itoa (sslength ValidselectedBlocks))
							 	" instances of " blockname  " selected."))
	                                        (princ "\nSelect Block To label: ")
	                                        (setvar "nomutt" 1)
	       					(setq en (ssget "_+.:S:E" (list '(0 . "INSERT")(cons 2 blockname))))
		       				(setvar "nomutt" 0)                        
		                              	(setq included (ssmemb  (ssname en 0) ValidselectedBlocks))
	                                      )
	                              )
	                        (alert
	                              (cond
	                                    (	(null ValidselectedBlocks) "No Blocks Selected\n Invalid Seclection")
	                                    (	(null en) "No Block for label Selected")
	                                    (	(null included) "Block Selected not part of selection")
	                                    )
	                              )
	                        )
                        	
                                (setq NextPoint
                                           (getpoint
                                                 (setq pt   (cdr  (assoc 10 (entget (ssname en 0)))))
                                                 "\nPick Next point:"))
                        )
			(progn
                              (command "_Mleader" "_non" pt "_non" NextPoint "")              		
                              (vla-put-textstring (vlax-ename->vla-object (entlast))
		  				(strcat (itoa (sslength ValidselectedBlocks))	"-" BlockKey	))
                  		(not (initget "E"))
                  	)
	    		)
            )
	     
      (if *push-error-using-stack*
	    (*pop-error-mode*)
      ) 
      (setvar "cmdecho" cmdecho)
      (setvar "nomutt" 0)
      (princ)
) 

HTH

0 Likes