TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: AARYAN on June 14, 2022, 04:38:15 AM
-
Hi All,
I am writing a routine and stuck at a point where I need to get the bounding box of a block created with multileader.
1. Setup the mleaderstyle.
2. Inserted Mleader using lisp.
3. (entnext (entlast)) returns nil. Anyway to get the limits?
Thank you in advance for your help!
-
Post your code if you want help with it.
-
I had a similar desire in a recent routine I've been working on. I found Lee Mac's Bounding box function http://www.lee-mac.com/boundingbox.html (http://www.lee-mac.com/boundingbox.html)
Using that function in a call like so:
(LM:boundingbox (vlax-ename->vla-object (cdar (entget (entlast)))))
will get you the 4 points that make up the bounds of the most recently added object.
edit:
(vlax-ename->vla-object (cdar (entget (entlast))))
is probably the heart of what you want I'm guessing. As I had a similar experience using (entget (entlast)) not returning what I wanted because I wasn't aware what was going on in the background with regards to the Acad DB. Worth noting I still don't and I'm not sure how mleaders are handled lol
-
Thanks for the reply guys!
I am simply using the command option to insert the multileader.
(command "_.MLeader" pt1 pt2)
(while (> (getvar "cmdactive") 1) (command ""))
(setq emleader (entlast))
(setq eblock (entnext emleader)) ; return nil.
I know the last line is not correct, I am looking to just get extent of the block that is drawn with multileader. The MleaderStyle content type is block. I believe I can use that block name to insert in the drawing and get the extent but the user can make changes to the block scale in the multileaderstyle and therefore, I assume its best to select the block that is drawn with multileader (which will have all settings applied e.g. scale) and get its extent. I will be adding the same block multiple times vertically or horizontally.
P.S. (vlax-ename->vla-object (cdar (entget (entlast)))) gives me the mleader and not the block.
Thank you!
-
Hmm, yeah, I'm not too sure lol.
Could Entsel be of any use to you? It would prompt you to select the block outright.
-
that is all you need.
is nil because the last entity is emleader their isn't anything after it.
-
P.S. (vlax-ename->vla-object (cdar (entget (entlast)))) gives me the mleader and not the block.
This makes a copy of the mleader and explodes it. then steps thought each entity and if its a block pulls the scale factors for x y and z.
-
vla-explode does not work with multileader objects. I tried already, any other method?
(setq sblock (vla-insertblock vspace (vlax-3d-point (cdr (assoc 15 (entget emleader)))) block scale scale scale rotation))
(setq icount 0)
(foreach satt (vlax-safearray->list (vlax-variant-value (vla-getattributes sblock)))
(if (= icount 0)
(vla-put-textstring satt "test")
(vla-put-textstring satt ""))
(setq icount (1+ icount)))
(vla-getboundingbox sblock 'lminpt 'lmaxpt)
(vla-delete sblock)
This is the best solution I could see so far. Inserting the block, apply the scale from the multileader style and getting the limits and finally delete the block that created.
Thanks for your inputs!
-
vla-explode does not work with multileader objects. I tried already, any other method?
Your right its probably because the leader is a anonymous type block.
prob easier to get the scale and block name with visual lisp.
-
vla-get-arrowheadblock returns ""
I am not changing the arrow head to block. The actual content type is a block. The code I wrote (see above) did the job and I was expecting the bounding box without having to add, get the box and delete the block.
Thanks!
-
vla-get-arrowheadblock returns ""
I am not changing the arrow head to block. The actual content type is a block. The code I wrote (see above) did the job and I was expecting the bounding box without having to add, get the box and delete the block.
Thanks!
that means the mleader doesn't have a block for the arrowhead. Its probably only a solid or a hatch.