Author Topic: polyline elevating help needed  (Read 2293 times)

0 Members and 1 Guest are viewing this topic.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
polyline elevating help needed
« on: March 22, 2008, 12:17:04 AM »
i wrote this routine that will prompt the user for a starting elevation and then it will let you select a series of polylines and it will set the first selected with an elevation equal to the starting elevation the user entered (default is 1) and the everything after that sequentially increases by 1. right now, i have 2 problems...
1.  after i select the first pline (it will be set with an elev. of 1), i selected the second pline  (but instead of setting it as 2, it sets it as three). for some reason, it skips the following number after the starting number.
2.  if i accidentially miss a pick on a pline (or just right click/enter to end the routine), i would like to to NOT add the next number, but instead stop adding (if the last pline i edit is with an elevation of 20, then i want when i execute teh command again, it will be be at 21 for the default, not 22.

any help would be greatly appreciated. eventually, if i can tackle these 2 issues, i would like to be able to give the option to set the increment (ie: 1, 1.5, -1, -1.5, etc.) and be able to change the increment mid picking if possible. these are things that are not as important and are far on the back burner.

here is what i have so far...

Code: [Select]
(defun C:ec()
   (if (not *SEQ-NUM) (setq *SEQ-NUM 1)) ;set default
   (setvar "cmdecho" 0)
   (princ "\nStarting Number <")
   (princ *SEQ-NUM)
   (setq SEQ-NUM (getint ">: "))
   (if (not SEQ-NUM)
      (setq SEQ-NUM *SEQ-NUM)
      (setq *SEQ-NUM SEQ-NUM)
   );if
   (graphscr)
   (setq ENT (entsel "\nSelect Polyline to Sequentially Elevate: "))
   (while ENT
      (progn
         (command "change" ENT "" "p" "e" *SEQ-NUM "")
         (setq SEQ-NUM (1+ SEQ-NUM)) ;advance default
         (princ "\n")(princ SEQ-NUM)
         (setq ENT (entsel " - Select Next Polyline: "))
      );progn
      (setq *SEQ-NUM (1+ SEQ-NUM)) ;set for next use
   );while
(princ))
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: polyline elevating help needed
« Reply #1 on: March 22, 2008, 12:49:53 AM »
Play with this.
Code: [Select]
(defun C:ec (/ SEQ-NUM ss)
  (or *SEQ-NUM (setq *SEQ-NUM 1))       ; set default
  (setvar "cmdecho" 0)
  (if (setq SEQ-NUM
             (getint
               (strcat "\nStarting Elevation <" (itoa *SEQ-NUM) ">: ")
             )
      )
    (setq *SEQ-NUM SEQ-NUM)
  )
  (graphscr)
  (while
    (progn
      (prompt "\nSelect Polyline to Sequentially Elevate: ")
      (if (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE"))))
        (progn
          (command "change" ss "" "p" "e" *SEQ-NUM "")
          (redraw (ssname ss 0) 3)
          (setq *SEQ-NUM (1+ *SEQ-NUM))   ;advance default
          (princ "\n")
          (princ *SEQ-NUM)
        )
      )
    )
  )
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: polyline elevating help needed
« Reply #2 on: March 26, 2008, 12:39:37 PM »
oh man, cab that's beautiful. thanks so much

what does this mean/do? 
Quote
_+.:E:S
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: polyline elevating help needed
« Reply #3 on: March 26, 2008, 12:59:37 PM »
It breaks down to this:
(setq ssent (ssget "_+.:E:S" '((0 . "LWPOLYLINE"))))

_ Support for other languages
+. Use autocad built in commands, + is needed for syntax
:E Everything in aperture, Everything within the cursor's object selection pickbox.
:S Force single object selection only

'((0 . "LWPOLYLINE")) Only get objects with DXF code zero equal to "LWPOLYLINE"
in other words only LWpolyline objects
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: polyline elevating help needed
« Reply #4 on: March 26, 2008, 01:30:54 PM »
cool, thank again cab :)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: polyline elevating help needed
« Reply #5 on: April 17, 2008, 10:30:47 PM »
i know i posted this a little while back, but i had a question on changes.
right now if you type in -20, it will assign -20 then then next will be -19. is it possible to change this to where it will always be positive. the only purpose of the - would be to tell the routine to subtract, but not place a negative?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: polyline elevating help needed
« Reply #6 on: April 17, 2008, 11:21:31 PM »
That is in a positive direction. i.e. +1  :kewl:


You could do this:

Code: [Select]
(defun C:ec (/ SEQ-NUM ss)
  (or *SEQ-NUM (setq *SEQ-NUM 1))       ; set default
  (setvar "cmdecho" 0)
  (if (setq SEQ-NUM
             (getint
               (strcat "\nStarting Elevation <" (itoa *SEQ-NUM) ">: ")
             )
      )
    (setq *SEQ-NUM SEQ-NUM)
  )
  (graphscr)
  (while
    (progn
      (prompt "\nSelect Polyline to Sequentially Elevate: ")
      (if (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE"))))
        (progn
          (command "change" ss "" "p" "e" *SEQ-NUM "")
          (redraw (ssname ss 0) 3)
          (if (minusp *SEQ-NUM)
            (setq *SEQ-NUM (1- *SEQ-NUM))   ;advance default
            (setq *SEQ-NUM (1+ *SEQ-NUM))   ;advance default
          )
          (princ "\n")
          (princ *SEQ-NUM)
        )
      )
    )
  )
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: polyline elevating help needed
« Reply #7 on: April 18, 2008, 08:14:32 AM »
minusp.
i tried using wcmatch, but that just crashed after the first elevated contour.

something still isn't working properly.
i think i screwed up my explanation. if i type in a -, i want it to subtract from that number, but i want the numbers to be postive.

_________________i select this line type in "-20" and it will assign it a 20 elev.
_________________2nd select will be 19
_________________3rd select will be 18

_________________i select this line type in "20" and it will assign it a 20 elev.
_________________2nd select will be 21
_________________3rd select will be 22

is this possible?

thanks for all your help alan, this is a HUGE improvement on the dribble i had originally started.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: polyline elevating help needed
« Reply #8 on: April 18, 2008, 08:41:39 AM »
You can do something like this:
Code: [Select]
(defun C:ec (/ SEQ-NUM ss step)
  (or *SEQ-NUM (setq *SEQ-NUM 1)) ; set default
  (setvar "cmdecho" 0)
  (if (and
        (setq SEQ-NUM
               (getint (strcat "\nStarting Elevation <" (itoa *SEQ-NUM) ">: "))
        )
        (or (initget 2)
            (setq step (getdist "\nEnter Increment [1 / -1] <1>: "))
            (setq step 1))
      )
    (setq *SEQ-NUM SEQ-NUM)
  )
  (graphscr)
  (while
    (progn
      (prompt "\nSelect Polyline to Sequentially Elevate: ")
      (if (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE"))))
        (progn
          (command "change" ss "" "p" "e" *SEQ-NUM "")
          (redraw (ssname ss 0) 3)
          (setq *SEQ-NUM (+ *SEQ-NUM step)) ;advance default
          (princ "\n")
          (princ *SEQ-NUM)
        )
      )
    )
  )
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: polyline elevating help needed
« Reply #9 on: April 18, 2008, 09:30:05 AM »
it would give me errors if i used an increment of say, .5 or a negative (to subtract) when i started the routine back up.
i took out a few things and set a nil to *seq-num. it's working perfectly now. i can live without the initial prompt looking like:

"Starting Elevation:"
instead of:
Starting Elevation <" (itoa *SEQ-NUM) ">:

thank you so much for your help.

Code: [Select]
;(defun C:ec (/ SEQ-NUM ss step)
(defun C:ec (/ SEQ-NUM *SEQ-NUM ss step)
;  (or *SEQ-NUM (setq *SEQ-NUM 1)) ; set default
  (setvar "cmdecho" 0)
  (if (and
        (setq SEQ-NUM
               (getint (strcat "\nStarting Elevation: "))
        )
        (or (initget 2)
            (setq step (getdist "\nEnter Increment [1 / -1] <1>: "))
            (setq step 1))
      )
    (setq *SEQ-NUM SEQ-NUM)
  )
  (graphscr)
  (while
    (progn
      (prompt "\nSelect Polyline to Sequentially Elevate: ")
      (if (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE"))))
        (progn
          (command "change" ss "" "p" "e" *SEQ-NUM "")
          (redraw (ssname ss 0) 3)
          (setq *SEQ-NUM (+ *SEQ-NUM step)) ;advance default
          (princ "\n")
          (princ *SEQ-NUM)
        )
      )
    )
  )
  (princ)
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: polyline elevating help needed
« Reply #10 on: April 18, 2008, 03:27:23 PM »
Sorry I did not test that version, try this out.
Code: [Select]
(defun C:ec (/ SEQ-NUM ss step)
  (or *SEQ-NUM (setq *SEQ-NUM 1)) ; set default
  (setvar "cmdecho" 0)
 
  (if (setq SEQ-NUM
               (getint (strcat "\nStarting Elevation <" (rtos *SEQ-NUM) ">: ")))
    (setq *SEQ-NUM SEQ-NUM)
  )
  (initget 2)
  (if (not (setq step (getdist "\nEnter Increment [1 / -1] <1>: ")))
            (setq step 1))

  (graphscr)
  (while
    (progn
      (prompt "\nSelect Polyline to Sequentially Elevate: ")
      ;;(if (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE"))))
      (if (setq ss (ssget '((0 . "LWPOLYLINE"))))
        (progn
          (command "change" ss "" "p" "e" *SEQ-NUM "")
          (mapcar '(lambda(x) (redraw x 3)) (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
          (redraw (ssname ss 0) 3)
          (setq *SEQ-NUM (+ *SEQ-NUM step)) ;advance default
          (princ "\n")
          (princ *SEQ-NUM)
        )
      )
    )
  )
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: polyline elevating help needed
« Reply #11 on: April 18, 2008, 03:44:03 PM »
oh man, that's beautiful!!
thank you thank you thank you!

i added ":S" back to the ssget so it would only select one line for each change.

thanks so much for all your help!!!
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox