+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 18
  1. #1
    Full Member
    Using
    Civil 3D 2011
    Join Date
    Aug 2011
    Posts
    99

    Default Scaling Polyline Contours

    Registered forum members do not see this ad.

    I have a great request. I need to scale some polyline contours from ground to grid coordinates. Using the scale comand this works, but the Z value is scaled as well. The thing is, I want to scale the X and Y only, not the Z.

    So far the only way to do this is to create a block, scale it, then explode. This takes a lot of time that to me seems unnecessary.

    So this is what I was thinking for a lisp routine that can do what I need.

    Select a polyline (contours)
    Scale the polyine to some factor.
    Reset the Z value to the orginal value before scaling.

    I hope this makes sense. Haha.

    Anyone willing to tackle this?

  2. #2
    Forum Deity
    Using
    AutoCAD 2002
    Join Date
    Sep 2006
    Location
    East Sussex, U.K.
    Posts
    2,969

    Default

    Quote Originally Posted by Bill_Myron View Post
    Using the scale comand this works, but the Z value is scaled as well.
    Anyone willing to tackle this?
    If you scale the contours individually, then the Z value is not scaled.

    Most people would probably scale the coordinates before they entered the data.

  3. #3
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,951

    Default

    Look into vla-scaleEntity function.
    "Potential has a shelf life." - Margaret Atwood

  4. #4
    Full Member
    Using
    Civil 3D 2011
    Join Date
    Aug 2011
    Posts
    99

    Default

    eldon - The scale command scales the polyline uniformly. It applys the scale to all 3 axis. The data that was given to me was just the contour polylines. Therefore i can only use what was given.

    Render man - Thanks for the start. Can this lisp be manipulated to only scale in the x and y directions and not the Z?

  5. #5
    Super Member Organic's Avatar
    Discipline
    Civil
    Using
    Civil 3D 2013
    Join Date
    Feb 2009
    Posts
    1,641

    Default

    Quote Originally Posted by Bill_Myron View Post
    I have a great request. I need to scale some polyline contours from ground to grid coordinates.
    Scaling contours like that is not a good practice in my opinion.

    Quote Originally Posted by Bill_Myron View Post
    So far the only way to do this is to create a block, scale it, then explode. This takes a lot of time that to me seems unnecessary.
    If this works and you only need to do it one off then why not just do this?

  6. #6
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,951

    Default

    Quote Originally Posted by Bill_Myron View Post
    Render man - Thanks for the start. Can this lisp be manipulated to only scale in the x and y directions and not the Z?
    What results did you get in your code testing?
    "Potential has a shelf life." - Margaret Atwood

  7. #7
    Forum Deity
    Using
    AutoCAD 2002
    Join Date
    Sep 2006
    Location
    East Sussex, U.K.
    Posts
    2,969

    Default

    Quote Originally Posted by Bill_Myron View Post
    The scale command scales the polyline uniformly. It applys the scale to all 3 axis.
    Only if you scale about 0,0. If you scale each individual contour polyline about its own endpoint, the Z value is unaltered.

  8. #8
    Senior Member marko_ribar's Avatar
    Computer Details
    marko_ribar's Computer Details
    Operating System:
    Windows 7 Ultimate X64
    Computer:
    Intel quad core CPU 4x2.66GHz, 8GB RAM
    Motherboard:
    INTEL compatibile
    CPU:
    quad core 4x2.66GHz
    RAM:
    8GB
    Graphics:
    NVIDIA GeForce 6600 GT
    Primary Storage:
    250 GB
    Secondary Storage:
    500 GB
    Monitor:
    Samsung 17''
    Discipline
    Architectural
    marko_ribar's Discipline Details
    Occupation
    Architecture, project designer, project visualisation
    Discipline
    Architectural
    Details
    space design - modeling and animations
    Using
    AutoCAD 2012
    Join Date
    Feb 2010
    Location
    Belgrade, Serbia, Europe
    Posts
    338

    Default

    Code:
    (defun c:scpl ( / pt elev bpt entpl scf )
      (setq pt (getpoint "\nPick base point in XY plane for scaling your pline : "))
      (setq entpl (car (entsel "\nPick pline you want to scale")))
      (setq elev (cdr (assoc 38 (entget entpl))))
      (setq bpt (list (car pt) (cadr pt) elev))
      (setq scf (getreal "\nInput scale factor with or without decimal precision : "))
      (vl-cmdf "_.scale" entpl "" bpt scf)
    (princ)
    )
    M.R.

  9. #9
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,951

    Default

    Quote Originally Posted by marko_ribar View Post
    Code:
    (defun c:scpl ( / pt elev bpt entpl scf )
      (setq pt (getpoint "\nPick base point in XY plane for scaling your pline : "))
      (setq entpl (car (entsel "\nPick pline you want to scale")))
      (setq elev (cdr (assoc 38 (entget entpl))))
      (setq bpt (list (car pt) (cadr pt) elev))
      (setq scf (getreal "\nInput scale factor with or without decimal precision : "))
      (vl-cmdf "_.scale" entpl "" bpt scf)
    (princ)
    )
    M.R.
    I hope the user doesn't miss...
    "Potential has a shelf life." - Margaret Atwood

  10. #10
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,951

    Default

    Registered forum members do not see this ad.

    Slight revision to Marko's code (hope you don't mind):

    Code:
    (defun c:SCPL  () (c:ScalePlines))
    (defun c:ScalePlines  (/ *error* nomutt oldNomutt ss pt scale)
      (princ "\rSCALE MULTIPLE POLYLINES ")
      (vl-load-com)
    
      (defun *error*  (msg)
        (and oldNomutt (setvar 'nomutt oldNomutt))
        (if acDoc (vla-endundomark acDoc))
        (cond ((not msg))                                                   ; Normal exit
              ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
              ((princ (strcat "\n** Error: " msg " ** "))))                 ; Fatal error, display it
        (princ))
    
      (defun nomutt (arg)
        (cond (oldNomutt)
              ((setq oldNomutt (getvar 'nomutt))))
        (if arg
          (setvar 'nomutt 1)
          (setvar 'nomutt 0)))
      
      (prompt "\nSelect multiple polylines to scale: ")
      (if (and (nomutt T)
               (setq ss (ssget "_:L" '((0 . "LWPOLYLINE"))))
               (nomutt nil)
               (setq pt (getpoint "\nSpecify base point: "))
               (setq scale (getreal "\nEnter scale factor: ")))
        ((lambda (acDoc / elev)
           (vla-startundomark acDoc)
           (vlax-for x  (setq ss (vla-get-activeselectionset acDoc))
             (setq elev (vla-get-elevation x))
             (vla-scaleentity x (vlax-3d-point pt) scale)
             (vla-put-elevation x elev))
           (vla-delete ss)
           (setvar 'nomutt oldNomutt)
           (vla-endundomark acDoc))
          (vla-get-activedocument (vlax-get-acad-object)))
        (cond (pt (prompt "\n** Scale factor required ** "))
              (ss (prompt "\n** Base point required ** "))
              ((prompt "\n** Nothing selected ** "))))
      (princ))
    Last edited by BlackBox; 30th Aug 2011 at 06:19 pm. Reason: Revised code to allow selectionset, limit to LW*
    "Potential has a shelf life." - Margaret Atwood

Similar Threads

  1. Scaling a polyline based on its area
    By harilalmn in forum AutoCAD General
    Replies: 2
    Last Post: 12th Jan 2011, 12:34 pm
  2. Contours
    By waqashraf in forum AutoCAD Beginners' Area
    Replies: 1
    Last Post: 17th May 2009, 05:11 am
  3. PLEASE HELP! Contours
    By skills12345 in forum Civil 3D & LDD
    Replies: 5
    Last Post: 21st Oct 2008, 03:05 pm
  4. Contours to 3ds max
    By almunro in forum AutoCAD 3D Modelling & Rendering
    Replies: 0
    Last Post: 19th Feb 2007, 11:53 pm
  5. contours
    By sharma in forum AutoCAD General
    Replies: 0
    Last Post: 3rd Feb 2005, 09:31 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts