Andi Posted July 1, 2022 Share Posted July 1, 2022 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 Quote Link to comment Share on other sites More sharing options...
Steven P Posted July 1, 2022 Share Posted July 1, 2022 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.... 2 Quote Link to comment Share on other sites More sharing options...
Andi Posted July 1, 2022 Author Share Posted July 1, 2022 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 1 Quote Link to comment Share on other sites More sharing options...
Steven P Posted July 1, 2022 Share Posted July 1, 2022 Nice. Quote Link to comment Share on other sites More sharing options...
mhupp Posted July 1, 2022 Share Posted July 1, 2022 (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 July 2, 2022 by mhupp 1 Quote Link to comment Share on other sites More sharing options...
Emmanuel Delay Posted July 4, 2022 Share Posted July 4, 2022 (edited) Here's a list of most things to draw (line, polyline, circle, ... ) Edited July 4, 2022 by Emmanuel Delay 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.