Jump to content

Recommended Posts

Posted

so i have one of two things that i am thinking about here.

 

1. i know that AutoCAD has the scale (short key SC) command. selecting it, clicking a base point, typing the scale factor and bingo you are done. i am wanting to see if i am able to throw a wrench in there. maybe it wont work i am not sure. but we get a room name file from the architects and they are just single line text with a box/rectangle around the room number. i have a scale lisp for scaling blocks and also one for resizing the text. but what i am looking for is to be able to take the text and the blocks/objects and scale it all at once with a selection and give scale factor (example of 1/2 size) and be done.

 

2. be able to do a select all and group each of the room names and room numbers into individual blocks. and then i can just use the scale lisp that i already have.

 

attached is the two lisps that i work with currently. i hope that i am making sence and not talking out of my o:)o:)

Scale Text Height2(TH).lsp

Scale All Tags2(SX).lsp

Posted

Would simply using annotative blocks/text be another solution to this need?

Posted
Would simply using annotative blocks/text be another solution to this need?

 

 

at this point i think that anything would work. the problem is that they send this to us this one way. would there be a simple way for me to change these to the annotative blocks/text?

Posted

You could first make a block/text (as pendean suggest) , select all the text's and rectangles in one go and use the string and insertionpoint from the text entity as base for your block insertionpoint. Dont know if the text's and rectangles are in a separate layer so you won't select other objects.

Posted
You could first make a block/text (as pendean suggest) , select all the text's and rectangles in one go and use the string and insertionpoint from the text entity as base for your block insertionpoint. Dont know if the text's and rectangles are in a separate layer so you won't select other objects.

 

i get all of this, however i am working with what is being sent to me. and what they are sending to me isnt set up that way. it is just the single line text with the square around the room number. so i would have to go in and make each of these a block, and then i would be able to use what i currently have. i am just wondering if there is a quick way to make them a block? or to be able to scale what i have currently. attached is what is being send to us.

ANAM.dwg

Posted

I think if you google 'visual lisp text to attribute' you find a couple of routines able to do this.

Posted (edited)

Rlx is on the money just make 2 blocks as you have text with 2 lines and 3 lines. I not sure that a blanket approach can be simply achieved but if happy with a do window, do window, approach it would be pretty easy to read the text and replace with a block. I just used your labels for the test block creating a attribute that matched and removed the text.

 

 

Something to play with as a start needs the text angle etc checked also need to do real work now.

(defun c:test ( / txt1 txt2 txt3 pt)
(while (setq ss (ssget (list(cons 0 "text"))))
(setq pt (cdr (assoc 10(entget(ssname ss 0)))))
(setq txt1 (cdr (assoc 1(entget(ssname ss 0)))))
(setq txt2 (cdr (assoc 1(entget(ssname ss 0)))))
(if (> (sslength ss) 2)
(progn
(setq txt3 (cdr (assoc 1(entget(ssname ss 0)))))
(command "-insert" "3att" pt 1 1 0 txt1 txt2 txt3) ; 3 att is block name 3 attributes
)
(command "-insert" "2att" pt 1 1 0 txt1 txt2)
)
)
)

Edited by BIGAL
Posted

It is of course also possible to select and scale these clusters of elements programmatically.

Note 1: Before trying c:Test use the _OverKill command to get rid of double polylines.

Note 2: The leaders are not processed.

(defun KGA_Conv_Pickset_To_ObjectList (ss / i ret)
 (if ss
   (repeat (setq i (sslength ss))
     (setq ret (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) ret))
   )
 )
)

(defun KGA_Geom_ObjectMiddle (obj / ptBL ptTR)
 (vla-getboundingbox obj 'ptBL 'ptTR)
 (mapcar
   '/
   (mapcar '+ (vlax-safearray->list ptBL) (vlax-safearray->list ptTR))
   '(2.0 2.0 2.0)
 )
)

(defun c:Test ( / dis doc lyr polyLst pt restLst scl tab)
 (setq dis 40.0)          ; Search distance.
 (setq lyr "A-ANNO-NOTE") ; Layer name.
 (setq scl 0.5)           ; Scale factor.
 (setq tab (if (= 1 (getvar 'cvport)) (getvar 'ctab) "Model"))
 (setq doc (vla-get-activedocument (vlax-get-acad-object)))
 (vla-endundomark doc)
 (vla-startundomark doc)
 (if
   (and
     (setq polyLst
       (KGA_Conv_Pickset_To_ObjectList
         (ssget "_A" (list (cons 8 lyr) (cons 410 tab) '(0 . "LWPOLYLINE")))
       )
     )
     (setq restLst
       (KGA_Conv_Pickset_To_ObjectList
         (ssget "_A" (list (cons 8 lyr) (cons 410 tab) '(0 . "*TEXT,SPLINE,ELLIPSE")))
       )
     )
   )
   (progn
     (setq restLst
       (mapcar
         '(lambda (obj) (list (KGA_Geom_ObjectMiddle obj) obj))
          restLst
       )
     )
     (foreach poly polyLst
       (setq pt (KGA_Geom_ObjectMiddle poly))
       (vla-scaleentity poly (vlax-3d-point pt) scl)
       (foreach sub restLst
         (if (> dis (distance pt (car sub)))
           (progn
             (vla-scaleentity (cadr sub) (vlax-3d-point pt) scl)
             (setq restLst (vl-remove sub restLst))
           )
         )
       )
     )
     (princ "\nDone! ")
   )
 )
 (vla-endundomark doc)
 (princ)
)

Posted
It is of course also possible to select and scale these clusters of elements programmatically.

Note 1: Before trying c:Test use the _OverKill command to get rid of double polylines.

Note 2: The leaders are not processed.

(defun KGA_Conv_Pickset_To_ObjectList (ss / i ret)....  )

 

 

Was about to suggest OP to have a look at this link :

 

 

http://www.cadtutor.net/forum/showthread.php?101120-Help-with-lisp-to-move-text-to-specific-locations-w-a-better-narrative

 

 

but your code is I think pretty much what OP needs. And its fast. Nicely done Roy. Got too much work at this moment to do much lisping...

 

 

so :beer: for you!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...