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

Scale multiple 3d polylines.

4 REPLIES 4
Reply
Message 1 of 5
komis
338 Views, 4 Replies

Scale multiple 3d polylines.

Hi all,

 

Is there a way or a lisp to scale multiple 3d polylines, at same time, and the base point is the start point of each one?

 

thanks.

4 REPLIES 4
Message 2 of 5
stevor
in reply to: komis

Try a Forech entity with a scale command using its start point, or a mid point if that is the case. Someone will produce some code, before me.
S
Message 3 of 5
Kent1Cooper
in reply to: komis


@komis wrote:

.... 

Is there a way or a lisp to scale multiple 3d polylines, at same time, and the base point is the start point of each one?

....


This seems to do that, in limited testing:

 

(defun C:Scale3DPs (/ sc 3DPss 3DP)
  (vl-load-com)
  (setq sc (getreal "\nScale factor to apply to 3DPolylines: "))
  (if (setq 3DPss (ssget '((0 . "POLYLINE")))); User selection contains some
    (repeat (sslength 3DPss)
      (setq 3DP (ssname 3DPss 0)); first [remaining] one
      (if (= (cdr (assoc 100 (reverse (entget 3DP)))) "AcDb3dPolyline"); [not "heavy" 2D]
        (command "_.scale" 3DP "" (vlax-curve-getStartPoint 3DP) sc)
      ); if
      (ssdel 3DP 3DPss); remove that one
    ); repeat
  ); if
); defun

 

That asks the User to select things, out of which it only scales the 3DPolylines.  If you want it to do it to all 3DPolylines, without User selection, change the fourth line to:

....

  (if (setq 3DPss (ssget "_X" '((0 . "POLYLINE"))))

....

 

You can get more sophisticated, such as with error handling, Osnap control, saving the scale factor and offering it as a default on subsequent use, perhaps building in a fixed scale factor instead, ignoring any not in the current space, etc., but see what you think.

Kent Cooper, AIA
Message 4 of 5
komis
in reply to: Kent1Cooper

It works just fine for now... thank you for that.
Message 5 of 5
alanjt_
in reply to: komis

(defun c:3PLS (/ _only3dPline lst sf)

  (defun _only3dPline (ss / i e lst)
    (if (eq (type ss) 'PICKSET)
      (progn
        (repeat (setq i (sslength ss))
          (if (eq (cdr (assoc 100 (reverse (entget (setq e (ssname ss (setq i (1- i))))))))
                  "AcDb3dPolyline"
              )
            (setq lst (cons (list (vlax-ename->vla-object e) (vlax-curve-getStartPoint e)) lst))
          )
        )
        lst
      )
    )
  )

  (if (and (setq lst (_only3dPline
                       (ssget "_:L"
                              (list '(0 . "POLYLINE")
                                    (if (eq (getvar 'CVPORT) 1)
                                      (cons 410 (getvar 'CTAB))
                                      '(410 . "Model")
                                    )
                              )
                       )
                     )
           )
           (progn (initget 6) (setq sf (getreal "\nSpecify scale factor: ")))
      )
    (foreach x lst (vlax-invoke (car x) 'ScaleEntity (cadr x) sf))
  )
  (princ)
)
(vl-load-com)
(princ)

 

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

Post to forums  

Autodesk Design & Make Report

”Boost