onzki Posted July 6, 2010 Posted July 6, 2010 Hi, I am doing a work that prompts me to use boundary creation often so I would like to request for Boundary creation LISP. The normal process (AutoCad 2007) when I typed in a command for boundary or "bo"- 1. Type boundary or BO at command line 2. the dialogue box comes out, 3. Pick a point button, 4. pick a point at the drawing, 5. Hit enter to end. Now is there a way to shortcut this, like I will need to do steps #1 and #4 only and skip others? Thanks a lot! Quote
alanjt Posted July 6, 2010 Posted July 6, 2010 Use -Boundary (commandline version) and turn it in to a macro or LISP macro. Quote
onzki Posted July 6, 2010 Author Posted July 6, 2010 Use -Boundary. Thanks, I didn't know that before (-boundary). I'm not yet familiar with macros so I just assigned my -boundary command alias to "bo". Thanks again Quote
Tharwat Posted July 6, 2010 Posted July 6, 2010 You can use this; (command "_.-boundary" pause "") Regards Tharwat Quote
onzki Posted July 6, 2010 Author Posted July 6, 2010 @Tharwat313: Thanks for the code, I liked that one-its "quick and quiet" By the way- If I may inquire further- right now, what we have is one by one selection. However, is it possible to redefine this command by clicking continuously or having multiple points selection? What I mean is, after the command- I can click one or more points and when I'm done, I can simple hit enter to end. I attached an image for reference. The numbering inside is just an assumed point selection sequence for boundary creation. Thanks! Uploaded with ImageShack.us Quote
lpseifert Posted July 6, 2010 Posted July 6, 2010 Try typing Multiple prior to the -Boundary command Quote
Tharwat Posted July 6, 2010 Posted July 6, 2010 Hi I guess this would be the best for your needs .... check this out. Enjoy..... (defun c:gift (/ num) (setq num (getint"\nEnter number of boundary Frames:")) (repeat num (command "_.-boundary" pause "") ) (princ) ) Best regards. Tharwat Quote
alanjt Posted July 6, 2010 Posted July 6, 2010 A while statement would be what you want... (defun c:BND (/ pt) (while (setq pt (getpoint "\nPick internal point: ")) (command "_.-boundary" "_a" "_i" "_n" "" "" "_non" pt "") ) (princ) ) 1 Quote
onzki Posted July 8, 2010 Author Posted July 8, 2010 wow, thanks so much for the reply, I will check them out. Quote
onzki Posted July 8, 2010 Author Posted July 8, 2010 That was amazing, thanks again! Now, I am very interested to study lisp Quote
pryzmm Posted July 8, 2010 Posted July 8, 2010 hi,,, wow,,, exactly what i needed,, but guys can this be stretch further by remembering the created boundary in a selection set and then at the end of the "boundary" session command it will invoke the "hatch" command and since you already have the selection set earlier it will use that selection for the hatch boundary,,,thanks in advance Quote
wkplan Posted July 8, 2010 Posted July 8, 2010 Hi, no need for a selection set, entlast will do it: (defun c:BND (/ pt) (while (setq pt (getpoint "\nPick internal point: ")) (command "_.-boundary" "_a" "_i" "_n" "" "" "_non" pt "") [color=Blue](command "_hatch" "solid" (entlast) "")[/color] ) (princ) ) BTW: the "bhatch-command" has an option which allow you to create a hatch and keep the boundary polyline. regards Wolfgang Quote
Tharwat Posted July 8, 2010 Posted July 8, 2010 Hi This is how it should be . (defun c:BND (/ pt) (while (setq pt (getpoint "\nPick internal point: ")) (command "_.-boundary" "_a" "_i" "_n" "" "" "_non" pt "") (command "_.-hatch" "_p" "_solid" pt "") ) (princ) ) Regards Tharwat Quote
onzki Posted July 9, 2010 Author Posted July 9, 2010 HiThis is how it should be . Now this is becoming more interesting, "stretchable" as well as challenging . Aside from hatching, is it also possible to evoke an "Area" computation (metric- M²) command instead of hatch. This time, automatically creating a text value (of readable height) on center of each polygon.. and finally assigning a layer "AREA" to both polygon and area text. Sorry if I requested too much. I'm just overwhelmed. I know you are not magicians haha .. but if it is possible, I'm sure it'll be beneficial to everyone. Quote
alanjt Posted July 9, 2010 Posted July 9, 2010 Up late packing for camping/hiking trip. Thought I'd take a break, saw this and decided to post a quickie... Enjoy and see you guys on Monday. I'm off to the woods at first light. (defun c:HatL (/ foo eLast pt obj) ;; Alan J. Thompson, 07.09.10 (vl-load-com) (defun foo (o / a b) (vla-getboundingbox o 'a 'b) (mapcar '(lambda (a b) (/ (+ a b) 2.)) (vlax-safearray->list a) (vlax-safearray->list b)) ) (setq eLast (entlast)) (if (and (setq pt (getpoint "\nSpecify point within area to hatch and label: ")) (vl-cmdf "_.-bhatch" "_non" pt "SOLID" "_A" "_R" "_Y" "" "") (not (equal eLast (setq obj (entlast)))) (setq obj (vlax-ename->vla-object obj)) ) (vla-put-BackgroundFill (AT:MText (foo obj) (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-objectid obj)) ">%).Area \\f \"%lu6%qf1\">%" ) 0. nil 5 ) :vlax-true ) ) (princ) ) (defun AT:MText (Pt Str Wd Lay Jus / Wd s o) ;; Add MText to drawing ;; Pt - MText insertion point ;; Str - String to place in created MText object ;; Wd - Width of MText object (if nil, will be 0 width) ;; Lay - Layer to place Mtext object on (nil for current) ;; Jus - Justification # for Mtext object ;; 1 or nil= TopLeft ;; 2= TopCenter ;; 3= TopRight ;; 4= MiddleLeft ;; 5= MiddleCenter ;; 6= MiddleRight ;; 7= BottomLeft ;; 8= BottomCenter ;; 9= BottomRight ;; Alan J. Thompson, 05.23.09 / 04.09.10 (or Wd (setq Wd 0.)) (setq s (if (or (eq acmodelspace (vla-get-activespace (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) ) (eq :vlax-true (vla-get-mspace *AcadDoc*)) ) (vla-get-modelspace *AcadDoc*) (vla-get-paperspace *AcadDoc*) ) Pt (cond ((vl-consp Pt) (vlax-3d-point Pt)) ((eq (type Pt) 'variant) Pt) ) ) (vla-put-lock (vlax-ename->vla-object (tblobjname "layer" (getvar 'clayer))) :vlax-false) (setq o (vla-addMText s Pt Wd (vl-princ-to-string Str))) (and Lay (tblsearch "layer" Lay) (vla-put-layer o Lay)) (cond ((vl-position Jus '(1 2 3 4 5 6 7 8 9)) (vla-put-AttachmentPoint o Jus) (vla-put-InsertionPoint o Pt) ) ) o ) Quote
onzki Posted July 16, 2010 Author Posted July 16, 2010 A while statement would be what you want... (defun c:BND (/ pt) (while (setq pt (getpoint "\nPick internal point: ")) (command "_.-boundary" "_a" "_i" "_n" "" "" "_non" pt "") ) (princ) ) @Allanjt: In case I want the original lines to be deleted afterwards so that only the new closed polyline/boundary remains, what would I add to this lisp? Thanks! Quote
alanjt Posted July 16, 2010 Posted July 16, 2010 @Allanjt: In case I want the original lines to be deleted afterwards so that only the new closed polyline/boundary remains, what would I add to this lisp?Thanks! If that's all your wanting to accomplish, just select everything and convert them to a polyline with PEdit. Quote
Madruga_SP Posted July 23, 2013 Posted July 23, 2013 (edited) Hi, Excellent code, guys!!! I'd like to delete the hatch in the code. Anybody Can help me please? Thank in advance Edited July 25, 2013 by Madruga_SP Quote
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.