Jump to content

Routine to project a Curve Wall to Elevation


Recommended Posts

Posted

Hi All,

I have been trying to write a routine that would project a curved wall to the elevation, based on the number of segments the user would input.

So far I could figure out how to get points along the arc based on the number of segments. Now I want to project it to a selected line as shown in the picture. The code now draws the radiating lines to the points on the arc.

I am stuck here. Now I dont know how to draw perpendiculars to the line from these points. In fact I dont know how to figure out the angle at which these lines should be projected.

In the picture, they are simple, the lines could be projected to an angle of 270 degrees. But what is the line lies on top of the arc; or at right side of the arc at an angle of 10 degrees? This is where I am stuck Could someone guide me to find out the projection angle of the lines from each 'P2's (the points along the arc)? Here is my code...

 

(defun c:crv ( / entarc entline)
   (while (and (setq entarc (car (entsel "\nPick An Arc: ")))
	(not (eq "ARC" (cdr (assoc 0 (entget entarc)))))
   )
   (princ "\nPlease Select an Arc...")
   )
 
   (while
     (and
(setq entline (car (entsel "\nPick a line to project on:")))
(not (eq "LINE" (cdr (assoc 0 (entget entline)))))
     );and
     (princ "\nPlease select a line....")
   );While
 
 (setq Segments (cond ((getint "\nNumber of Segments:")) (10)))
 (setq Height (getdist "\nCut-off Height:"))
 (projectlines entarc entline)
 (princ)
);Function



;;;****************************************************
;;;This is the function which draws the projected lines
;;;****************************************************

(defun projectlines (ArcObj LineObj
	     / ArcCenter ArcStartAngle ArcEndAngle
	     ArcRadius ArcStartPoint ArcEndPoint)

 (setq ArcCenter (cdr ( assoc 10 (entget ArcObj))))
 (setq ArcStartAngle (cdr ( assoc 50 (entget ArcObj))))
 (setq ArcEndAngle (cdr ( assoc 51 (entget ArcObj))))
 (setq ArcRadius  (cdr ( assoc 40 (entget ArcObj))))
 (setq ArcStartPoint (polar ArcCenter ArcStartAngle ArcRadius))
 (setq ArcEndPoint (polar ArcCenter ArcEndAngle ArcRadius))
 (setq ArcAngle (abs (- ArcStartAngle ArcEndAngle)))

 (setq LineStartPoint (cdr (assoc 10 (entget LineObj))))
 (setq LineEndtPoint (cdr (assoc 11 (entget LineObj))))
 (setq LineAngle (angle LineStartPoint LineEndtPoint))
 (setq LinePerpendicular (+ LineAngle (dtor 90)))

 (setq i 1)
 (setq p2 ArcStartPoint)
 (setq AngleDivision (/ ArcAngle Segments))

 (setq OSM (getvar "OSMODE"))
 (setvar "OSMODE" 0)


 (repeat (1+ Segments)
   (command "_LINE" ArcCenter p2 "")
   (setq p2 (polar ArcCenter (+ ArcStartAngle (* AngleDivision i)) ArcRadius))
   (setq i (1+ i))
 )
 (setvar "OSMODE" OSM)
);Function

(defun dtor(d)
 (* d 0.01745329)
)

Curve_Wall.jpg

Posted

If its one elevation then just use THICKNESS it does this to lines arcs etc

Posted

Thanks for your reply BIGAL,

But it is not at all a 3D drawing. Just a plane 2D drawing.

The problem is that it would also demand a rotation of the view / ucs to show up that thickness.

In my case, the plan and elevation must be placed on the same plane.

Posted

Something like this?

(vl-load-com)

(defun c:ProjectCurve (/ crv l1 l2 div pt1 pt2 pt3 n l1s l1e ang l2s l2e)
 (if (and (setq crv (entsel "\nPick curve: "))
          (setq crv (car crv))
          (setq l1 (entsel "\nPick furthest projection line: "))
          (setq l1 (entget (car l1)))
          (setq l1s (cdr (assoc 10 l1)))
          (setq l1e (cdr (assoc 11 l1)))
          (setq ang (+ (angle l1s l1e) (/ pi 2.0)))
          (setq l2 (entsel "\nPick nearest projection line: "))
          (setq l2 (entget (car l2)))
          (setq l2s (cdr (assoc 10 l2)))
          (setq l2e (cdr (assoc 11 l2)))
          (setq div (getdist "\nSelect maximum curvature arc length per projection line: "))
     )
   (progn
     (setq n   (vlax-curve-getDistAtParam crv (vlax-curve-getEndParam crv))
           div (/ n (1+ (fix (/ n div))))
     )
     (while (> n 0.0)
       (setq pt1 (vlax-curve-getPointAtDist crv n)
             pt2 (inters l1s l1e pt1 (polar pt1 ang 1000.0) nil)
             pt3 (inters l2s l2e pt1 (polar pt1 ang 1000.0) nil)
       )
       (entmake (list '(0 . "LINE")
                      (cons 8 (getvar 'CLayer))
                      (cons 410 (getvar 'CTab))
                      (cons 10 pt2)
                      (cons 11 pt3)
                )
       )
       (setq n (- n div))
     )
   )
 )
 (princ)
)

Not enough error checking but at least it works. Even "works" on pl arcs, though for those there should be a bit of different programming to make it work on segment endpoints as well.

Posted

Wow...!!! Thats Great...!!! Thanks a lot for that code, IRNEB...!! :D:D:D:D

Posted

You're welcome. I wasn't sure if you wanted the divisions by a specified number or rather as per my code (a maximum source distance). It would be a small change to asking the user to enter the number of divisions instead, actually the math would also be a bit simpler.

Posted

Well... that will work...

And I asked for 1 kg of iron and received 1 kg of gold...!!! HE HE.. :D

Why because, my code would have worked only for arc objects. This works on anything...!!!

Thanks...!!

Posted

Also I got a lot new things from your code to learn...!!! Happy Happy.... :)

Posted
Also I got a lot new things from your code to learn...!!! Happy Happy.... :)
Yep! Glad to help you learn :thumbsup:. It's how I learnt most of what I know: examples & doing it for myself from there.

 

Mainly the vlax-curve functions is what makes my code a lot easier than it would be otherwise. Then it's the usual obtaining an angle, rotating by half-pi (90 degrees) then getting intersections by using inters & polar. That last part allows the projection to be at any angle as well, it projects perpendicular to the furthest projection plane. So your 2 planes may even be non-parallel and at any angle.

Posted

To have more extra line of codes for insurance would be much more better for national security . :)

 


(eq (cdr (assoc 0 (entget crv))) "ARC")
(eq (cdr (assoc 0 l1)) "LINE")
(eq (cdr (assoc 0 l2)) "LINE")

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