Project a line to a surface command

Project a line to a surface command

Anonymous
Not applicable
5,610 Views
31 Replies
Message 1 of 32

Project a line to a surface command

Anonymous
Not applicable

Hi Everyone

 

I'm relative new to Civil 3d, previously a Inroads users.. and i'm found what i use Civil 3d for to be very handy and easier than Inroads there are a few commands in Inroads i wish (i hope someone can tell me otherwise) were in Civil 3d.

 

Main on is a command in Inroads called 'project a line to a surface', i have searched the internet and some ppl have asked the question but have been shown the 'elevations from surface' in Civil 3d which is essentially 'drape to surface' 

 

what i'm looking for is to project a single line at a grade (say 1:10) from a crest level of my design to an existing surface. when i move my mouse the line will get longer or shorter depending where i intersects with the selected surface.

I'm hoping someone with inroads background has tried to find this, knows it does or doesn't exist so i can move on with my life haha

 

thanks in advance

 

Andrew

0 Likes
5,611 Views
31 Replies
Replies (31)
Message 2 of 32

krzysztof.psujek
Advocate
Advocate

Hi, 

welcome on forum.

Not sure what exactly you mean but I can suggest you to play with Future Lines modifications (Ribbon Modify - Tab Edit Elevations).

 

See this thread:

http://forums.autodesk.com/t5/autocad-civil-3d-forum/how-to-project-lines-and-curves-to-a-surface-wi...

 

 

Chris

0 Likes
Message 3 of 32

Hidden_Brain
Advisor
Advisor

Is this what you are looking for in Civil 3D? I do not think there is a menu/button to do this, but can be accomplished using feature line(s) at the desired grade, creating temporary TIN surface from them and then by comparing the temp TIN and existing ground TIN (or using the minimum distance between surfaces command).

 

 

 

SURF.png

0 Likes
Message 4 of 32

Anonymous
Not applicable

That is the command I'm looking for. Sucks that it doesn't exist. Handy for ramps from crest of an embankment to toe.

0 Likes
Message 5 of 32

Neilw_05
Mentor
Mentor

Though C3D does not have an identical tool that I know of, you can achieve your task with a grading. To do this you draw a very small circle around the point you want to start from. Convert it to a featureline and set the elevation to match the elevation of the starting point. Next apply a grading that targets your surface at the desired slope. The resulting daylight line will be all the locations for a solution. Then strike a line at the optimal solution.

 

The circle you start with should be very small to keep the grading as close as possible to the true starting point location. I haven't tested this so I am not sure how well the grading will work from such a small circle.

Neil Wilson (a.k.a. neilw)
AEC Collection/C3D 2024, LDT 2004, Power Civil v8i SS1
WIN 10 64 PRO

http://www.sec-landmgt.com
Message 6 of 32

Anonymous
Not applicable

Cheers, that would work.

 

Thanks guys

0 Likes
Message 7 of 32

Neilw_05
Mentor
Mentor

I think you'll find the grading will not be suitable using a very small circle. The reason being the tessellation for such a small circle (the little 3D line segments that approximate the circle) does not generate enough vertices for the grading to solve. To overcome that problem you could increase the diameter of the circle and raise or lower the elevation by interpolation along the target slope.

 

