Set layer polyline by attribute

Set layer polyline by attribute

djurk_haas
Advocate Advocate
1,595 Views
6 Replies
Message 1 of 7

Set layer polyline by attribute

djurk_haas
Advocate
Advocate


Hello,

 

See the lisp code in the attachment.

The code works fine; it changes the layer of the block to the layer wich is given in an attribute in the block itselfs.

Is it possible to (also) change the layer of an "linked" polyline in that block? This polyline is linked through a field in an attribute with an object (See attached jpg).

For example the dwg is also included.

 

Tanks in advance.

 

0 Likes
Accepted solutions (1)
1,596 Views
6 Replies
Replies (6)
Message 2 of 7

Moshe-A
Mentor
Mentor

@djurk_haas  hi,

 

why don't you move the polyline it inside that block? if you can't do that then your better solution is MATCHPROP

 

moshe

 

0 Likes
Message 3 of 7

djurk_haas
Advocate
Advocate
Thanks for your reply.
Do you have a lisp code for that solution with match properties?

0 Likes
Message 4 of 7

Moshe-A
Mentor
Mentor
Accepted solution

@djurk_haas ,

 

try this lisp,  each run select only 2 objects the block + it's polyline 

 

enjoy

moshe

 

 

; Djurk Haas Matchprop
(defun c:DHMP (/ ss i elist ename lay)
 (if (and
       (setq ss (ssget (list '(-4 . "<or")
			   	'(0 . "lwpolyline")
			   	'(-4 . "<and")
			   		'(0 . "insert") '(66 . 1)
			    	'(-4 . "and>")
 			   '(-4 . "or>")
		      )
	       )
       )
       (= (sslength ss) 2) ; only a block + it's polyline at a time
     )
  (progn
   (setq i -1)
   (repeat (sslength ss)
    (setq elist (entget (setq ename (ssname ss (setq i (1+ i))))))
     
    (if (eq (strcase (cdr (assoc '0 elist))) "INSERT")
     (progn
      (setq lay (getpropertyvalue ename "HANDLEBLOK")); get layer name
      (command "._chprop" "_si" ss "_layer" lay "")	    
     ); progn  
    ); if		 
   ); repeat
  ); progn
 ); if

 (princ)
)
0 Likes
Message 5 of 7

Moshe-A
Mentor
Mentor

@djurk_haas 

 

please close this thread and mark it as your solution

 

thank you

moshe

 

0 Likes
Message 6 of 7

djurk_haas
Advocate
Advocate


Thanks a lot for your code works really fine but it is not what I'm looking for.

I'm trying to get a link between the blockattribute and the 'connected' polyline.

 

In the attachment is an earlier lsp that put's the area and lenght of the seleted polyline to the specified attributes (VLOEROPP - OMTREK) in the lisp code.

Maybe it is possible to add some code so that this lisp also put the handle, of the selected polyline, into the TAG: HANDLE.

 

I have the code

(cdr (assoc 5 (entget en)))

that shows the handle of an entity.  So what I want to arcieve is that this output is writing down to the block attribute HANDLE.

 

Thanks a lot for your help

0 Likes
Message 7 of 7

Moshe-A
Mentor
Mentor

@djurk_haas ,

 

really sorry, up till now i did not fully understand what you want, but of course there is a solution

 

do you write code activex? cause there is a method (function) called (vla-fieldcode) that returns the field as string

inside is the object id of the polyline - can you continue from here?

 

moshe

 

0 Likes