trefan123 Posted May 16, 2018 Share Posted May 16, 2018 Good day, What i know is dangerous. I have a basic lisp that draws a couple of lines and arc's. --------------- (command "LINE" IP P4 P5 P6 P16 P15 P14 "C") (command "LINE" P1 P8 "") (command "LINE" P11 P18 "") (Command "arc" P5 P7 P8 "") (Command "arc" P8 P9 P18 "") (Command "arc" P18 P17 P15 "") ---------------------------------- I would like to group these items for ease of manipulation. All help is appreciated. Thanks Peter Quote Link to comment Share on other sites More sharing options...
Grrr Posted May 16, 2018 Share Posted May 16, 2018 Hi, something like: (setq objlist (list (setq entity (entlast)))) (command "LINE" IP P4 P5 P6 P16 P15 P14 "C") (command "LINE" P1 P8 "") (command "LINE" P11 P18 "") (Command "arc" P5 P7 P8 "") (Command "arc" P8 P9 P18 "") (Command "arc" P18 P17 P15 "") (while (setq entity (entnext entity)) (setq objlist (cons (vlax-ename->vla-object entity) objlist)) ) (vlax-invoke (vla-add (vla-get-groups (vla-get-activedocument (vlax-get-acad-object))) "*") 'appenditems objlist ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 16, 2018 Share Posted May 16, 2018 Here's another way, which may be easier to understand for a beginner: (setq ent (entlast)) (while (setq tmp (entnext ent)) (setq ent tmp)) (command "_.line" "_non" IP "_non" P4 "_non" P5 "_non" P6 "_non" P16 "_non" P15 "_non" P14 "_c" "_.line" "_non" P1 "_non" P8 "" "_.line" "_non" P11 "_non" P18 "" "_.arc" "_non" P5 "_non" P7 "_non" P8 "_.arc" "_non" P8 "_non" P9 "_non" P18 "_.arc" "_non" P18 "_non" P17 "_non" P15 "_.-group" "_c" "*" "" ) (while (setq ent (entnext ent)) (command ent)) (command "") @Grrr beware of circumstances in which the last entity in the database is complex (e.g. Heavy/3D polyline / attributed block) Quote Link to comment Share on other sites More sharing options...
Grrr Posted May 16, 2018 Share Posted May 16, 2018 @Grrr beware of circumstances in which the last entity in the database is complex (e.g. Heavy/3D polyline / attributed block) Thanks Lee, I just understood what you did in the first two rows of your suggestion, and then I read your remark. Now I think that a subfunction that determines if an entity is parent (returns boolean), would pair nicely with entnext. Quote Link to comment Share on other sites More sharing options...
trefan123 Posted May 17, 2018 Author Share Posted May 17, 2018 Thanks a lot. I seem to grasp what lee added, i did try the entlast previously ..just errors... One question why put the non in front of the points? Quote Link to comment Share on other sites More sharing options...
trefan123 Posted May 17, 2018 Author Share Posted May 17, 2018 Here is the complete lisp, must have had the old one loaded as it worked but the addition fails (defun C:boltside (/ IP P1 P2 P3 SIZE) ;================make and choose color========================= (command "LAYER" "M" "Steel" "c" "green" "" "") (command "color" "white" "") (setvar 'osmode 53) ;=================insertion point======================== (setvar "CMDECHO" 0) (setvar "BLIPMODE" 0) (setq IP (getpoint "\nInsertion Point: ")) (setvar "OSMODE" 0) (setq SIZE (getreal "\nEnter the Nominal Bolt Size--Metric-: ") ) ;====================get all points=================== (setq P1 (polar IP (DTR 180.0) (* 0.4330 SIZE)) P2 (polar IP (DTR 180.0) (* 0.6495 SIZE)) P3 (polar IP (DTR 180.0) (* 0.7655 SIZE)) P4 (polar IP (DTR 180.0) (* 0.8660 SIZE)) P9 (polar IP (DTR 90.0) (* 0.8000 SIZE)) P8 (polar P1 (DTR 90.0) (* 0.7420 SIZE)) P7 (polar P2 (DTR 90.0) (* 0.8000 SIZE)) P6 (polar P3 (DTR 90.0) (* 0.8000 SIZE)) P5 (polar P4 (DTR 90.0) (* 0.7420 SIZE)) P11 (polar IP (DTR 0.0) (* 0.4330 SIZE)) P12 (polar IP (DTR 0.0) (* 0.6495 SIZE)) P13 (polar IP (DTR 0.0) (* 0.7655 SIZE)) P14 (polar IP (DTR 0.0) (* 0.8660 SIZE)) P18 (polar P11 (DTR 90.0) (* 0.7420 SIZE)) P17 (polar P12 (DTR 90.0) (* 0.8000 SIZE)) P16 (polar P13 (DTR 90.0) (* 0.8000 SIZE)) P15 (polar P14 (DTR 90.0) (* 0.7420 SIZE)) ) ;==================draw nut======================= (setq ent (entlast)) (while (setq tmp (entnext ent)) (setq ent tmp)) (command "_.line" "_non" IP "_non" P4 "_non" P5 "_non" P6 "_non" P16 "_non" P15 "_non" P14 "_c" "_.line" "_non" P1 "_non" P8 "" "_.line" "_non" P11 "_non" P18 "" "_.arc" "_non" P5 "_non" P7 "_non" P8 "_.arc" "_non" P8 "_non" P9 "_non" P18 "_.arc" "_non" P18 "_non" P17 "_non" P15 "_.-group" "_c" "*" "" ) (while (setq ent (entnext ent)) (command ent)) (command "") ;================rotate to desired position========================= (prompt "\nRotation Angle: ") (command "ROTATE" "LAST" "" IP pause) ;================end========================= (setvar 'osmode 53) (princ) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 17, 2018 Share Posted May 17, 2018 Just a suggestion (setq a90 (/ pi 2.0)) ; this is 90 degrees pi is 180 degrees use as is (setq a180 pi) (setq a270 (* pi 1.5)) this is 270 degrees P3 (polar IP pi (* 0.7655 SIZE)) P18 (polar P11 a90 (* 0.7420 SIZE)) Quote Link to comment Share on other sites More sharing options...
trefan123 Posted May 17, 2018 Author Share Posted May 17, 2018 this was not copied (defun DTR (a) ;degrees to radians function (* PI (/ a 180.0)) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2018 Share Posted May 17, 2018 One question why put the non in front of the points? This command modifier is short for "none" and instructs AutoCAD to ignore all active Object Snap modes for the next point input. Quote Link to comment Share on other sites More sharing options...
trefan123 Posted May 17, 2018 Author Share Posted May 17, 2018 This command modifier is short for "none" and instructs AutoCAD to ignore all active Object Snap modes for the next point input. learn something every day.. thanks again Quote Link to comment Share on other sites More sharing options...
Grrr Posted May 17, 2018 Share Posted May 17, 2018 learn something every day.. ha! I live with that motto.. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 18, 2018 Share Posted May 18, 2018 trefan what I was getting at is the 90 180 270 are known values so you could predefine them in a startup lisp so no need for the dtr routine. Check out help on "Pi". 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.