For example if the reference point is elevation 100 and the target slope is down to the surface at 1 to 1, you can draw a circle that is 10' diameter and set the elevation to be 10' lower than the reference point (10' x 1 to 1). This will provide a much better solution. If the difference in elevation between the reference point and the target surface is small it does not limit the size of the circle. You will still get the same solution even if the interpolated circle falls below the target surface. 

Neil Wilson (a.k.a. neilw)
AEC Collection/C3D 2024, LDT 2004, Power Civil v8i SS1
WIN 10 64 PRO

http://www.sec-landmgt.com
0 Likes
Message 8 of 32

Neilw_05
Mentor
Mentor

Disregard that last comment about the solution being the same if the circle is below the target. That is not correct. In that scenario the solution becomes more complicated. You would need to use a combination of grading and surface models. The approach would be to create a cone shaped surface with gradings and then find the line of intersection between the 2 surfaces. That idea may have been suggested previously.

Neil Wilson (a.k.a. neilw)
AEC Collection/C3D 2024, LDT 2004, Power Civil v8i SS1
WIN 10 64 PRO

http://www.sec-landmgt.com
0 Likes
Message 9 of 32

Ranjit_Singh
Advisor
Advisor

See if the below lisp helps. It will use 2 points to determine the direction of a vector and then determine its intersection with surface.

;;; Get intersection point with surface
;;; created by Ranjit Singh 12/21/16
(vl-load-com)
(defun c:gip  (/ adoc curcmdecho curnomutt modelspace newss pt1 pt2 retpt vdirection1 vdirection2 vlasurf x y)
  (defun *error*  (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (setvar 'cmdecho curcmdecho)
    (setvar 'nomutt curnomutt)
    (vla-endundomark adoc)
    (princ))
  (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
  (setq curcmdecho (getvar 'cmdecho)
        curnomutt  (getvar 'nomutt)
        modelspace (vla-get-modelSpace adoc))
  (prompt "\nSelect Tin Surface: ")
  (setvar 'cmdecho 0)
  (setvar 'nomutt 1)
  (setq vlasurf (vlax-ename->vla-object (car (entsel))))
  (setvar 'nomutt 0)
  (setq pt1 (vlax-3d-point (getpoint "\nSelect first point: "))
        pt2 (vlax-3d-point (getpoint "\nSelect second point: ")))
  (setvar 'nomutt 1)
  (setq vDirection1 (vla-get-DirectionVector (vla-AddRay modelspace pt1 pt2))
        vDirection2 (vla-get-DirectionVector (vla-AddRay modelspace pt2 pt1)))
  (entdel (entlast))
  (entdel (entlast))
  (setq newss (ssadd))
  (mapcar
    '(lambda (x y)
       (if
         (not
           (vl-catch-all-error-p
             (setq retpt (vl-catch-all-apply 'vlax-invoke-method (list vlaSurf 'IntersectPointWithSurface x y)))))
          (progn (vla-addpoint modelspace retpt) (ssadd (entlast) newss))))
    (list pt1 pt2)
    (list vDirection1 vDirection2))
  (if (/= (sslength newss) 0)
    (sssetfirst nil newss)
    (princ "\nNo intersection found"))
  (*error* "end"))
(prompt "Type GIP to find intersection with surface. Needs 2 points to define vector.")

 

Message 10 of 32

Anonymous
Not applicable

So the way i solved it was using a circle, breaking so i am able to turn it into a feature line, then grading that at 1:10 to the desired surface. Where the toe intersects the surface at desired location i drew a 3d poly line from there back up to the design crest

 

1.JPG2.JPG

0 Likes
Message 11 of 32

Neilw_05
Mentor
Mentor

Now that I see your drawing I think you can solve that scenario more directly with a single featureline, assuming all the graphics are at true elevation. Strike a featureline from your start point to a point on the target line. Label the slope on the featureline for visual feedback. Then just move the end point along the target line until you achieve the desired slope. 

Neil Wilson (a.k.a. neilw)
AEC Collection/C3D 2024, LDT 2004, Power Civil v8i SS1
WIN 10 64 PRO

http://www.sec-landmgt.com
0 Likes
Message 12 of 32

Neilw_05
Mentor
Mentor

Hi

 

I may not understand your program correctly but from the video it looks like you only solve for a single point along a vector. The task is to find any point in any direction from the origin, with visual feedback for the solutions. Are you able to do that? 

Neil Wilson (a.k.a. neilw)
AEC Collection/C3D 2024, LDT 2004, Power Civil v8i SS1
WIN 10 64 PRO

http://www.sec-landmgt.com
0 Likes
Message 13 of 32

Ranjit_Singh
Advisor
Advisor

@Anonymous wrote:

Hi

 

I may not understand your program correctly but from the video it looks like you only solve for a single point along a vector. The task is to find any point in any direction from the origin, with visual feedback for the solutions. Are you able to do that? 


I misunderstood OPs original post of finding intersection of a single line. If he needs to check every possible direction then grading is the way to go.


@Anonymous wrote:

............... what i'm looking for is to project a single line at a grade (say 1:10) from a crest level of my design to an existing surface. .................

 

Andrew


 

0 Likes
Message 14 of 32

TerryDotson
Mentor
Mentor

This video shows the way I envision what you described.  We had an existing design on the drawing simply as a guide for the demo.

 

We're adding this to our C3D FeatureLine Tools today.

Message 15 of 32

Neilw_05
Mentor
Mentor

Hi Terry,

 

That is a nice functioning tool. Well done. However I don't think it solves this particular task. We need to solve from a single point, not from along a linear feature. It still might be useful as it is for some scenarios though.

Neil Wilson (a.k.a. neilw)
AEC Collection/C3D 2024, LDT 2004, Power Civil v8i SS1
WIN 10 64 PRO

http://www.sec-landmgt.com
0 Likes
Message 16 of 32

tcorey
Mentor
Mentor

Hello Ranjit,

 

I like your program.

 

I did something similar to yours, inserted below. I am struggling to get the error checking, so anyone out there who cares to contribute has my permission to modify the code so that it traps the error that occurs when the user inputs values that don't find an intersection with the surface.

 

The routine asks for a surface, asks for startpoint (uses this as starting elevation for the upcoming 3D poly that gets drawn), asks for direction point and then for slope. The routine draws a 3D polyline along that 3D vector until it intersects the surface. You can use Create Feature Lines from Objects to convert to feature line.

 

I think this directly addresses the OP's request, no?

 

 



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 17 of 32

Ranjit_Singh
Advisor
Advisor

Hi Tim, I think you forgot to attach the code.

0 Likes
Message 18 of 32

tcorey
Mentor
Mentor

Yes, I did. Here it is....

					;Needs error trapping
;Select a surface
					;Pick a start point on a feature/polyline
;Pick a direction point
;Enter a slope in percent
;routine draws a 3d polyline along the selected direction and slope until it intersects the surface
;This routine needs error trapping as it fails when you input values that don't allow the intersection to be found


(defun c:go (/ cosmode srf stpt stptz endpt endptxy0 difx slop difz newxyz rayo dirvec basep newpt)


  (vl-load-com)
  (setq cosmode (getvar "OSMODE"))
  (setvar "OSMODE" 0)

  (setq
    srf	(vlax-ename->vla-object (car (entsel "\nSelect Surface: ")))
  )					;user selects the surface.
   (setq stpt (getpoint "\nSelect Start Point: "))
    (setq stptz (caddr stpt))
    (setq endpt (getpoint "\nSelect direction point: "))
    (setq endptxy0 (list (car endpt) (cadr endpt) stptz))
    (setq difx (distance stpt endptxy0))
    
     (setq slop (/ (getreal "\nEnter slope in percent: ") 100))
    (setq difz (* difx slop))
    
    (setq newxyz (list (car endpt) (cadr endpt) (+ stptz difz)))
    
    (vl-cmdf "Ray" stpt newxyz "")
    (setq rayo (vlax-ename->vla-object (entlast)))
    (setq dirvec (vlax-get-property rayo 'DirectionVector))
    (setq basep (vlax-get-property rayo 'BasePoint))
    (vl-cmdf "erase" (entlast) "")

  
    
	       (setq newpt (vlax-invoke-method srf 'IntersectPointWithSurface basep dirvec))
               (setq newpt (list (vlax-safearray-get-element (vlax-variant-value newpt) 0)
				 (vlax-safearray-get-element (vlax-variant-value newpt) 1)
				 (vlax-safearray-get-element (vlax-variant-value newpt) 2)
				 )
		     )
  
	(vl-cmdf "3dpoly" stpt newpt "")
	

  (setvar "OSMODE" cosmode)
  (princ)
  ;(*error* "end")
)					;end defun









Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 19 of 32

TerryDotson
Mentor
Mentor

Easy enough, we added a [Point] option that lets the user pick a 3d point location instead of a linear object.

0 Likes
Message 20 of 32

Ranjit_Singh
Advisor
Advisor

Nice. I will spend time on your error trap sometime later today (assuming no one else gets to it before that). Meanwhile, I am attaching a modification to my above LISP, give it a try. I will, time permitting, add grade and slope options as well.

;;; Get intersection point with surface
;;; created by Ranjit Singh 12/21/16
(vl-load-com)
(defun c:gip  (/ adoc b curcmdecho curnomutt i modelspace newss pt1 pt2 retpt vdirection vlasurf)
  (defun *error*  (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (setvar 'cmdecho curcmdecho)
    (setvar 'nomutt curnomutt)
    (vla-endundomark adoc)
    (princ))
  (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
  (setq curcmdecho (getvar 'cmdecho)
        curnomutt  (getvar 'nomutt)
        modelspace (vla-get-modelSpace adoc))
  (prompt "\nSelect Tin Surface: ")
  (setvar 'cmdecho 0)
  (setvar 'nomutt 1)
  (setq vlasurf (vlax-ename->vla-object (car (entsel))))
  (setvar 'nomutt 0)
  (setq pt1 (getpoint "\nSelect first point: ")
        pt2 (getpoint "\nSelect second point: "))
  (setvar 'nomutt 1)
  (setq b     100 ; this sets how many points needed
        i     0
        newss (ssadd))
  (repeat b
    (setq vDirection
           (vla-get-DirectionVector
             (vla-AddRay
               modelspace
               (vlax-3d-point pt1)
               (vlax-3d-point
                 (append
                   (reverse
                     (cdr (reverse
                            (polar pt1
                                   (+ (angle pt1 pt2) (* i (* (/ (/ 360.0 b) 180.0) pi)))
                                   (distance (reverse (cdr (reverse pt1))) (reverse (cdr (reverse pt2))))))))
                   (cddr pt2))))))
    (entdel (entlast))
    (if (not
          (vl-catch-all-error-p
            (setq
              retpt (vl-catch-all-apply 'vlax-invoke-method
                                        (list vlaSurf 'IntersectPointWithSurface (vlax-3d-point pt1) vDirection)))))
      (progn (vla-addpoint modelspace retpt) (ssadd (entlast) newss)))
    (setq i (1+ i)))
  (if (/= (sslength newss) 0)
    (sssetfirst nil newss)
    (princ "\nNo intersection found"))
  (*error* "end"))
(prompt "Type GIP to find intersection with surface. Needs 2 points to define vector.")
0 Likes