Author Topic: Arc  (Read 3934 times)

0 Members and 1 Guest are viewing this topic.

Newbie

  • Guest
Arc
« on: November 23, 2017, 02:35:44 AM »
Hi!
I have a  lisp script and it works almost  as I want it to.
Could someone help me fixing  it?
Tried to fix it by myself.. guess I’m not that headstrong as I thought

The problem is the arc that’s being made inside the circle, the radius is too small,  I need to make it waay bigger then that so the arc would look like a straight line or near it. So the entrance point to the circle would be close to 90 degrees.

See the pics. 
The “2” pic is how I need it to be.

Code - Auto/Visual Lisp: [Select]
  1.  (defun o-vrd (offs)                   
  2.                                        
  3.    (setvar "cmdecho" 0)
  4.   (setq old_osmode (getvar "osmode"))                  
  5.   (setvar "osmode" 0)
  6.  
  7.  (setq nabor (ssget "X" '((0 . "CIRCLE"))))
  8.   (setq kol (sslength nabor))
  9.   (setq I 0)
  10.  
  11.   (repeat kol
  12.     (setq dan (entget (ssname nabor I)))
  13.     (setq imia (cdr (assoc -1 dan)))
  14.     (setq center (cdr (assoc 10 dan)))
  15.     (setq radius (cdr (assoc 40 dan)))
  16.  
  17.     (setq xc (nth 0 center))
  18.     (setq yc (nth 1 center))
  19.  
  20.     (setq radius (- radius offs))
  21.  
  22.      (command "ERASE" imia "")      
  23.      
  24.      (setq ydwn (- yc radius))
  25.      (setq ver3 (list xc ydwn))
  26.      (setq ycdwn (+ yc 0.001))
  27.      (setq xcleft (- xc 0.001))
  28.      (setq ver33 (list xcleft ydwn))
  29.  
  30.      (command "ARC" "c" center ver3 ver33)
  31.                                     (setq dan1 (entget (entlast)))
  32.                                     (setq imia1 (cdr (assoc -1 dan1)))
  33.  
  34.                                            
  35.     (if (> radius 2.5)
  36.       (setq yvr (+ ydwn 2.5))
  37.       (setq yvr (+ ydwn radius))
  38.     )
  39.     (setq vrez (list xc yvr))
  40.     (setq dlvrez (- yvr ydwn))
  41.     (setq centvrez (+ ydwn (/ dlvrez 2)))
  42.     (setq cent (list xc centvrez))
  43.     (command "ARC"  "c" cent vrez ver3)
  44.     (command)
  45.                            (setq linvrez (entget (entlast)))
  46.                            (setq imia3 (cdr (assoc -1 linvrez)))
  47.                            (command "PEDIT" imia3 "y" "j" imia1  "" "")
  48.                            (setq plin (entget (entlast)))
  49.                            (setq imia6 (cdr (assoc -1 plin)))
  50.                            (command "CHANGE" imia6 "" "p" "c" "blue" "")
  51.  
  52.     (setq I (+ 1 I))
  53.   )
  54.    (setvar "cmdecho" 1)
  55.    (setvar "osmode" old_osmode)
  56. )
  57.  

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Arc
« Reply #1 on: November 23, 2017, 10:27:56 AM »
Why don't you use a block?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Newbie

  • Guest
Re: Arc
« Reply #2 on: November 24, 2017, 02:34:36 AM »
Why don't you use a block?

I don’t get it. Could you explain, please?

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: Arc
« Reply #3 on: November 24, 2017, 03:46:50 AM »
Ronjop i dong get it ether

Just pick a point on circle the using the centre point nominate some form of distance from circle to centre say 1/2 as an example you could do Aline pick mid then just use a big radius using start and end options.
A man who never made a mistake never made anything

Newbie

  • Guest
Re: Arc
« Reply #4 on: November 24, 2017, 06:50:46 AM »
Ronjop i dong get it ether

Just pick a point on circle the using the centre point nominate some form of distance from circle to centre say 1/2 as an example you could do Aline pick mid then just use a big radius using start and end options.

That’s the problem. I couldn’t figure out how.
I mean, I’ve read lisp manual , tried to change the code in various ways -  nothing

I figured, this part of the code makes the inside arc
Code - Auto/Visual Lisp: [Select]
  1.    (if  (> radius 2.5)
  2.       (setq yvr (+ ydwn 2.5))
  3.       (setq yvr (+ ydwn radius))
  4.     )
  5.     (setq vrez (list xc yvr))
  6.     (setq dlvrez (- yvr ydwn))
  7.     (setq centvrez (+ ydwn (/ dlvrez 2)))
  8.     (setq cent (list xc centvrez))
  9.     (command "ARC"  "c" cent vrez ver3)
  10.     (command)
  11.  

I need to change these parameters:“  command "ARC"  "c" cent vrez ver3)”


And That’s it. 

All my efforts end up like that.
« Last Edit: November 24, 2017, 08:12:34 AM by Newbie »

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: Arc
« Reply #5 on: November 24, 2017, 06:20:37 PM »
1st use Arc Start pt1 End pt2 R rad

Sometimes need mirror to flip arc.

Do manual arc using s & e so get idea of result.
A man who never made a mistake never made anything

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Arc
« Reply #6 on: November 26, 2017, 11:03:24 PM »
Ronjop i dong get it ether

Just pick a point on circle the using the centre point nominate some form of distance from circle to centre say 1/2 as an example you could do Aline pick mid then just use a big radius using start and end options.
Maybe I missed the point. Different thought process
« Last Edit: November 27, 2017, 10:15:45 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Arc
« Reply #7 on: November 27, 2017, 12:00:03 PM »
Here's a quick one to draw an arced polyline at selected circles.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ el p s)
  2.   (if (setq s (ssget ":L" '((0 . "circle"))))
  3.     (foreach c (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
  4.       (setq p (cdr (assoc 10 (setq el (entget c)))))
  5.       (entmakex   (list '(0 . "LWPOLYLINE")
  6.             '(100 . "AcDbEntity")
  7.             (assoc 8 el)
  8.             '(100 . "AcDbPolyline")
  9.             '(90 . 2)
  10.             (list 10 (car p) (- (cadr p) (/ (cdr (assoc 40 el)) 2.)))
  11.             '(42 . 0.1)
  12.             (list 10 (car p) (- (cadr p) (cdr (assoc 40 el))))
  13.             '(42 . 4.)
  14.       )
  15.       )
  16.     )
  17.   )
  18.   (princ)
  19. )
« Last Edit: November 27, 2017, 12:15:32 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Newbie

  • Guest
Re: Arc
« Reply #8 on: November 29, 2017, 08:09:36 AM »
Here's a quick one to draw an arced polyline at selected circles.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ el p s)
  2.   (if (setq s (ssget ":L" '((0 . "circle"))))
  3.     (foreach c (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
  4.       (setq p (cdr (assoc 10 (setq el (entget c)))))
  5.       (entmakex   (list '(0 . "LWPOLYLINE")
  6.             '(100 . "AcDbEntity")
  7.             (assoc 8 el)
  8.             '(100 . "AcDbPolyline")
  9.             '(90 . 2)
  10.             (list 10 (car p) (- (cadr p) (/ (cdr (assoc 40 el)) 2.)))
  11.             '(42 . 0.1)
  12.             (list 10 (car p) (- (cadr p) (cdr (assoc 40 el))))
  13.             '(42 . 4.)
  14.       )
  15.       )
  16.     )
  17.   )
  18.   (princ)
  19. )


Thanks for an example. I’ll try to figure out how it works and maybe try to apply to my code. 😄

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Arc
« Reply #9 on: December 02, 2017, 08:29:44 AM »
@Ron, just curious, why the (42 . 4)?

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Arc
« Reply #10 on: December 03, 2017, 02:20:59 AM »
(* 4.0 (atan 0.1)) = 22.842 degree
(* 4.0 (atan 4.0)) = 303.855 degree

I'd rather use (42 . 0.098491403) - (* 4.0 (atan 0.098491403)) = 22.5 degree
And it's complement (42 . 10.15317039) - (* 4.0 (atan 10.15317039)) = 337.5 degree

But my final guess is that 0.1 and 4.0 are Ron's lucky numbers...
 ^-^
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Arc
« Reply #11 on: December 03, 2017, 07:02:22 AM »
I fully understand the definition of polyline bulges. :-)

However, since the polyline has two vertices, the second bulge value is redundant.

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Arc
« Reply #12 on: December 03, 2017, 07:49:34 AM »
You are right, but you'll never know when will user like to turn Close option to Yes... And I suppose in that case that first bulge should be positive and second one negative, IMHO...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Arc
« Reply #13 on: December 03, 2017, 08:08:03 AM »
Hi,

The bulge of the last vertex is used by AutoCAD to close the polyline.
Not specified stands for 0.0.
The complement bulge is the inverse number (1 / bulge)

You ca try:

Code - Auto/Visual Lisp: [Select]
  1.   (list
  2.     '(0 . "LWPOLYLINE")
  3.     '(100 . "AcDbEntity")
  4.     '(100 . "AcDbPolyline")
  5.     '(90 . 2)
  6.     '(70 . 1)
  7.     '(10 0. 0.)
  8.     '(42 . 0.1)
  9.     '(10 0. 5.)
  10.   )
  11. )

Code - Auto/Visual Lisp: [Select]
  1.   (list
  2.     '(0 . "LWPOLYLINE")
  3.     '(100 . "AcDbEntity")
  4.     '(100 . "AcDbPolyline")
  5.     '(90 . 2)
  6.     '(70 . 1)
  7.     '(10 0. 0.)
  8.     '(42 . 0.1)
  9.     '(10 0. 5.)
  10.     '(42 . 10.)
  11.   )
  12. )
Speaking English as a French Frog

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Arc
« Reply #14 on: December 03, 2017, 08:20:51 AM »
@gile, yes, this clears many things... I've learned something new, thanks...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube