Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

can anybody upgrade my lisp please ?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
E.S.7.9
409 Views, 3 Replies

can anybody upgrade my lisp please ?

hi everybody ,

 

i have a lisp routine which i can change my spesific attribute block values in entire drawing but i need a little bit help for to make it much usefull..

the routine is changing middle text string value according to last text string value but in this code i need to specify my block name ( red one )  and values for condition ( blue one )  and middle text string value ( orange one ) in everytime i want to change values

 

i want to specify my block name by which attribute block i desire to select from drawing and i want to specify condition values and result text in command line ..

 

can anybody help ?

 

my attribute block is   AA - DN?? - 5000

 

and

 

my  lisp code is here :

 

(defun c:chdim (/ ss i atts val new1)
  (if (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1) (2 . "my attribute block name"))))
    (repeat (setq i (sslength ss))
      (setq atts (vlax-invoke (vlax-ename->vla-object (ssname ss (setq i (1- i)))) 'GetAttributes)
            val  (atoi (vla-get-textstring (cadr atts)))
      )
      (if (setq new1 (cond ((<= 0. val 10000.) "DN20"))
          )
        (vla-put-textstring (car atts) new1)
      )
    )
  )
  (princ)
)
(vl-load-com)
(princ)

 

thank you

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: E.S.7.9

 

 

Trying to understand your post there,

from what I can tell, you're wanting to be able to call this routine

and then be able to select which block you're going to edit, via selecting on the attribute for that block (in your drawing).

You can accomplish this by replacing your ssget filter with (nentsel), you would still want to keep the (setq ss....) part though.

 

If i understand correctly and you wish to be able to enter in the values (in dark blue) for each time you run the routine, then you could do it by replacing this line

 (if (setq new1 (cond ((<= 0. val 10000.) "DN20"))

 with

(if
(and
(setq val1 (getreal "Enter first value/lower limit:"))
(setq val2 (getreal "Enter second value/max limit:"))
);and
  
(setq new1 (cond ((<= val1 val val2) "DN20"))
          );setq
);if

(if new1
    (vla-put-textstring (car atts) new1))
(princ "Values not accepted. Try again.")
);if
....at end of the routine be sure to include
(setq new1 nil)

 Or similar. Untested, hopefully it shows a somewhat workable method, if i've understood your intentions correctly.

HTH

Message 3 of 4
E.S.7.9
in reply to: Anonymous

hi bhull1985

 

your code is working , thank you for your help  ... just remained one point i need to help about

 

in this row     (if (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1) (2 . "my attribute block name"))))     i have to spesify block name manualy but i dont want to ,  because there are different attribute blocks with different names , so i wanna select my block from drawing and lisp going to realise that it has to put this block name to code , how can i do it ? can you  help me in this point please ..

 

thank you

 

Message 4 of 4
Anonymous
in reply to: E.S.7.9

E.S.7.9, hey, glad to hear most of the code worked for you.

Try this for selecting attributed blocks to run your code on:

(setq ss (ssget '((0 . "INSERT")(66 . 1))))

 This will put you with a cursor for selecting a block. It can be any block, as long as that block has attributes. And then the selected block will be assigned to variable SS, which you can begin processing as normal

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost