Jump to content

Circle on a Surface


Jozi68

Recommended Posts

I need to draw a circle, then drape it on a Civil 3D surface (ie turn it into a 3DPoly perhaps?), and then find all points on the circle that has a specific elevation. Does anyone have any ideas on this?

Link to comment
Share on other sites

  • Replies 40
  • Created
  • Last Reply

Top Posters In This Topic

  • Jozi68

    15

  • SEANT

    7

  • Hippe013

    7

  • BIGAL

    4

Top Posters In This Topic

Posted Images

Thanx Lee Mac,

I don't think that is what I need. I've made some progress, this is taking very long, as I've never written any lisp before. I got my code to make the 2D Polyline, but the conversion to 3D Polyline is not working, as it pauses to get user input. Any help with this part would be appreciated.

 

(defun c:CS ( / circle_1 2dP pt1)

 (if (setq pt1 (getpoint "\nEnter the start point: "))
  
   (progn
     (command "circle" pt1 10)
     (setq circle_1 (entlast))  
     (COMMAND "_polygon" 50 pt1 "_I" "10")

     (setq 2dP (entlast))
     (entdel circle_1)

     (Command "_aeccConvertPlines" 2dP) ;This is not working, it should not pause here

     
   )
 )
(princ)
)

Link to comment
Share on other sites

I’ll state up front that I don’t know anything about Civil 3D surfaces.

 

Can a Planar surface intersect with a Civil 3D surface? In other words, can a contour be generated at those specific elevations. If so, could a regular flat circle then be used to find intersections with that/those contours?

Link to comment
Share on other sites

Hi Sean,

I am not really sure.

I was thinking that if I could convert my 2dpoly to 3dpoly, and then drape to the surface, it should be easy to just loop through the vertices to find the right one.

Link to comment
Share on other sites

Hi Sean,

I am not really sure.

I was thinking that if I could convert my 2dpoly to 3dpoly, and then drape to the surface, it should be easy to just loop through the vertices to find the right one.

 

That sounds like a reasonable game plan. As stated, I don't know anything about Civil 3d, so I imagined how I would go about it in AutoCAD if I had some type of topographical/undulating loft style surface.

Link to comment
Share on other sites

Now my problem is using Civil 3D commands that require the user to click to select. I have the 2D Polyline selected, but Civil 3D wants the user to choose more entities or click enter. Any suggestions?

Link to comment
Share on other sites

I need to draw a circle, then drape it on a Civil 3D surface (ie turn it into a 3DPoly perhaps?), and then find all points on the circle that has a specific elevation. Does anyone have any ideas on this?

 

If Civil 3D surface behaves like AutoCAD surface entity, I would suggest following...

- copy surface and circle at the same 3D space position...

- create cylinder 3D SOLID from circle - use EXTRUDE command...

- use CONVTOSURFACE command to convert CYLINDER to corresponding 3D surface...

- use INTERSECT command on copied Civil 3D surface and CYLINDER surface...

 

