Jump to content

Recommended Posts

Posted

At the university, they asked me to make a figure based on a drawing. It turns out everything except rounding the corners. Help me how to do it, I've searched the entire Internet and gpt. It is necessary that it be drawn immediately with a given radius. And it didn't ask you to choose. Fillet asks you to select the sides of the rounding after the construction. You need to round the lines: 2 from 3 and 3 from 4, 8 from 7 and 7 from 6. My code:
 

(defun c:DrawLinesNamed ()
  (progn
    ;;LINE1
    (command "LINE" "0,0" "5,0" "")
    
    ;;LINE2
    (command "LINE" "5,0" "5,20" "")
    
    ;; LINE3
    (command "LINE" "5,20" "10,20" "")
    
    ;;LINE4
    (command "LINE" "10,20" "10,0" "")
    
    ;;LINE5
    (command "LINE" "10,0" "16,0" "")
    
    ;;LINE6
    (command "LINE" "0,0" "0,20" "")
    
    ;; LINE7
    (command "LINE" "0,20" "-5,20" "")
    
    ;; LINE8
    (command "LINE" "-5,20" "-5,0" "")
    
    ;; LINE9
    (command "LINE" "-5,0" "-11,0" "")
    
    ;;  LINE10
    (command "LINE" "-7.5,25" "-11,5" "")
    
    ;; LINE11
    (command "LINE" "-7.5,25" "12.5,25" "")
    
    ;; LINE12
    (command "LINE" "12.5,25" "16,5" "")
    
     ;;LINE13
    (command "LINE" "-11,0" "-11,5" "")
    
     ;;LINE14
      (command "LINE" "16,0" "16,5" "")
  )
)

 

photo_2024-11-26_18-36-11.jpg

Posted

I'd suggest drawing this figure using polyline and if the final outcome needs to be lines and arcs, explode the polyline figure after it is drawn.

 

Use polar function to get all the points and then feed them to polyline command, alternating "l" and "a" polyline options as you go.

For example, if the fillet radius is 1, start:

 

(setq r 1.0
      p1 (list 0 0)
      p2 (polar p1 (* pi 0.5) (- 20 r))
      p2c (polar p2 (* pi 0.5) r)
      p3 (polar p2c pi r)
      p4 (polar p3 pi (- 5 (* 2 r)))
      p4c (polar p4 pi r)
      p5 (polar p4c (* pi 1.5) r)
      p6 (polar p5 (* pi 1.5) (- 20 r))
      p7 (polar p6 pi 6.0)
      )
(command "pline" p1 p2 "a" p3 "l" p4 "a" p5 "l" p6 p7 "")


 

 

Posted

My $0.05

 

(command "pLINE"
"0,0"
"5,0"
"5,20"
"10,20"
"10,0"
"16,0"
"16,5"
"12.5,25"
"-7.5,25"
"-11,5"
"-11,0"
"-5,0"
"-5,20"
"0,20"
"C")

Ok now look at fillets. There is a few ways to the fillets easiest is using a point on the pline segments.

 

