Jump to content

Boundary Creation Lisp- a request


onzki

Recommended Posts

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! :)

Link to comment
Share on other sites

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 :)
Link to comment
Share on other sites

@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! :)

 

sampleboundarycreations.jpg

 

Uploaded with ImageShack.us

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Hi

This 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 :D .. but if it is possible, I'm sure it'll be beneficial to everyone.

Link to comment
Share on other sites

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
)

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 3 years later...

Hi,

Excellent code, guys!!!

I'd like to delete the hatch in the code.

 

Anybody Can help me please?

 

Thank in advance

Edited by Madruga_SP
Link to comment
Share on other sites

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