Jump to content

Recommended Posts

Posted

Hello everyone! Can anyone helps me with code to draw a circle at specified dimensions. I have added the details in attached file.

Test.dwg

Posted

one way is to entmake it, using this basic code:

 

(entmake '(
  (0 . "CIRCLE") ;make circle
  (62 . 3) ; colour
  (10 4.0 4.0 0.0) ; centre
  (40 . 1.0) ; radius
))

 

https://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-D47983BA-1E5D-417D-85B8-6F3DE5F506BA

 

Pop that into your LISP and modify to suit what you want

 

If you want to create this using variables, change the (entmake '( to (entmake (list

 

(setq pt (list 0 0 0)) ;;insertion point
(setq rad 1)
(setq colour 3) ;colour code 
(setq layer "0") ; layer, as a string


(entmake (list
  (cons 0 "CIRCLE") ;make circle
  (cons 62 colour) ; colour
  (cons 8 layer) ; colour
  (cons 10 pt) ; centre
  (cons 40 rad) ; radius
))

 

and using the entmake codes you can use these for more conrol:

410        Drawn in tab
8            Layer
62         Colour
6           Linetype
48        Linetype Scale
370     Lineweight

 

 

 

So up to you, if you need more help just say....

  • Like 2
Posted

Hi Steven. Thanks for your help. Your code is working perfectly. However I also came up with below code.

(defun c:CSP ( / e1 eg1 p10 p11 mp e2 eg2 p20 p21 pt)
  ;; Circle @ Specific Point
  (if (and (setq e1 (car (entsel "\nSelect Line for Midpoint: ")))
           (setq eg1 (entget e1))
           (setq p10 (cdr (assoc 10 eg1)) p11 (cdr (assoc 11 eg1)))
           (setq mp (mapcar '* (mapcar '+ p10 p11) '(0.5 0.5 05)))
           (setq e2 (car (entsel "\nSelect line where Circle will reside: ")))
           (setq eg2 (entget e2))
           (setq p20 (cdr (assoc 10 eg2)) p21 (cdr (assoc 11 eg2)))
           (setq pt (inters mp (mapcar '- mp '(0 1 0)) p20 p21 nil))
      );and
    (command "_.CIRCLE" "_non" pt pause)
  );if
  (princ)
);defun

 

  • Like 1
Posted (edited)

Another way. Scratch that this doesn't account for the mid point of the first line. and after looking a the example both lines being selected it looks like they are parallel to each other.

 

(defun c:CSP (/ a b)
  (if (and (setq a (vlax-ename->vla-object (car (entsel "\nSelect the first line: "))))
           (setq b (vlax-ename->vla-object (car (entsel "\nSelect the second line: "))))
      );; and
    (command "_.CIRCLE" "_non" (mapcar '- (vlax-invoke a 'IntersectWith b acExtendNone) '(0 1 0)) pause)  
  );; if
  (princ)
)

 

 

 

Edited by mhupp
  • Like 1
Posted (edited)

Here's a list of most things to draw (line, polyline, circle, ... )

 

 

Edited by Emmanuel Delay
  • Like 2

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