Results 1 to 8 of 8

Thread: Move line to average Z coordinate

  1. #1
    Member
    Join Date
    2006-08
    Posts
    13
    Login to Give a bone
    0

    Default Move line to average Z coordinate

    I have a need to flatten a lot of lines, one at a time, not to 0, but to the average of their ends. Right now I am just going to the properties, averaging the ends and typing in the new value. It doesn't take long, but this is something I am going to have to do 1000's of times over the next couple years. Is there a guru out there that could come up with something real quick I could drop in my custom lisp file? Perty Please!

  2. #2
    Member
    Join Date
    2006-08
    Posts
    13
    Login to Give a bone
    0

    Default Re: Move line to average Z coordinate

    Another really cool function would be to be able to select a flat line, gets is z, and then apply that to a selected line.

  3. #3
    I could stop if I wanted to
    Join Date
    2003-12
    Location
    Pittsburgh, PA
    Posts
    355
    Login to Give a bone
    0

    Default Re: Move line to average Z coordinate

    Quote Originally Posted by gmiller.119448 View Post
    Another really cool function would be to be able to select a flat line, gets is z, and then apply that to a selected line.
    Code:
    ;Sets elevation of selected objects to the elevation of a source object
    
    (defun c:ce ()
    (defun dxf(code elist)
     (cdr (assoc code elist))   ;finds the association pair, strips 1st element
    );defun
    (COMMAND "UCS" "W")    
        (setq ed (entget (car (entsel "Pick source: "))))
            (if (= (DXF 0 ED) "LWPOLYLINE")
        (SETQ el (DXF 38 ED))
        (SETQ el (CADDR (DXF 10 ED)))
            )
    (setq ss1 (ssget ))
        (command "change" ss1 "" "p" "e" el "")
    (COMMAND "UCS" "P")
    (prompt  (rtos el 2 1))
    (princ)
    );defun

  4. #4
    Member
    Join Date
    2006-08
    Posts
    13
    Login to Give a bone
    0

    Default Re: Move line to average Z coordinate

    That code worked great for my second request. I am trying to figure out how to edit it to make the first. I am not a customizer, but I've dabbled a few years ago.
    When the "start z" and "end z" are different what you have used the "start z".
    It looks to me like that is set with "(SETQ el (DXF 38 ED))". So what would I need to get "end z"? If I could get that, average those 2 numbers, that is all I think I need to add to get what I am looking for. I would then just need to apply it to the line already selected, "ed" right?

  5. #5
    Member
    Join Date
    2006-08
    Posts
    13
    Login to Give a bone
    0

    Default Re: Move line to average Z coordinate

    Actually I have an even better idea, instead of getting the average if I just pick a point, and use that Z. That will work for averaging 2 ends (I can just snap to the middle), matching another line, also if the start z or end z is what I want I can snap to that end point and make the whole line that elevation. I am pretty sure that would cover all my possibilities in one simple routine. So, I can decipher the previous code well enough to get the entity, and apply the elevation, I just need to know how to select the point that I want to store.

  6. #6
    Member
    Join Date
    2006-08
    Posts
    13
    Login to Give a bone
    0

    Default Re: Move line to average Z coordinate

    FYI so you know I am trying to figure this out on my own, I am researching getpoint, that will solve my problem if I can figure out how to strip out the z from the list.

  7. #7
    I could stop if I wanted to
    Join Date
    2003-12
    Location
    Pittsburgh, PA
    Posts
    355
    Login to Give a bone
    0

    Default Re: Move line to average Z coordinate

    This will get you started by returning the average z value
    Code:
    (defun c:test ()
    (setq LN1 (entsel)
            BZ  (caddr (cdr (assoc 10 (entget (car LN1)))))
            EZ  (caddr (cdr (assoc 11 (entget (car LN1)))))
            AVGZ (/ (+ BZ EZ) 2)
    );setq
    );defun
    You'll need to look into using subst and entmod to finish.
    But I think it's beer o'clock now.

  8. #8
    Member
    Join Date
    2006-08
    Posts
    13
    Login to Give a bone
    0

    Default Re: Move line to average Z coordinate

    Thanks for your help lpseifert!! I got what I need.

Similar Threads

  1. Replies: 1
    Last Post: 2013-04-28, 12:21 AM
  2. Calculate next polar coordinate if line is not straight
    By sanjaybharkatiya248970 in forum AutoLISP
    Replies: 1
    Last Post: 2012-09-13, 11:44 AM
  3. move to coordinate not working
    By Gigliano70 in forum AutoCAD General
    Replies: 6
    Last Post: 2008-08-25, 06:43 PM
  4. tag property line with survey coordinate
    By comhasse in forum Revit Architecture - General
    Replies: 2
    Last Post: 2007-05-15, 07:19 PM
  5. Coordinate input to displace instead of move
    By pgastelum77763 in forum AutoCAD General
    Replies: 11
    Last Post: 2007-03-15, 01:14 PM

Posting Permissions

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