Jump to content

Mleader to get Block Name or Description from within Xref


Recommended Posts

Posted

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!

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

Posted (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 by Jonathan Handojo
Posted

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.

Posted (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 by Jonathan Handojo
Posted

Please look at the nentsel function.

Posted

Could I ask in what way? For the nentsel function?

Posted

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.

  • Like 1
Posted

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

 

 

Posted
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

Posted

Thanks did not look to deep. Never had to worry about this.

Posted

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?

Posted

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

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