Jump to content

Looking for a LISP that incrementally adds Thickness and Elevation to lines.


dollada06

Recommended Posts

Hey everyone. We have an issue that we think we may be able to solve with a LISP. Only problem is that I am only just beginning to learn AutoLISP and this is way over my head.

 

Problem - We are trying to export data from roads and have the ability to sort it in a certain way when we data extract it. To do that we have been applying a thickness to the line. Basically doing 1,2,3,4,5 etc in the order we want the lines sorted. So when it comes time to data extract it we can sort by layer and then sort by thickness as a secondary. We've been having to click on each line manually, enter in the thickness. We want to speed this process up. So we are thinking that a LISP which would add a thickness of 1 to the first line selected and then +1 to every line after that would work.

 

The second aspect of this is that we also use the elevation field to define the number of buildings that are along the aforementioned road segments. This too would be set up the exact same way as the other. Click a line and it does +1 to the elevation (starting from 1). The thing we need to be able to do though with the elevation is reset the elevation counter some way while not starting the thickness incremental increase over. The reasoning for this will hopefully be more obvious if you look at the attached drawing, but basically the number of buildings along the road resets if we have a new segment of road.

 

What we have been spitballing for an idea to reset the elevation/building counter would be if the user clicked on the building block rather than a line it would know to reset the elevation/building to a.

 

Thank you all for any help you can provide on this. It is greatly appreciated!

thickness elevation lisp.dwg

Link to comment
Share on other sites

Just a thought but if you are looking at extracting data from lines, why not attach xdata to each line? This can be filtered and sorted.

 

Sent from my Pixel XL using Tapatalk

Link to comment
Share on other sites

Just a thought but if you are looking at extracting data from lines, why not attach xdata to each line? This can be filtered and sorted.

 

Sent from my Pixel XL using Tapatalk

 

The reason we like the idea of just +1 each time we click is because we have to do this 100's and sometimes 1000's of times when projects get really big. So to click on each line and then have to manually enter in a value that puts us right about where we are now. Our goal is to speed up the process. Hope I do not come across dismissive to your suggestion. I'm just not sure that would save us any time--unless there is something I am missing and if so I apologize.

Link to comment
Share on other sites

Changing the elevation for this purpose seems like a very bad idea. You are moving entities in the Z-direction. For example snapping to end points would become unpredictable.

Link to comment
Share on other sites

Changing the elevation for this purpose seems like a very bad idea. You are moving entities in the Z-direction. For example snapping to end points would become unpredictable.

 

For what we are doing in this stage of our project bid elevation does not matter. This is only for getting bulk quantities on aggregate. We've always done it with elevation, but if it is possible to create an Xdata field in the lisp instead I suppose that would be just great too.

Link to comment
Share on other sites

Here's a quick one .. although I agree there is most likely a better way to approach this.

(defun c:foo (/ e el w)
 ;; Not much error checking...
 (if (and (not (initget 4))
   (setq w (getint "\nEnter start width: "))
   (setq el (getint "\nEnter start elevation: "))
     )
   (while (setq e (car (entsel "\nPick polyline: ")))
     (entmod (append (entget e) (list (cons 43 w) (cons 38 el) (cons 62 w))))
     (setq w  (1+ w)
    el (1+ el)
     )
   )
 )
 (princ)
)

Edited by ronjonp
Link to comment
Share on other sites

What ronjon has posted will give you exactly what you are doing now in a more 'automated' fashion.

 

By using xdata you can add so much more information to the line eg type, weight, price. Also by using ssget and filtering the regapp name you could quantify much faster what you are after. If you are handling hundreds/thousands of lines why not have the computer do as much of the legwork as possible. You can even have AutoCAD export the data to word, excel, xml....your imagination is the limit with something like this.

 

Sent from my Pixel XL using Tapatalk

Link to comment
Share on other sites

My $0.05 you need a what was the last value check but look at code thats just a few more lines at start. Oh and a if Thickness is not >0

 

Found a couple of minutes, 100's of lines may take a bit of time so could add a progress bar for say selections 100+

 

(defun set-thick ( /  ss x)
(setq thick 0)
(setq ss (ssget (list ( cons 0 "*line"))))
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(setq newthick (vla-get-thickness obj))
(if (< thick newthick)(setq thick newthick))
)
(alert (strcat "1st pass completed last number is " (rtos thick 2 0)))
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(if (= 0.0 (vla-get-thickness obj))(vla-put-thickness obj (setq thick (+ thick 1))))
)
(alert (strcat "2nd pass completed last number is " (rtos thick 2 0)))
)
(set-thick)

Edited by BIGAL
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...