Would like some help please

Would like some help please

RBernaz
Advocate Advocate
874 Views
10 Replies
Message 1 of 11

Would like some help please

RBernaz
Advocate
Advocate

As I'm still not aware of how to program Lisp, I would like some help.

 

I have a block which represent a mast. And I have a few along the route.

The block has an attribute which is the mast number. Usually the attribute text value is aligned with the bylayer properties, but sometimes I have to change the attribute value properties of some of them, but I have always to do one by one. 

Is it possible to have a code which I can change the attribute value properties by selecting only a few mast blocks and change it all one by one or all of them which are selected at once?

The properties I need most is the color text value and the plot style, but if it's possible all properties it would be better. Can be done with dialog box? 

 

Thank you in advance for your help

Best regards

  

  

0 Likes
Accepted solutions (3)
875 Views
10 Replies
Replies (10)
Message 2 of 11

Sea-Haven
Mentor
Mentor

Post a sample dwg. Makes life easier.

0 Likes
Message 3 of 11

RBernaz
Advocate
Advocate

Hi, thank you very much for your reply

Sure, I send you an example

There are only 4 attribute which I want to be able to do it, I put them in red

I cannot use the byblock because the are entities that are not related and already have the byblock solution 

 

Regards

0 Likes
Message 4 of 11

Sea-Haven
Mentor
Mentor
Accepted solution

This resets the color of all attributes in one block could be changed to a select all blocks of same name etc, but you have way more than 4 attributes in the block. So more questions.

 

 

 

(defun c:test ( / atts att obj)
(setq obj (vlax-ename->vla-object (car (entsel "\nSelect a block object "))))
(setq atts (vlax-invoke obj 'Getattributes))
(foreach att atts
(vlax-put att 'Color 4) ; color cyan 4
)
(princ)
)

 

 

  

0 Likes
Message 5 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

Possibly like this. 

 

btw It's always good to avoid using special characters in names/tags and so on. It just makes trouble. One time is like this, second like that.

 

eekeeCZ_0-1712829397662.png

 

 

(vl-load-com)

(defun c:AttMatchColor ( / e s i att)
  
  (if (and (setq e (car (nentsel "\nSelect source att: ")))
	   (setq e (vlax-ename->vla-object e))
	   (not (vl-catch-all-error-p (setq g (vl-catch-all-apply 'vla-get-tagstring (list e)))))
	   (not (vl-catch-all-error-p (setq c (vl-catch-all-apply 'vla-get-color (list e)))))
	   (setq s (ssget '((0 . "INSERT") (66 . 1))))
	   )
    (repeat (setq i (sslength s))
      (setq blk (vlax-ename->vla-object (ssname s (setq i (1- i)))))
      (foreach att (vlax-invoke blk 'getattributes)
	(if (= g (vla-get-tagstring att))
	  (vla-put-color att c)))))
  (princ)
  )


(defun c:AttMatchSTB ( / e s i att)
  
  (if (and (setq e (car (nentsel "\nSelect source att: ")))
	   (setq e (vlax-ename->vla-object e))
	   (not (vl-catch-all-error-p (setq g (vl-catch-all-apply 'vla-get-tagstring (list e)))))
	   (not (vl-catch-all-error-p (setq c (vl-catch-all-apply 'vla-get-plotstylename (list e)))))
	   (setq s (ssget '((0 . "INSERT") (66 . 1))))
	   )
    (repeat (setq i (sslength s))
      (setq blk (vlax-ename->vla-object (ssname s (setq i (1- i)))))
      (foreach att (vlax-invoke blk 'getattributes)
	(if (= g (vla-get-tagstring att))
	  (vla-put-plotstylename att c)))))
  (princ)
  )

 

0 Likes
Message 6 of 11

RBernaz
Advocate
Advocate

It works, but not as I would like it to be, I would like to be able to have the option of choosing the attribute to change, because the same block can have a different color in each attribute value. That's why I've suggested the dialog box.

Don't  have to do in all blocks at once, it can be by choosing one by one and choosing which attribute to change

 

Thank you very much for your help

 

0 Likes
Message 7 of 11

RBernaz
Advocate
Advocate

Thank you, it work and its a very good solution, not as I was thinking, but can do the job very very well.

Although I would like to ask you if it is possible to join the color and plot style change in one single command.

 

Regards

0 Likes
Message 8 of 11

RBernaz
Advocate
Advocate

Is it possible to match the chosen picked attribute instead of choosing the picked block? to match attribute one by one 

 

Thank you very much for your help

Regards

 

0 Likes
Message 9 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution
0 Likes
Message 10 of 11

RBernaz
Advocate
Advocate

Thank you it seems very good, but... doesn't includes "Plot style", is it possible  to improve it?

 

Regards 

0 Likes
Message 11 of 11

RBernaz
Advocate
Advocate

I've done it, 

 

Thank you very much 

 

Regards

 

0 Likes