Author Topic: How to grdraw / grvecs a circle?  (Read 327 times)

0 Members and 1 Guest are viewing this topic.

Peter2

  • Swamp Rat
  • Posts: 584
How to grdraw / grvecs a circle?
« on: February 10, 2020, 08:25:57 AM »
I have to "grdraw / grvecs" a (kind of ) circle, and at the moment I use grdraw to create a octogon. That's 99% good enough (also I could you a x^n gon ..), but nevertheless I would like to know: is there a simple way to grdraw a circle? I don't think so ....
Peter

AutoCAD Map 3D 2018 German (so some technical terms will be badly retranslated to English)
BricsCAD V19

roy_043

  • Water Moccasin
  • Posts: 1758
  • BricsCAD 18
Re: How to grdraw / grvecs a circle?
« Reply #1 on: February 10, 2020, 12:54:15 PM »
BricsCAD has the grarc function.

Stefan

  • Bull Frog
  • Posts: 224
Re: How to grdraw / grvecs a circle?
« Reply #2 on: February 11, 2020, 05:27:33 AM »
You can use entmod

Code - Auto/Visual Lisp: [Select]
  1. (setq c (entmakex '((0 . "CIRCLE") (10 0.0 0.0 0.0) (40 . 1.0))))
  2.  
  3.   (= (car (setq gr (grread T))) 5)
  4.   (entmod
  5.     (list
  6.       (cons -1 c)
  7.       (cons 10 (cadr gr))
  8.     )
  9.   )
  10. )

Peter2

  • Swamp Rat
  • Posts: 584
Re: How to grdraw / grvecs a circle?
« Reply #3 on: February 12, 2020, 03:08:28 AM »
Thanks Stefan
an interessting thing, but not what I need. But it shows the direction to use "entmake circle / delete circle" instead of grdraw.   
Peter

AutoCAD Map 3D 2018 German (so some technical terms will be badly retranslated to English)
BricsCAD V19

Augusto

  • Newt
  • Posts: 40
Re: How to grdraw / grvecs a circle?
« Reply #4 on: February 12, 2020, 05:21:16 AM »
For study purposes, I used some functions to make an arc using grvecs.
maybe that can help you to have other ideas.  :idea:

https://www.theswamp.org/index.php?topic=54879.msg592707#msg592707

Stefan

  • Bull Frog
  • Posts: 224
Re: How to grdraw / grvecs a circle?
« Reply #5 on: February 12, 2020, 09:43:22 AM »
Thanks Stefan
an interessting thing, but not what I need. But it shows the direction to use "entmake circle / delete circle" instead of grdraw.   
Please don't do that. If you can entmake/entdel then you can entmod for sure. It's just not a good idea to re-create the circle thousands times, autocad has it's limits and eventually will crash.

Peter2

  • Swamp Rat
  • Posts: 584
Re: How to grdraw / grvecs a circle?
« Reply #6 on: February 13, 2020, 02:59:32 AM »
@Augusto
thanks, I found this posting before. I suppose it is a great stuff, but to much for my simple request.

@Stefan
thanks too, but I don't need a "dynamic usage"of the circle. My program steps and zooms through the vertex of a polyline, but it stops every time. And when stopped, I use "grdraw / grvecs" to display some temporary elements
Peter

AutoCAD Map 3D 2018 German (so some technical terms will be badly retranslated to English)
BricsCAD V19

Rustabout

  • Mosquito
  • Posts: 17
Re: How to grdraw / grvecs a circle?
« Reply #7 on: February 13, 2020, 01:36:23 PM »
I just recently did this but with dialog box vectors. The codes methology would be applicable to grvecs (you'd need to make some sort of a list). Just a heads up: What this would do is draw a ton of lines that would "look" like a circle. An un-trained eye wouldn't know the difference. My application is a bit easier actually because I just have to repeat the "image_vector" function. I think in this case I need to build a list and plug it into grvecs.

I'll have a look at my code and see if I can make it work with grvecs. I have about half an hour (and not a great programmer). I can post the code as-is if you're curious. But I'm sure someone will come up with a real solution.

Rustabout

  • Mosquito
  • Posts: 17
Re: How to grdraw / grvecs a circle?
« Reply #8 on: February 13, 2020, 01:59:11 PM »
I've gotten it to work with GRDRAW. Not with GRVECS. I'm out of time (for now).

(defun C:GRDRAWTEST (/)

(defun real2int ( value / ) (atoi (rtos value 2 0)))


(setq pt1 (getpoint "Select Circle's Center: "))

(setq rad1 (getdist pt1 "Specify Circle's Radius: "))

  (setq cReps 50)  ;****************THIS LINE CONTROLS THE NUMBER OF REPETITIONS.
                   ;****************SOME NUMBERS WILL PRODUCE ERRATIC RESULTS... I THINK I NEED TO USE FACTORS OF 25



;________________ CREATE X LIST BELOW ___________________________________________________________________________________

(defun makeX_List ()

  (setq angle1 0.0)
  (setq xList (list "placeholder"))
  (setq xCounter 0)
   
  (repeat cReps
    (setq xList (append xList (list (+ (* rad1 (cos angle1)) (car pt1)))))
    (if (= (nth 0 xList) "placeholder") (setq xList (cdr xList)));skip after first pass
    (setq angle1 (+ angle1 (/ pi (/ (- cReps 1) 2)))) (setq xCounter (1+ xCounter))
    (if (>= xCounter 1)
      (progn (if (< (abs (nth (- xCounter 1) xList)) 0.001) (setq xList (subst 0 (nth (- xCounter 1) xList) xList)))))   
   );end repeat

   (setq xList (mapcar 'real2int xList))

  );end defun makeX_List

  (makeX_List)


;________________ CREATE X LIST BELOW ___________________________________________________________________________________
 
(defun makeY_List ()
 
  (setq angle1 0.0)
  (setq yList (list "placeholder"))
  (setq yCounter 0)
   
  (repeat cReps
    (setq yList (append yList (list (+ (* rad1 (sin angle1)) (car (cdr pt1))))))
    (if (= (nth 0 yList) "placeholder") (setq yList (cdr yList)));skip after first pass
    (setq angle1 (+ angle1 (/ pi (/ (- cReps 1) 2)))) (setq yCounter (1+ yCounter))
    (if (>= yCounter 1)
      (progn (if (< (abs (nth (- yCounter 1) yList)) 0.001) (setq yList (subst 0 (nth (- yCounter 1) yList) yList)))))   
   );end repeat

   (setq yList (mapcar 'real2int yList))

   );end defun makeY_List

  (makeY_List)


  ;____________________________________________________________________________

     (setq vectorCircleCounter 0)

     (repeat (- (length xList) 1)

       (grdraw (list (nth vectorCircleCounter xList) (nth vectorCircleCounter yList)) (list (nth (1+ vectorCircleCounter) xList) (nth (1+ vectorCircleCounter) yList)) 2 )

       (setq vectorCircleCounter (1+ vectorCircleCounter))

      ); end repeat

  ); END DEFUN GRDRAWTEST