Jump to content

help to create a circle based on the length of the line you made


ktbjx

Recommended Posts

Senario is this, i make a line, and it will automatically generate a circle with the length of the line as diameter, im sure you guys can make this very easy... but im really new to this lisp thingy, so im asking for help pretty please??:)

circle line.dwg

Link to comment
Share on other sites

Here you go.

(defun c:Test (/ a b)
 ;; Tharwat.	;;
 (and (setq a (getpoint "\nSpecify 1st point :"))
      (setq b (getpoint "\nSpecify 2nd point :" a))
      (entmake (list '(0 . "LINE") (cons 10 a) (cons 11 b)))
      (entmake
        (list '(0 . "CIRCLE")
              (cons 10 (mapcar '(lambda (q p) (/ (+ q p) 2.)) a b))
              (cons 40 (/ (distance a b) 2.))
        )
      )
 )
 (princ)
)

Link to comment
Share on other sites

Here you go.

(defun c:Test (/ a b)
 ;; Tharwat.	;;
 (and (setq a (getpoint "\nSpecify 1st point :"))
      (setq b (getpoint "\nSpecify 2nd point :" a))
      (entmake (list '(0 . "LINE") (cons 10 a) (cons 11 b)))
      (entmake
        (list '(0 . "CIRCLE")
              (cons 10 (mapcar '(lambda (q p) (/ (+ q p) 2.)) a b))
              (cons 40 (/ (distance a b) 2.))
        )
      )
 )
 (princ)
)

DARN you GOOD!!!!! exactly what i need!!!! thank you so much!

Link to comment
Share on other sites

sir just s quick thought,

is it possible to draw the circle first so i can hatch it and then the line, i wanted to add

(C:hhatch)

its the code i got thanks to this forum

Link to comment
Share on other sites

(defun c:HHatch (/ hcol pt1 clr)
 (initget 1 "Gray Blue greeN Yellow Red Magenta")
 (if (and (setq hcol (getkword "\nEnter COLOR [Gray/Blue/greeN/Yellow/Red/Magenta]: "))
          (setq clr (nth (vl-position hcol '("Gray" "Blue" "greeN" "Yellow" "Red" "Magenta")) '(252 5 3 2 1 200))) 
          (setq pt1 (getpoint "\nSelect INTERNAL point: "))
          )
       
 (command "_-hatch" "Properties" "_Solid" "_COLOR" clr "" pt1 "")
   )
 (princ)
 )

Link to comment
Share on other sites

(defun c:Test (/ a b h p c)
   ;; Tharwat.	;;
 (initget 1 "Gray Blue greeN Yellow Red Magenta")
 (if (and (setq h (getkword "\nEnter COLOR [Gray/Blue/greeN/Yellow/Red/Magenta]: "))
          (setq c (nth (vl-position h '("Gray" "Blue" "greeN" "Yellow" "Red" "Magenta")) '(252 5 3 2 1 200)))
          )
   (while (and
            (setq a (getpoint "\nSpecify 1st point :"))
            (setq b (getpoint "\nSpecify 2nd point :" a))             
            (entmake (list '(0 . "CIRCLE") (cons 10 (setq p (mapcar '(lambda (q p) (/ (+ q p) 2.)) a b)))
                           (cons 40 (/ (distance a b) 2.))
                           )
                     )
            )
     (command "_-hatch" "Properties" "_Solid" "_COLOR" c "" p "")
     (entmake (list '(0 . "LINE") (cons 10 a) (cons 11 b)))
     )
   )
 (princ)
 )
 

Link to comment
Share on other sites

(defun c:Test (/ a b h p c)
   ;; Tharwat.	;;
 (initget 1 "Gray Blue greeN Yellow Red Magenta")
 (if (and (setq h (getkword "\nEnter COLOR [Gray/Blue/greeN/Yellow/Red/Magenta]: "))
          (setq c (nth (vl-position h '("Gray" "Blue" "greeN" "Yellow" "Red" "Magenta")) '(252 5 3 2 1 200)))
          )
   (while (and
            (setq a (getpoint "\nSpecify 1st point :"))
            (setq b (getpoint "\nSpecify 2nd point :" a))             
            (entmake (list '(0 . "CIRCLE") (cons 10 (setq p (mapcar '(lambda (q p) (/ (+ q p) 2.)) a b)))
                           (cons 40 (/ (distance a b) 2.))
                           )
                     )
            )
     (command "_-hatch" "Properties" "_Solid" "_COLOR" c "" p "")
     (entmake (list '(0 . "LINE") (cons 10 a) (cons 11 b)))
     )
   )
 (princ)
 )
 

 

this is what i needed! darn you good! hands down!

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