rcb007 Posted April 9, 2020 Posted April 9, 2020 Is it possible for an MLeader to grab the block name or the block description and place it in the text portion of the Mleader? I have seen routines that do this within the dwg, but I am not sure if its possible to select it from an xref. Thanks! Quote
Jonathan Handojo Posted April 10, 2020 Posted April 10, 2020 21 hours ago, rcb007 said: Is it possible for an MLeader to grab the block name or the block description and place it in the text portion of the Mleader? I have seen routines that do this within the dwg, but I am not sure if its possible to select it from an xref. Thanks! Technically an xref attached comes in as a "block", so unless you explode the xref, I'm not sure of another way. If you're doing entsel, I don't know of a way that you can do it on an xref to actually get the entity inside the xref inside. It would be possible if you explode it. Quote
Jonathan Handojo Posted April 10, 2020 Posted April 10, 2020 (edited) However, I do know that you can get a list of blocks from an xref by doing something like (defun c:xblock ( / adoc xblks xname xblks) (setq adoc (vla-get-ActiveDocument (vlax-get-acad-object)) xname "Your_Xref_Name" ; can be adjusted to, entsel, for example ) (vlax-for x (vla-item (vla-get-blocks adoc) xname) (if (eq (vla-get-ObjectName x) "AcDbBlockReference") (setq xblks (cons x xblks)) ) ) (princ) ) Edited April 10, 2020 by Jonathan Handojo Quote
rcb007 Posted April 10, 2020 Author Posted April 10, 2020 Thank you for the response! This is similar to Xlist? I tried to run the routine but it says: Quote Command: XBLOCK ; error: Automation Error. Key not found Command: I wonder if I did something wrong. Quote
Jonathan Handojo Posted April 10, 2020 Posted April 10, 2020 (edited) 17 minutes ago, rcb007 said: Thank you for the response! This is similar to Xlist? I tried to run the routine but it says: I wonder if I did something wrong. Change xname to the name of your xref The below will find the name of the xref by using entsel: (defun c:xblock ( / adoc vxref xblks xref) (setq adoc (vla-get-ActiveDocument (vlax-get-acad-object))) (while (cond ((null (setq xref (entsel "\nSelect xref: "))) (princ "\nNothing selected")) ((null (and (eq (cdr (assoc 0 (entget (car xref)))) "INSERT") (vlax-property-available-p (setq vxref (vlax-ename->vla-object (car xref))) 'Path) ) ) (princ "\nObject is not an xref") ) ) ) (vlax-for x (vla-item (vla-get-blocks adoc) (vla-get-EffectiveName vxref)) (if (eq (vla-get-ObjectName x) "AcDbBlockReference") (setq xblks (cons x xblks)) ) ) (princ) ) Yeah, you can say this will list all the blocks within your xref. Nothing will happen. But this is not part of your request, because you want to do "entsel" to select the block within the xref which I don't know of a way to do that, but this is the least you can do to get the list of blocks inside the xref Edited April 10, 2020 by Jonathan Handojo Quote
rcb007 Posted April 10, 2020 Author Posted April 10, 2020 Could I ask in what way? For the nentsel function? Quote
Lee Mac Posted April 10, 2020 Posted April 10, 2020 The nentsel & nentselp functions facilitate subentity selection, with the last element of the selection list also providing information about the parent entities in which the selected entity resides. 1 Quote
BIGAL Posted April 12, 2020 Posted April 12, 2020 I found this did not work it returned the object within the block not a block name ? nentsel & nentselp maybe doing something wrong. Command: (entget (car (nentselp))) Select object: ((-1 . <Entity name: 18774961b70>) (0 . "LWPOLYLINE") within xref/dwg reflects as a block Command: (entget (car (entsel))) Select object: ((-1 . <Entity name: 1877495daf0>) (0 . "INSERT") Quote
Jonathan Handojo Posted April 12, 2020 Posted April 12, 2020 2 hours ago, BIGAL said: I found this did not work it returned the object within the block not a block name ? nentsel & nentselp maybe doing something wrong. Command: (entget (car (nentselp))) Select object: ((-1 . <Entity name: 18774961b70>) (0 . "LWPOLYLINE") within xref/dwg reflects as a block Command: (entget (car (entsel))) Select object: ((-1 . <Entity name: 1877495daf0>) (0 . "INSERT") It's the last item (last nentselp) that returns the block... The first item is the innermost object, which in your case is a polyline. That polyline resides in a block, which is also residing in an xref... Those are the last two items Quote
BIGAL Posted April 12, 2020 Posted April 12, 2020 Thanks did not look to deep. Never had to worry about this. Quote
rcb007 Posted April 13, 2020 Author Posted April 13, 2020 The reason I was looking at this (if it was possible). To label up sheet files with mleaders. If the Name of the block is correct. I could select the block within a xref and then it would label what the block name would be. It was worth a shot to ask. If this doesn't work, would be there be an alternative method? Quote
Jonathan Handojo Posted April 13, 2020 Posted April 13, 2020 There's a way to do it. Thanks to Lee Mac and Roy, I had an idea, just haven't spend the time for it. I'll get back shortly 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.