Observe resulting SPLINE entity... With various methods, you can convert this 3D SPLINE to 3D POLYLINE by segmenting SPLINE entity, or alternatively you could try to obtain desired elevation points on that 3D SPLINE directly by using ID command and picking points with turned "Nearest" OBJECT SNAP - (setvar 'osmode 512)...

 

HTH, M.R.

Link to comment
Share on other sites

I believe that the OP is looking for something like this. This is a quick and dirty method.

 

(defun c:Test ()
 (setq ms (vlax-get-property (vlax-get-property (vlax-get-acad-object) 'ActiveDocument) 'ModelSpace))
 (defun pl->var (pl / ub sa var)
   (setq ub (- (length pl) 1))
   (setq sa (vlax-make-safearray vlax-vbdouble (cons 0 ub)))
   (setq var (vlax-make-variant (setq sa (vlax-safearray-fill sa pl))))
   )
 (princ "\nSelect Circle:")
 (setq ss (ssget ":S" '(( 0 . "CIRCLE"))))
 (setq pl nil)
 (if ss
   (progn
     (setq cir (vlax-ename->vla-object (ssname ss 0)))
     (setq rp (vlax-safearray->list (vlax-variant-value (vlax-get-property cir 'Center))))
     (setq r (vlax-get-property cir 'Radius))
     (princ "\nSelect AECC TIN Surface:")
     (setq ss (ssget ":S" '((0 . "AECC_TIN_SURFACE"))))
     (setq surf (vlax-ename->vla-object (ssname ss 0)))
     (setq a 0)
     (repeat 360
(setq p (polar rp a r))
(setq el (vlax-invoke-method surf 'FindElevationAtXY (car p)(cadr p)))
(setq p (list (car p)(cadr p)el))
(setq pl (append pl p))
(setq a (+ a (/ pi 180.0)))
)
     (setq var (pl->var pl))
     (setq 3dobj (vlax-invoke-method ms 'Add3DPoly var))
     (vlax-put-property 3dobj 'Closed 1)
     )
   )
 )

 

Please bear in mind that I didn't look too close into error trapping. This will error out if any portion of the circle is not on top of the surface. This will sample every degree in the circle.

 

regards,

 

hippe013

 

P.S. Maybe somebody is willing to take this idea and clean it up (add error trapping & deal with local vs. global variables).

Edited by Hippe013
added P.S.
Link to comment
Share on other sites

I've changed Hippe013's code a bit (the circle is not really needed, etc):

(defun c:CS ( / pt1)
 (if (setq pt1 (getpoint "\nEnter the start point: "))
   (progn
     (setq rp pt1)
     (setq r 10)
     (princ "\nSelect AECC TIN Surface:")
     (setq ss (ssget ":S" '((0 . "AECC_TIN_SURFACE"))))
     (setq surf (vlax-ename->vla-object (ssname ss 0)))
     (setq a 0)
     (repeat 360
   (setq p (polar rp a r))
   (setq el (vlax-invoke-method surf 'FindElevationAtXY (car p)(cadr p)))
   (setq p (list (car p)(cadr p)el))
   (setq pl (append pl p))
   (setq a (+ a (/ pi 180.0)))
   )
     (setq var (pl->var pl))
     (setq 3dobj (vlax-invoke-method ms 'Add3DPoly var))
     (vlax-put-property 3dobj 'Closed 1)
     )
   )
(princ)
)

Now I get an error on this line: (setq var (pl->var pl))

The error is: no function definition: PL->VAR

Please help with this one. When the error is not there, it gives interesting results when you run the code more than once.

Link to comment
Share on other sites

You are missing the definition of pl->var

 

(defun pl->var (pl / ub sa var)
   (setq ub (- (length pl) 1))
   (setq sa (vlax-make-safearray vlax-vbdouble (cons 0 ub)))
   (setq var (vlax-make-variant (setq sa (vlax-safearray-fill sa pl))))
   )

 

You need to make the variable "pl" a local variable. Otherwise every time you run the code the list "pl" will keep growing as you keep appending the the same list "pl".

 

Make sense?

 

 

Edit: Actually all the variables should be local. (defun c:cs ( / pt1 rp r ss surf a p el pl var 3dobj)....

 

Is the radius of the circle always going to be 10?

Link to comment
Share on other sites

Thank you so much Hippe013, It's working beautifully.

Radius will always be 10 yes.

 

If I now connect 2 of the vertices of the object to the starting point (center), the slope of those 2 line will be 1%. So I need to loop through them all, and test the height difference. Can you help me with ideas? At this point I don't think the start point is draped on the surface.

 

BTW, I am trying to create something similar to "Grade poly" on http://www.dotsoft.com/mwsurfaces.htm

Here is my code so far:

(defun c:CS ( / pt1 rp r ss surf a p el pl var 3dobj)
 (if (setq pt1 (getpoint "\nEnter the start point: "))
   (progn
     (setq rp pt1)
     (setq r 10)
     (princ "\nSelect AECC TIN Surface:")
     (setq ss (ssget ":S" '((0 . "AECC_TIN_SURFACE"))))
     (setq surf (vlax-ename->vla-object (ssname ss 0)))
     (setq a 0)
     (repeat 360
   (setq p (polar rp a r))
   (setq el (vlax-invoke-method surf 'FindElevationAtXY (car p)(cadr p)))
   (setq p (list (car p)(cadr p)el))
   (setq pl (append pl p))
   (setq a (+ a (/ pi 180.0)))
   )
     (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
     (setq var (pl->var pl))
     (setq 3dobj (vlax-invoke-method mspace 'Add3DPoly var))
     )
   )
(princ)
)

(defun pl->var (pl / ub sa var)
   (setq ub (- (length pl) 1))
   (setq sa (vlax-make-safearray vlax-vbdouble (cons 0 ub)))
   (setq var (vlax-make-variant (setq sa (vlax-safearray-fill sa pl))))
   )

Link to comment
Share on other sites

If I now connect 2 of the vertices of the object to the starting point (center), the slope of those 2 line will be 1%. So I need to loop through them all, and test the height difference. Can you help me with ideas? At this point I don't think the start point is draped on the surface.

 

I guess that I am not certain as to what you are looking to do. As for the center points elevation you should at this time know how to obtain the elevation of the center point of the circle.

 

You need to invoke the FindElevationAtXY method on the surf object (AECC_TIN_SURFACE). Your center point is under the rp variable so the code would be as follows:

 

(setq rp-elev (vlax-invoke-method surf 'FindElevationAtXY (car rp)(cadr rp)))

 

The method FindElevationAtXY requires two arguments (the x and the y) ie (car rp)=X (cadr rp)=Y

 

If you are able to clarify as to what you are trying to achieve I should be able to help with ideas.

Link to comment
Share on other sites

I need the user to select a slope; normally it would be 1%.

Then he selects a point on a surface, and the application then should draw a 3dpoly (from that point upwards) at the required slope. There would normally be 2 lines, from the point that the user selected.

 

I'm not sure if this makes sense. I see that DotSoft is offering this function, they call it Grade Poly (http://www.dotsoft.com/mwsurfaces.htm), but there is no way we could pay $495.

 

So my thinking was to draw the circular 3dpoly, drape it to the surface, and then iterate through the vertices, find the one (or two) that gives the correct grade. The center point would then be connected to this point with a line. Then a new circular 3dPoly would be created with the new point as the center. Then the iteration would be repeated. Eventually, we will have a series of lines; these should all be concatenated, to form a 3dpoly that has a consistent grade on the surface. I am not very good a explaining things, so I hope you understand this.

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...