Lisp to divide 3d polyline at specific levels

Lisp to divide 3d polyline at specific levels

Anonymous
Not applicable
1,931 Views
5 Replies
Message 1 of 6

Lisp to divide 3d polyline at specific levels

Anonymous
Not applicable

Good morning,

 

I work with the design of houses, and one rather tedious job is applying underbuild and tanking, which is effectively the difference between external ground level and the finished floor level. We tend to identify this by drawing polylines around the building with different linetypes to show whether it is underbuild or tanking.

 

I know I can use a 3D polyline to create an external boundary which would mimic the ground levels. But I wondered if it would be possible to create a lisp that would be able to take that 3D polyline and split it at a specific level (the FFL), it would be ideal if the lisp was able to apply a certain layer to the 3D polylines above the specified level, and another to levels below.

 

For example, if the FFL was set at 100m, and the levels along the front of the house went from 99m on the left to 101m on the right, it would create a split at the 100m mark, then the 3dpolyline to the left would be underbuild and the 3dpolyline to the right would be tanking.

 

I hope that makes sense, and I would be extremely grateful for any help.

 

Kind regards,

 

Anthony

 

 

 

 

0 Likes
1,932 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

... I wondered if it would be possible to create a lisp that would be able to take that 3D polyline and split it at a specific level (the FFL), it would be ideal if the lisp was able to apply a certain layer to the 3D polylines above the specified level, and another to levels below.

....


That should be possible, but I have some questions:

 

Would such a 3DPolyline be drawn as one all the way around a building perimeter, so that it would need to be split twice [at least -- see next question]?  Or would each face of a building have a grade line?

 

Would such a 3DPolyline, even if each face of a building has its own, sometimes cross above and back below the FFL, maybe even more than once, meaning that a routine would need to determine how many such splits to perform, and not simply stop when it finds a crossing elevation?

Kent Cooper, AIA
0 Likes
Message 3 of 6

Anonymous
Not applicable

Sorry for the late reply, but thank you for responding.

 

I had envisaged that I would draw a closed 3D polyline around the perimeter of a building which would represent the external ground level, albeit, if it's easier to have separate lines, then I'm not fussy!

 

I would say that you would only cross the FFL level twice, imagine that the ground level falls from front to back, therefore along the sides, there must be a point where the ground level crosses on the left and right.

 

It would be perfect if this tool was able to split the line into three layers;

 

Tanking - When the ground level is above the FFL

Level - When the ground level is equal to the FFL

Underbuild - When the ground level is below the FFL

 

If it's a bit too difficult then don't worry, this is just something that could potentially save a lot of time, and some human error along the way, and i am thankful for any help.

 

0 Likes
Message 4 of 6

john.uhden
Mentor
Mentor

This relates to something I always wanted to do (but never have)... to identify/mark the points of whole contour elevations along the path of a 3D polyline.  Before, and even after, the advent of AutoCAD, DCA, Softdesk, Land Desktop, and today Civil 3D, I used to grade sites with nothing but contours.  Then I would add spot grades based on interpolation between contours.  I gradually got comfortable with drawing 3D poly grade lines because I could manipulate their slopes (with my own AutoLisp).  But then I would have to adjust contours by trial and error until they would cross the grade line at "about" the contour elevation.

 

Sadly, the Visual Lisp curve functions don't provide a function to get a point at an elevation, but that's what one of us here has to write.  Thinking about it, it's really not that difficult.  I guess maybe it's time.  Too bad I don't have a job where I could use it.

John F. Uhden

0 Likes
Message 5 of 6

Ranjit_Singh
Advisor
Advisor

I wrote something similar here a few days back for civil 3d feature line. I have modified it to work for 3d polyline. It will get you the points at elevation on the 3d polyline. From there on you can modify the code to split the polyline, add it to different layers etc.

Spoiler
(defun c:somefunc  (/ vlaObj pts el pt modelspace adoc)
    (defun *error*  (errmsg)
        (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
            (princ (strcat "\nError: " errmsg)))
        (vla-endundomark adoc)
        (princ))
    (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
    (setq vlaObj     (vlax-ename->vla-object (car (entsel)))
          pts        (vl-remove-if '(lambda (x) (atom x)) (test (vlax-get vlaObj 'Coordinates)))
          modelspace (vla-get-modelspace adoc))
    (initget 1)
    (setq el (getreal "\nElevation to be identified :"))
    (while el
        (mapcar '(lambda (x y)
                     (if (setq pt (inters x
                                          y
                                          (append (reverse (cdr (reverse x))) (list el))
                                          (append (reverse (cdr (reverse y))) (list el))
                                          T))
                         (vla-AddPoint modelSpace (vlax-3d-point pt))))
                pts
                (if (= (vla-get-closed vlaObj) :vlax-true) (append (cdr pts) (list (car pts))) (cdr pts)))
        (initget 1)
        (setq el (getreal "\nElevation to be identified :")))
    (*error* "end"))

(defun test  (x)
    (cond ((null x) ())
          (T (append (list (list (car x) (cadr x) (caddr x))) (test (cdddr x))))))
0 Likes
Message 6 of 6

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

... a closed 3D polyline around the perimeter of a building which would represent the external ground level....

 

... would only cross the FFL level twice, imagine that the ground level falls from front to back, therefore along the sides, there must be a point where the ground level crosses on the left and right.

 

It would be perfect if this tool was able to split the line into three layers;

 

Tanking - When the ground level is above the FFL

Level - When the ground level is equal to the FFL

Underbuild - When the ground level is below the FFL

.... 


I can imagine a way to find where such a 3DPolyline crosses the FFL [check vertices for their Z-coordinate elevation, and when two adjacent ones straddle the FFL, find the crossing location by proportional calculation].  It shouldn't be hard to Break it at that level within a segment.  If you need a whole Layer for at the FFL, I assume there must [at least sometimes] be stretches across entrance doors or something -- is that right?.  It also shouldn't be too hard to isolate those [any segment with both ends at the FFL].  Slightly trickier could be the re-joining of pieces that become separate 3DPolylines that should go on the same Layer -- at the first single-point Break of one, it becomes two 3DPolylines, one from the original start up to the Break point and another from there to the original end, rather than one with its start-end at the Break point.  But that can probably be accounted for somehow.

Kent Cooper, AIA
0 Likes