Jump to content

Scale selected lines about their midpoints


eddablin

Recommended Posts

Hi. I have a first floor plan of a large building and have drawn beams to the midpoint of columns. Its common practice to have the lines shrunk so it looks like this on plan:

 

I ------- I

 

rather than

 

I----------I

 

It would save me a lot of time if I had a piece of code that made them all scale about their midpoints rather than scale each line by its base points separately. Anyone have a solution?

 

Many thanks!

Link to comment
Share on other sites

How much do you need them scaled by? Are they all on their own layer? Are they lines or Polylines or LWPolylines?

 

Hi Lee. Thanks for the response.

 

They are all lines. Ideally the scale could be user input. If not a scale of 0.8 would be good.

 

Thanks

Link to comment
Share on other sites

Give this a shot:

 

(defun c:scl  (/ ss scl)
 (vl-load-com)
 (or scale:def (setq scale:def 0.)
 (if (setq ss (ssget "X" (list (cons 0 "LINE")
                               (cons 8 "Beams")
                               (if (getvar "CTAB")
                                 (cons 410 (getvar "CTAB"))
                                 (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (initget 6)
     (setq scl (getreal (strcat "\nSpecify Scale Factor <" (rtos scale:def) "> : ")))
     (or (not scl) (setq scale:def scl))
     (foreach x  (mapcar 'vlax-ename->vla-object
                         (mapcar 'cadr (ssnamex ss)))
       (vla-ScaleEntity x
         (vlax-3D-point
           (vlax-curve-getPointatDist x
             (/ (vla-get-length x) 2.0))) scale:def)))
   (princ "\n<!> No Lines Found <!>"))
 (princ))

Link to comment
Share on other sites

Give this a shot:

 

(defun c:scl  (/ ss scl)
 (vl-load-com)
 (or scale:def (setq scale:def 0.)
 (if (setq ss (ssget "X" (list (cons 0 "LINE")
                               (cons 8 "Beams")
                               (if (getvar "CTAB")
                                 (cons 410 (getvar "CTAB"))
                                 (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (initget 6)
     (setq scl (getreal (strcat "\nSpecify Scale Factor <" (rtos scale:def) "> : ")))
     (or (not scl) (setq scale:def scl))
     (foreach x  (mapcar 'vlax-ename->vla-object
                         (mapcar 'cadr (ssnamex ss)))
       (vla-ScaleEntity x
         (vlax-3D-point
           (vlax-curve-getPointatDist x
             (/ (vla-get-length x) 2.0))) scale:def)))
   (princ "\n<!> No Lines Found <!>"))
 (princ))

 

Worked an absolute treat! I wish I could code these. Would save so much time. Thank you so much! Lifesaver

Link to comment
Share on other sites

Hi Lee,

 

One more question: I would like to resize everything on the layer "columns" about its midpoint. These columns are mostly in the form of squares but i think some might have been formed by 4 lines.

 

I tried to edit your code but failed. They just resized about a corner.

 

Thanks in advance

Link to comment
Share on other sites

Hi Lee,

 

One more question: I would like to resize everything on the layer "columns" about its midpoint. These columns are mostly in the form of squares but i think some might have been formed by 4 lines.

 

I tried to edit your code but failed. They just resized about a corner.

 

Thanks in advance

 

My code was only engineered for the initial problem - it was not universal.

Link to comment
Share on other sites

This will scale the squares with the basepoint at their centres.

 

(defun c:scl  (/ ss scl st 3p)
 (vl-load-com)
 (or scale:def (setq scale:def 0.)
 (if (setq ss (ssget 
                     (list (cons 0 "*Polyline")
                           (cons 8 "Columns")
                           (if (getvar "CTAB")
                             (cons 410 (getvar "CTAB"))
                             (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (initget 6)
     (setq scl (getreal (strcat "\nSpecify Scale Factor <" (rtos scale:def) "> : ")))
     (or (not scl) (setq scale:def scl))
     (foreach x  (mapcar 'vlax-ename->vla-object
                         (mapcar 'cadr (ssnamex ss)))
       (setq st (vlax-curve-getStartPoint x)
             3p (vlax-curve-getPointatParam x 2.0))
       (vla-scaleEntity x
         (vlax-3D-point
           (polar st (angle st 3p) (/ (distance st 3p) 2.0))) scale:def)))
   (princ "\n<!> No Lines Found <!>"))
 (princ))

 

It makes a ton of assumptions though - like them being perfectly square, etc

Link to comment
Share on other sites

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...