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

Modify code issue

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
cummins600
353 Views, 6 Replies

Modify code issue

I'm having some issues trying to get the existing code to just select the text (only one per dwg) on layer "Floor_Label" rather than the entsel. Any tips would be very nice.

 

(defun c:m1 ( / e en entype pt)
; (setq txt1 (ssget "X" (list (cons 8 "Floor_Label"))))
(setq e (entsel) en (car e) entype (cdr (assoc 0 (entget en))))
(if (or
(= entype "HATCH")
(not (setq pt (cdr (assoc 10 (entget en)))))
)
(setq pt (nth 1 e))
)
(command "move" en "" pt)
)

6 REPLIES 6
Message 2 of 7
gjrcmb
in reply to: cummins600

Try following for Text Entity or Replace "TEXT" with "MTEXT" if Multiline Text:

 

(setq txt1 (ssget "X" '((0 . "TEXT")(8 . "Floor_Label"))))

 

OR if you prefer

 

(setq txt1 (ssget "X" (list '(0 . "TEXT")(cons 8 "Floor_Label"))))

 

OR another option

 

(setq txt1 (ssget "X" (list (cons 0 "TEXT")(cons 8 "Floor_Label"))))

 

 I like the first option, but there may be times when you need to use the other options if you are using variables to set the entity type or layer name.

Message 3 of 7
pbejse
in reply to: cummins600


@cummins600 wrote:

I'm having some issues trying to get the existing code to just select the text (only one per dwg) on layer "Floor_Label" rather than the entsel. Any tips would be very nice.

 


You can cut it down to specifics by using a known values.


(ssget "_X" '((0 . "TEXT")(8 .  "Floor_Label")(1 . "StringValue")));<--- known string value\Layer

(ssget "_X" '((0 . "TEXT")(8 .  "Floor_Label")(40 . 2.50)(1 . "StringValue")));<--- known string valueLayer\Text Height

 

50 for rotaition 7 for textstyle and so on.....

 

HTH

 

 

 

Message 4 of 7
cummins600
in reply to: cummins600

Yes, those are good ones! Still trying to get rid of the (entsel) and replace with the known text selection so the user will not be prompted.

Message 5 of 7
pbejse
in reply to: cummins600


@cummins600 wrote:

Yes, those are good ones! Still trying to get rid of the (entsel) and replace with the known text selection so the user will not be prompted.



Yes. thats exactly what those lines of codes  do for you.

The  "X in conjunction with ssget function will AUTOMATICALLY select the entity for you

 

Like

(defun c:m1  (/ e en entype pt)
      (if (and (setq txt1 (ssget "X"
                                 '((0 . "TEXT")
                                   (8 . "Floor_Label")
                                   (1 . "BEDROOM"))))
                     (= (sslength txt1) 1))
            (command
                  "_.move"
                  txt1 ""
                        (cdr (assoc 10 (entget (ssname txt1 0))))
                  '(1.0 2.0 0.0))
            )
      )

 

it will select a TEXT entity with "Floor_label"  layer and with a string value of "BEDROOM"

and if the selection set contains 1 object

Then it will move the entity from pt to this coordinates  '(1.0 2.0 0.0))

 

No prompt for selection needed  

Message 6 of 7
cummins600
in reply to: cummins600

Thanks a bunch! Got what I'm looking for now. Here's ver that worked for me.

 

(defun c:m1 (/ e en entype pt LRC)
(setq LRC (list (nth 0 (getvar "extmax")) (nth 1 (getvar "extmin"))))
(if (and (setq txt1 (ssget "X"
'((0 . "MTEXT")
(8 . "Tri_triFloor_Label")
)))
(= (sslength txt1) 1))
(command
"_.move"
txt1 ""
(cdr (assoc 10 (entget (ssname txt1 0))))
LRC)
;'(1.0 2.0 0.0))
)
)

Message 7 of 7
pbejse
in reply to: cummins600


@cummins600 wrote:

Thanks a bunch! Got what I'm looking for now. Here's ver that worked for me.

 


 

You are welcome cummins600

 

Glad I could help

 

Cheers


 

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

Post to forums  

Autodesk Design & Make Report

”Boost