danyra Posted January 20, 2020 Share Posted January 20, 2020 I have this, but how can I make a block of the circle in order to put the color blue? (setq R 10) (setq P1 (getpoint "center:" )) (command "circle" P1 R) Quote Link to comment Share on other sites More sharing options...
ronjonp Posted January 20, 2020 Share Posted January 20, 2020 You can apply the color blue directly to the circle? Quote Link to comment Share on other sites More sharing options...
danyra Posted January 22, 2020 Author Share Posted January 22, 2020 On 1/20/2020 at 4:06 PM, ronjonp said: You can apply the color blue directly to the circle? No, I dont know how to do Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted January 22, 2020 Share Posted January 22, 2020 (entmake (list '(0 . "CIRCLE") '(62 . 5) (cons 10 (getpoint "\nSpecify center of circle: ")) (cons 40 (getint "\nSpecify radius of circle: ")) ) ) Use entmake to create an entity. You can replace '(62 . 5) into "(cons 62 acBlue)" because the color index for blue is 5 as returned by acBlue. If you want to understand how AutoLISP interprets entities, you can always do the below on the entity you'd like to make (like I always do) if I don't know what to include while making new entities. (entget (car (entsel))) 1 Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted January 22, 2020 Share Posted January 22, 2020 (edited) Or, if the object is already in the drawing, you can do: (vla-put-color (vlax-ename-vla-object <entity_here>) acBlue) If you don't prefer using ActiveX, then: (entmod (if (assoc 62 (setq ent (entget <entity_here>))) (subst '(62 . 5) (assoc 62 ent) ent) (append ent (list '(62 . 5))) ) ) Whichever works easier for you. Edited January 22, 2020 by Jonathan Handojo 1 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted January 22, 2020 Share Posted January 22, 2020 Similar to @Jonathan Handojo examples but uses (getdist + picked point) to set radius as well as validates input: (defun c:foo (/ d p) (if (and (setq p (getpoint "\nSpecify center of circle: ")) (setq d (getdist p "\nSpecify radius of circle: ")) ) (entmake (list '(0 . "CIRCLE") '(62 . 5) (cons 10 p) (cons 40 d))) ) (princ) ) Or if you want to assign different colors: (defun c:foo (/ c d p) (if (and (setq c (acad_truecolordlg 5)) (setq p (getpoint "\nSpecify center of circle: ")) (setq d (getdist p "\nSpecify radius of circle: ")) ) (entmake (append (list '(0 . "CIRCLE") (cons 10 p) (cons 40 d)) c)) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 22, 2020 Share Posted January 22, 2020 Here are three examples demonstrating how to construct a blue circle under any UCS/View settings, using either command calls, Vanilla AutoLISP using entmake, or Visual LISP using ActiveX methods: Command Calls: (defun c:com-cir ( / cec cen rad ) (if (and (setq cen (getpoint "\nSpecify circle center: ")) (setq rad (getdist cen "\nSpecify circle radius: ")) ) (progn (setq cec (getvar 'cecolor)) (setvar 'cecolor "5") (command "_.circle" "_non" cen rad) (setvar 'cecolor cec) ) ) (princ) ) Vanilla AutoLISP using entmake: (defun c:al-cir ( / cen rad ) (if (and (setq cen (getpoint "\nSpecify circle center: ")) (setq rad (getdist cen "\nSpecify circle radius: ")) ) (entmake (list '(000 . "CIRCLE") '(062 . 5) (cons 010 (trans cen 1 (trans '(0 0 1) 1 0 t))) (cons 040 rad) (cons 210 (trans '(0 0 1) 1 0 t)) ) ) ) (princ) ) Visual LISP using ActiveX: (defun c:vl-cir ( / cen obj rad ) (if (and (setq cen (getpoint "\nSpecify circle center: ")) (setq rad (getdist cen "\nSpecify circle radius: ")) ) (progn (setq obj (vla-addcircle (vlax-get-property (vla-get-activedocument (vlax-get-acad-object) ) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace ) ) (vlax-3D-point (trans cen 1 0)) rad ) ) (vla-put-color obj acblue) ) ) (princ) ) (vl-load-com) (princ) 1 Quote Link to comment Share on other sites More sharing options...
danyra Posted January 24, 2020 Author Share Posted January 24, 2020 On 1/22/2020 at 3:01 AM, Jonathan Handojo said: (entmake (list '(0 . "CIRCLE") '(62 . 5) (cons 10 (getpoint "\nSpecify center of circle: ")) (cons 40 (getint "\nSpecify radius of circle: ")) ) ) IF I WANT HATCH THE CIRCLE, TO A SOLID COLOR, HOW CAN I DO? THANK YOU Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted January 24, 2020 Share Posted January 24, 2020 (edited) 2 hours ago, danyra said: IF I WANT HATCH THE CIRCLE, TO A SOLID COLOR, HOW CAN I DO? THANK YOU If you want the easy way, do it through command like you did with the circle. But you need to use entmakex in order for AutoLISP to return the new object's entity name, so that when using the command function, you can input its entity name. If you want the hard way, it involves using vla-AddHatch to create a hatch object, followed by (vlax-make-safearray vlax-vbObject '(0 . <number_of_objects> - 1)) and then putting an object element into that safearray. After which you use vla-Append to append the hatch object to that safearray list of objects resulting in the visible hatch. Edited January 24, 2020 by Jonathan Handojo Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 24, 2020 Share Posted January 24, 2020 Like this ? (setq oldhat (getvar 'hpname)) (setvar 'hpname "Solid") (setq oldcol (getvar 'cecolor)) (setvar 'cecolor "1") (command "-hatch" "s" (entlast) "" "") (setvar 'hpname oldhat) (setvar 'cecolor oldcol) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 24, 2020 Share Posted January 24, 2020 6 hours ago, danyra said: IF I WANT HATCH THE CIRCLE, TO A SOLID COLOR, HOW CAN I DO? THANK YOU Here is an existing example for an ellipse, the same technique would be applicable to a circle (or indeed any closed object). Quote Link to comment Share on other sites More sharing options...
ronjonp Posted January 24, 2020 Share Posted January 24, 2020 (edited) On 1/23/2020 at 8:09 PM, danyra said: IF I WANT HATCH THE CIRCLE, TO A SOLID COLOR, HOW CAN I DO? THANK YOU Post a sample drawing of what you're trying to accomplish ... perhaps this will help you? (defun c:foo (/ b c d p) ;; RJP » 2020-01-24 (defun _foo (c / r) (entmake (list '(0 . "BLOCK") '(100 . "AcDbEntity") '(67 . 0) '(8 . "0") '(100 . "AcDbBlockReference") (cons 2 (setq r (strcat "foo-" (vl-princ-to-string c)))) '(10 0. 0. 0.) '(70 . 0) ) ) (entmake (append '((0 . "HATCH") (100 . "AcDbEntity") (8 . "hatch") (100 . "AcDbHatch") (10 0. 0. 0.) (210 0. 0. 1.) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 1) (72 . 2) (10 0. 0. 0.) (40 . 0.5) (50 . 0.) (51 . 6.283185307179588) (73 . 1) (97 . 0) (75 . 1) (76 . 1) (98 . 1) (10 0. 0. 0.) (450 . 0) (451 . 0) (460 . 0.) (461 . 0.) (452 . 0) (462 . 0.) (453 . 2) (463 . 0.) (63 . 5) (421 . 255) (463 . 1.) (63 . 2) (421 . 16776960) (470 . "LINEAR") ) c ) ) (entmake (append '((0 . "CIRCLE") (100 . "AcDbEntity") (67 . 0) (8 . "0") (62 . 5) (100 . "AcDbCircle") (10 0. 0. 0.) (40 . 0.5) ) c ) ) (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0"))) (princ) r ) (if (setq c (acad_truecolordlg 1)) (while (and (setq p (getpoint "\nPick center point: ")) (or d (setq d (getdist p "\nPick radius: "))) (setq b (_foo c)) ) (entmakex (list '(0 . "INSERT") '(100 . "AcDbEntity") '(67 . 0) (cons 8 b) '(100 . "AcDbBlockReference") (cons 2 b) (cons 10 p) (cons 41 (* 2 d)) (cons 42 (* 2 d)) (cons 43 (* 2 d)) '(50 . 0.0) ) ) ) ) (princ) ) Will create circle blocks with different colored hatches. Edited January 28, 2020 by ronjonp 1 Quote Link to comment Share on other sites More sharing options...
danyra Posted January 24, 2020 Author Share Posted January 24, 2020 16 hours ago, BIGAL said: (setq oldhat (getvar 'hpname)) (setvar 'hpname "Solid") (setq oldcol (getvar 'cecolor)) (setvar 'cecolor "1") (command "-hatch" "s" (entlast) "" "") (setvar 'hpname oldhat) (setvar 'cecolor oldcol) Its show me a CYAN COLOR, if I want to change to color number 171? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 24, 2020 Share Posted January 24, 2020 (setvar 'cecolor "1") If you got to "Express" Click tools then System variable editor, it gives details about Autocad system variables its a big list so experience comes in. See image, note its a string not a number "171" ps 1 is red 1 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.