(setvar 'filletrad 1)
(command "fillet" (list -5 10) (list -2.5 20))
(command "fillet" (list -2.5 20)(list 0 10))

(command "fillet" (list 7.5 20)(list 5 10))
(command "fillet" (list 7.5 20)(list 10 10))

Personally I would use something like this method.

(setq 
pt1 (list 0 0)
pt2 (list 5 0)
pt3 list 5 20)
pt4 (list 10 20)
pt5(list 10 0)
pt6 (list 16 0)
pt7 (list 16 5)
pt8 (list 12.5 25)
pt9 (list -7.5 25)
pt10 (list -11 5)
pt11 (list -11 0)
pt12 (list -5 0)
pt13 (list -5 20)
pt14 (list 0 20)
(command "pline" pt1 pt2 pt3...pt14 "C") ; include all points

You can now work out the fillet points using polar or a mapcar + to X& Y.

Or like Paulmcz use pline with "a" option.

 

The mapcar function

(setq pt2 (mapcar '+ pt1 (list X Y 0.0))) ; use correct X & Y adjustment
(setq pt3 (mapcar '+ pt2 (list X Y 0.0))) ; use correct X & Y adjustment
repeat as required

 

Posted

Usually, it’s better to avoid the use of the COMMAND function. The ENTMAKE function was created just for what you need.

So here is the program PP0 to draw a simple polyline:

(defun c:pp0()
   (entmake
     (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity")'(100 . "AcDbPolyline") (cons 90 5) (cons 70 0)
                   (cons 10 (list 0.0 0.0))
                   (cons 10 (list 5.0 0.0))
                   (cons 10 (list 5.0 20.0))
                   (cons 10 (list 10.0 20.0))
                   (cons 10 (list 10.0 0.0))
                   )
     )
   )

That (cons 70 0) at the end of the third line means “open polyline”, change that for (cons 70 1) to close it.

poly1.gif.08bfa60d248b4c71232a21485391faa0.gif

This draws straight lines. Let’s say a line goes to point A and from there a different line continues in a perpendicular direction. To fillet these two lines, the straight line must stop before it reaches the A point. Also, the next line will start not from A, but at a distance. If the lines are perpendicular to each other, the distances are booth equal with the fillet radius.

In the program PP1 there is some math. It draws almost the same polyline, just it “leaves space” from the fillets. As you can see, it asks for the radius fist. Then it calculates the ends of the straight lines and it draws the polyline accordingly. It is the user’s responsibility to enter correct values, the light-blue polyline has a too large radius.

(defun c:pp1()
   (setq r (getdist "radius? "))
   (entmake
     (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity")'(100 . "AcDbPolyline") (cons 90 7) (cons 70 0)
                   (cons 10 (list 0.0 0.0))
                   (cons 10 (list 5.0 0.0))
                   (cons 10 (list 5.0 (- 20.0 r)))
                   (cons 10 (list (+ 5.0 r) 20.0))
                   (cons 10 (list (- 10.0 r) 20.0))
                   (cons 10 (list 10.0 (- 20.0 r)))
                   (cons 10 (list 10.0 0.0))
                   )
     )
   )

poly2.gif.a3e86e80d65b1fff4b14ad596957b4ff.gif

But this program is not exactly what you need. There are straight segments instead of fillets. The program PP2 ads the “bulge factor” – that (42 . …). That says to AutoCAD to curve a straight segment. If there is no bulge factor, AutoCAD assumes that is zero (straight line). So adding '(42 . 0) or add nothing will result in the same thing: straight lines. But adding 0.5 it will draw a quarter of circle -and that’s what we need here. In fact, there is -0.5 because the curvature direction.

(defun c:pp2()
   (setq r (getdist "radius? "))
   (entmake
     (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity")'(100 . "AcDbPolyline") (cons 90 7) (cons 70 0)
                   (cons 10 (list 0.0 0.0)) '(42 . 0)
                   (cons 10 (list 5.0 0.0)) '(42 . 0)
                   (cons 10 (list 5.0 (- 20.0 r))) '(42 . -0.5)
                   (cons 10 (list (+ 5.0 r) 20.0)) '(42 . 0)
                   (cons 10 (list (- 10.0 r) 20.0)) '(42 . -0.5)
                   (cons 10 (list 10.0 (- 20.0 r))) '(42 . 0)
                   (cons 10 (list 10.0 0.0)) '(42 . 0)
                   )
     )
   )

 

poly3.gif.e480b09bb960ce26010994529e716168.gif

The same rule is still true: wrong inputs will lead to a wrong polyline. See that dark-blue line with too large fillet radius.

Posted
(defun c:pp3()
   (setq r (getdist "radius? "))
   (entmake
     (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity")'(100 . "AcDbPolyline") (cons 90 18) (cons 70 1)
	   (list 10 0.0 0.0)
	   (list 10 5.0 0.0)
	   (list 10 5.0 (- 20.0 r)) (cons 42 -0.5)
	   (list 10 (+ 5.0 r) 20.0) 
	   (list 10 (- 10.0 r) 20.0) (cons 42 -0.5)
	   (list 10 10.0 (- 20.0 r))
	   (list 10 10.0 0.0)
	   (list 10 16.0 0.0)
	   (list 10 16.0 5.0)
	   (list 10 12.5 25.0)
	   (list 10 -7.5 25.0)
	   (list 10 -11.0 5.0)
	   (list 10 -11.0 0.0)
	   (list 10 -5.0 0.0)
	   (list 10 -5.0 (- 20 r)) (cons 42 -0.5)
	   (list 10 (+ -5.0 r) 20.0)
	   (list 10 (- r) 20.0) (cons 42 -0.5)
	   (list 10 0.0 (- 20.0 r))
	   )
     )
   )

;)

 

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