Jump to content

Recommended Posts

Posted (edited)

Like mhupp as you want trees, you could use a bounding box to get a Dia and replace with a tree symbol block using scale as width of box.

 

image.png.42aeb09fa593c8b0b8f68e2ec7284dfa.png

Edited by BIGAL
Posted (edited)

Hey Bigal, I guess this library is not included in AutoCAD. I need to focus on a workflow near to opensource, and dependent on as few paid software as possible (I'm still a Student). Since Civil 3D is more exoctic in Architecture Offices, I'm keen on AutoCAD. Still, this bounding box method is something I have to look at in the future, if applicable in AutoCAD. For now I'm happy with this bruteforce method ;-). Thanks for the Tip!

 

Regards :)

Edited by JensiLehmanni
Posted (edited)

Bounding box is a VL function, rather than pick 1 at a time would use a selection set of your polygons and convert.

 

(vl-load-com)

(setq obj (vlax-ename->vla-object (car (entsel "pick object "))))

(vla-GetBoundingBox obj 'minpoint 'maxpoint)
(setq pointmin (vlax-safearray->list minpoint))
(setq pointmax (vlax-safearray->list maxpoint))
;minpoint contains the minimum point of the bounding box
;maxpoint contains the maximum point of the bounding box

Post a sample dwg with a few of the polygons.

Edited by BIGAL
  • 3 months later...
Posted

I tried the update of mhupp - Insert Block at Block insertion point, but at the end I have an error.

 

Error: too few actual parameters

Error_Insertion.jpg

Posted
On 5/2/2022 at 8:25 PM, mhupp said:

 

Update the first part

 

;; Insert Block at Block insertion point  -  Lee Mac
(defun c:insblkcen ( / *error* blk box idx ref sel spc )
   (defun *error* ( msg )
       (LM:endundo (LM:acdoc))
       (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
           (princ (strcat "\nError: " msg))
       )
       (princ)
   )
   (LM:startundo (LM:acdoc))
   (if (and (setq blk (LM:selectifobject "\nSelect block to be inserted: " "INSERT"))
            (setq blk (LM:name->effectivename (cdr (assoc 2 (entget blk)))))
            (setq sel (LM:ssget (strcat "\nSelect blocks to insert \"" blk "\" at insertion point: ") '(((0 . "INSERT")))))
            (setq spc (vlax-get-property (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)))
       )
       (repeat (setq idx (sslength sel))
           (if (setq ref (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))))
              (vla-insertblock spc
                (vla-get-insertionpoint ref)
                (vla-get-rotation ref)
              )
           )
       )
   )
   (LM:endundo (LM:acdoc))
   (princ)
)

 

 

Posted

Can someone give an advice how to fix the error with too few actual parameters? 

  • 4 weeks later...
Posted

So, with Lee-Mac's code it works superb for 2D but when I try to select 3D Polyface Meshes as my destination blocks, it seems to not like that and doesn't recognize my ssget. 

  • 1 month later...
Posted
On 9/22/2022 at 1:54 PM, j2lstaples said:

So, with Lee-Mac's code it works superb for 2D but when I try to select 3D Polyface Meshes as my destination blocks, it seems to not like that and doesn't recognize my ssget. 

I actually fixed it. Polyface Meshes doesn't have "INSERT". Lee Mac's codes inspired me to be creative for some of the functions in the workflow at my workplace. I actually used this as a reference for when trying to check if our generated 3D I-beams are populated at a certain height. Polyface Meshes are difficult to do manually because you have to properly click the line at the bottom. I've also allowed for it to work with actual 3D objects. I've generated a function for the PolyFace Meshes to actually calculate the center and minimum using bounding box vertices. 

  • 1 year later...
Posted

@Lee Mac Hi Sir, is there a possibility to modify the lisp in order to put say for example a block named "NUMBER" at the center of a rectangle or while creating a rectangle the block named "NUMBER" will always be at the center regardless of the specified dimension the rectangle.

Thank you.

Posted

You just make the rectang, use the midpoint of the 2 diag corners as insertion point. Adding to your counter each time. Look carefully each rectang has +1.

 

 

 

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