Get attribute value and test for specific value

Get attribute value and test for specific value

Anonymous
Not applicable
4,203 Views
23 Replies
Message 1 of 24

Get attribute value and test for specific value

Anonymous
Not applicable

I would like to put all blocks collected into groups or arrays or lists... lisp is weird... by and attribute value... pole_id then I need to draw a polyline according to the "drop_order".  Please help me.

 

Here is the code I have so far which draws by "drop_order" all the blocks selected but I need it to sort them by the "pole_id" first then draw polylines for each group separately.

 

This code is taken from snippets from a Lee Mac answer a long time back.

 

(defun C:PP-CARDBIP ; = CONNECT BLOCKS BY INSERTION POINTS - ORIGINALLY LBS
  (/ *error* ent fmt idx ins ocs par sel spc txt typ uxa ss blk att blkinslist)
  ;(prompt "\nTo Link Blocks with Lines in Attribute Sequence,")(if (setq ss (ssget '((0 . "INSERT") (66 . 1) (2 . "ACMAP_ANN_TEMPLATE_PERMIT-FEATURES") ))); could omit (66 . 1)*
  (prompt "\nTo Link Blocks with Lines in Attribute Sequence,")
  (if (setq ss (ssget '((0 . "INSERT") (66 . 1) (2 . "ar_drop_point") ))); could omit (66 . 1)*
    (progn ; then
      (repeat (setq n (sslength ss)); step through selection set
        (setq
          blk (ssname ss (setq n (1- n))); Block entity name
          att (entnext blk); Attribute entity name
          blkinslist ; list of integer equivalents of Attribute values paired with insertion points
             (cons
              (list 
				;(atoi 
					;(princ(LM:getattributevalue att "COMMENT_1"))
					(princ(LM:getattributevalue att "drop_order"))
					;(cdr 
					;	(assoc 1 (entget att)
					;	); assoc
					;); cdr
				;); atoi - turns string into integer
				
				; gets the insertion point here
				(trans 
					(cdr 
						(assoc 10 
							(entget blk)
						); assoc
					); cdr
					0 1
				); trans
				; finish getting the insertion points
			  ); list
              blkinslist
            ); cons
        ); setq
      ); repeat
      (setq blkinslist ; replace former content
        (mapcar 'cadr ; keep only insertion points after:
          (vl-sort blkinslist '(lambda (a b) (< (car a) (car b)))); sorting in Attribute-value order
        ); mapcar
      ); setq	  
	  	  	  
	  (command "-COLOR" 6) 
	  (command "")
      (command "_.pline"); consider Polyline instead, possibly with specified width
      (apply 'command blkinslist); feed points to Line command
      (command ""); end Line command 		
	  
	  
	  ;(LM:inputfootage); call text input - might work on this later but have seperated the two
	  
    (princ)
    ); progn
	(prompt "\nNo PERMIT-FEATURE Blocks selected."); else
  ); if  ACMAP_ANN_TEMPLATE_PERMIT-FEATURES
); defun

 

0 Likes
Accepted solutions (1)
4,204 Views
23 Replies
Replies (23)
Message 21 of 24

Anonymous
Not applicable

It doesn't work.  It is drawing a continues pline between the drops.  Thanks though.

 

It needs to draw every pole on the maps drops with one command.  Otherwise the user has to go to each location and run the command.

 

But yes I don't know lisp at all really.  I've learned bits a pieces but no much.

0 Likes
Message 22 of 24

pbejse
Mentor
Mentor

@Anonymous wrote:

It needs to draw every pole on the maps drops with one command.  Otherwise the user has to go to each location and run the command.


I see, what you're needing is creating a connection between the same group. The routine can be easily modifed to do that.

The thing is, on your sample drawing, "POLE_ID" doesnt even have values, there's no way to truly test how YOU wanted the program to work. and you keep changing the condition.  

 

Thats about it from me though.

 

BTW: The routine works to some degree, just not the way YOU wanted it to be.

 

0 Likes
Message 23 of 24

Anonymous
Not applicable

Welp I don't know lisp enough to do it.  And I realize that.  I am not sure why you are being so passive-aggressive.  I had forgotten because of the late nights I'm putting in so yea screwed that up a bit.  Oh well.  This was just icing on the cake.  I'll be having it draw to WKT format soon enough so it will not even need a lisp.  For now, unless someone sheds light on how to get this one modified or provides another solution I'm good.

0 Likes
Message 24 of 24

pbejse
Mentor
Mentor

@Anonymous wrote:

I am not sure why you are being so passive-aggressive.  I had forgotten because of the late nights I'm putting in so yea screwed that up a bit.  Oh well.  This was just icing on the cake.


 

Annoying isn't it? Same way when you offer to help and being told what you contributed doesnt even work, granting the information you are working on isnt even complete.

 

I can assure you that this forum will provide the help you need, but please do your part. 

 


@Anonymous wrote:

I'll be having it draw to WKT format soon enough so it will not even need a lisp.  For now, unless someone sheds light on how to get this one modified or provides another solution I'm good.


Would you like to start over again? I need to see this topic all sorted for my own sanity. It doesnt even need to be me who finished it. I'm also having late nights thinking about it 😁. So I say that makes us even-steven.

 

.A program should be able to determine the grouping based on our latest condition

"POLE_ID" , "ID" then "DROP_ORDER".   

 

  • Post an exampe that all three has values wherein the program can make a distinction between groups. 
  • What will be "POLE_ID" tag values?  even for the other 2. This is important when determining the order, sorting the ID with both alpha and numeric characers are a bit tricky
  • Will this be unique only for "ar_drop_point" block?  Tag names will differ depending on the block name, so sorting via tag names will be also be factor. The block tags_left has "POWER_TAG" and "TEL_TAG" etc...
  • Tell us moe about WKT fromat.