Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
New Member
komis
Posts: 2
Registered: ‎01-20-2011
Message 1 of 5 (180 Views)

Scale multiple 3d polylines.

180 Views, 4 Replies
02-07-2013 05:48 PM

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.

Mentor
stevor
Posts: 850
Registered: ‎12-26-2005
Message 2 of 5 (175 Views)

Re: Scale multiple 3d polylines.

02-07-2013 06:29 PM 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
*Expert Elite*
Kent1Cooper
Posts: 5,411
Registered: ‎09-13-2004
Message 3 of 5 (170 Views)

Re: Scale multiple 3d polylines.

02-07-2013 06:54 PM 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:smileyfrustrated:cale3DPs (/ 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
New Member
komis
Posts: 2
Registered: ‎01-20-2011
Message 4 of 5 (126 Views)

Re: Scale multiple 3d polylines.

07-04-2013 05:27 PM in reply to: Kent1Cooper
It works just fine for now... thank you for that.
Valued Mentor
alanjt_
Posts: 480
Registered: ‎08-25-2008
Message 5 of 5 (119 Views)

Re: Scale multiple 3d polylines.

07-04-2013 08:05 PM 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)

 

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.