Jump to content

xref clip boundry


cadman6735

Recommended Posts

Where in the visual lisp editor under watch window once I create

 

 
(vl-load-com)

(setq acaddoc (vlax-get-acad-object))

and add 'acaddoc' to my watch window then double click on ACADDOC in the watch window and this opens up the vast wealth of vlisp

 

can I find the xref and xref clip boundry?

 

 

and if not there, where can I access the xref clip boundry information?

 

thanks

Link to comment
Share on other sites

  • Replies 59
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    20

  • cadman6735

    17

  • BlackBox

    15

  • alanjt

    8

Top Posters In This Topic

Posted Images

Xrefs are stored in the Document Block Collection, hence here are two ways:

 

(defun GetBlockObject ( name )
 (if (tblsearch "BLOCK" name)
   (vla-item
     (vla-get-Blocks
       (vla-get-ActiveDocument
         (vlax-get-acad-object)
       )
     )
     name
   )
 )
)

(defun GetBlockObject ( name / block )
 (if
   (not
     (vl-catch-all-error-p
       (setq block
         (vl-catch-all-apply 'vla-item
           (list
             (vla-get-Blocks
               (vla-get-ActiveDocument
                 (vlax-get-acad-object)
               )
             )
             name
           )
         )
       )
     )
   )
   block
 )
)

Link to comment
Share on other sites

Just or fun...

 

[color=lemonchiffon](defun GetBlockObject (block)
 (if (setq block (tblobjname "BLOCK" block))
   (vlax-ename->vla-object block)
 )
)[/color]

Edited by alanjt
Link to comment
Share on other sites

I don't think that returns quite the same object Alan :wink:

 

Perhaps this:

 

(defun GetBlockObject ( name / block )
 (if (setq block (tblobjname "BLOCK" name))
   (vlax-ename->vla-object (cdr (assoc 330 (entget block))))
 )
)

 

Or

 

(defun GetBlockObject ( name / block )
 (if (setq block (tblobjname "BLOCK" name))
   (vla-objectIdtoObject
     (vla-get-ActiveDocument
       (vlax-get-acad-object)
     )
     (vla-get-OwnerID
       (vlax-ename->vla-object block)
     )
   )
 )
)

Link to comment
Share on other sites

Here's mine...

 

(defun i:blockItem  (arg)
 (vl-load-com)
 (cond
   ((= 'ENAME (type arg))
    (vla-item
      (vla-get-blocks
        (vla-get-activedocument
          (vlax-get-acad-object)))
      (i:dxf 2 (entget arg))))
   ((= 'STR (type arg))
    (vla-item
      (vla-get-blocks
        (vla-get-activedocument
          (vlax-get-acad-object)))
      arg))))

Edited by BlackBox
Remove sub-function calls, added (vl-load-com)
Link to comment
Share on other sites

(3) options brain overload... :lol:

 

The only problem is, I don't know what to do with it:?

 

Not what I was expecting, (but then again, I didn't know what to expect)

 

 

I like your second code, it has error catching I am very curiouse about catching errors (I get a lot of them)

 

But for now I would just like to understand how to use this code.

 

I am looking for a way to list my xref blocks and pull the information from them, such as clip boundry and file path, attach vs overlay.

 

I guess this is not a simple task, I just found the watch window the other day and was like holly molly, look at what I can access and this opened the door to an idea I have been wanting to work on.

 

 

I assumed the variable "block" (in your code above) would allow me to list out the xref blocks, but I get nil.

 

 

What is vla-item all about, I found an old post of yours but couldn't make heads or tails from it, I am unable to find vla-item in the acad help or developer help.

 

http://www.cadtutor.net/forum/showthread.php?36779-Using-VLA-Item

Link to comment
Share on other sites

Ahh, just noticed the 330 code in the dump. Shows what assumptions do.

 

Revised:

(defun GetBlockObject (block)
 (if (setq block (tblobjname "BLOCK" block))
   (vlax-ename->vla-object (cdr (assoc 330 (entget block))))
 )
)

 

 

EDIT: nevermind, I see you added it to your prior post.

Link to comment
Share on other sites

I am looking for a way to list my xref blocks

 

 

Here is one way:

 

(defun i:xrefList  (/ xrefList)
 (vl-load-com)
 (vlax-for x  (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
   (if (= :vlax-true (vla-get-isxref x))
     (setq xrefList (cons (vla-get-name x) xrefList))))
 (vl-sort xrefList '<))

 

 

I am unable to find vla-item in the acad help or developer help.

 

 

Check out the apropos (Hint: click the "(A)" button within the VLIDE). :wink:

 

Edit: Or you could select vla-item (or any other function), and hit the help "(?)" button.

Edited by BlackBox
Removed sub-function calls, added (vl-load-com)
Link to comment
Share on other sites

You can also step through vla-get-filedependencies, but I don't recommend it since it will ignore XRefs that were inserted after last save - I'm really only stating this for informational purposes.

Link to comment
Share on other sites

Hi Cadman, to answer some of your questions....

 

I like your second code, it has error catching I am very curiouse about catching errors (I get a lot of them)

 

All of my options have the appropriate error catching, (all are catching the same error of the block not existing), the second code uses the VL apply to catch an actual exception, as vla-item will error when the item at the index specified doesn't exist (whereas most Vanilla methods just return nil - hence the other methods).

 

I am looking for a way to list my xref blocks and pull the information from them, such as clip boundry and file path, attach vs overlay.

 

I believe Renderman has already posted a similar code, but just for completeness of this post:

 

(defun GetXRefs ( / l )
 (vlax-for block
    (vla-get-Blocks
      (vla-get-ActiveDocument
        (vlax-get-acad-object)
      )
    )
   (if (eq :vlax-true (vla-get-isXRef block))
     (setq l (cons block l))
   )
 )
 (reverse l)
)

I assumed the variable "block" (in your code above) would allow me to list out the xref blocks, but I get nil.

 

Bear in mind that all the options posted are subfunctions - and hence are designed to be called from a main function, supplying the subfunction with the block name as an argument.

 

The subfunctions are designed with a 'useful' return. This means they can be used without any modification whatsoever - really you don't even need to know what the code looks like. All you need to know is what to supply the function and what it returns.

 

In this case, you supply a block name (string) and the function either returns a VLA Block Object from the Block Collection or nil if the block with the name supplied doesn't exist.

 

Example:

(setq VLABlock (GetBlockObject "myBlock"))

What is vla-item all about, I found an old post of yours but couldn't make heads or tails from it, I am unable to find vla-item in the acad help or developer help.

 

http://www.cadtutor.net/forum/showthread.php?36779-Using-VLA-Item

 

Wow - that is from way back... vla-item is useful in that you can retrieve an item from a collection without iterating through the whole collection to find it - the downside of using such a function is that if you don't know for sure that the object is present in the collection, vla-item may return an error, and crash your whole routine. Hence the use of vl-catch-all-apply, as this will catch such an exception.

 

I would suggest that you look into the VLIDE Help Files, specifically at the ActiveX Object Model - this will give a complete overview of the structure of the various collections and objects in AutoCAD.

 

Lee

Link to comment
Share on other sites

By the way Renderman,

 

I would suggest that you post the subfunctions referenced by your subfunctions, as the omission of these will only confuse a beginner and renders the code as it stands useless.

 

Lee

Link to comment
Share on other sites

By the way Renderman,

 

I would suggest that you post the subfunctions referenced by your subfunctions, as the omission of these will only confuse a beginner and renders the code as it stands useless.

 

Dually noted, and thanks for the correction... I've only begun to amass a code library worthy of sharing, and sometimes forget the lengths to which one must 'fill in the gaps' so to speak.

 

Edit: Fixing my posts now....

 

It's no excuse, but it also didn't help that I have been extremely busy with a submittal, and registering for the State's new *DOT 2011 Kit for Civil 3D/MicroStation Training events. I've been tapped to 'train the trainers' for my Transportation group, and get us cross trained on both platforms (C3D/MS). Should be very interesting.

Link to comment
Share on other sites

Yeah, as you've probably guessed that is the pointer to the owner object :)

 

Yup.

 

I was going to correct you on your GetXRefs, but I just noticed you made the necessary modification.

Link to comment
Share on other sites

I am looking for a way to list my xref blocks and pull the information from them, such as clip boundry and file path, attach vs overlay

 

By the way, just to note, this could all be done in Vanilla AutoLISP :)

 

Some example functions:

 

(defun GetAllXRefs ( / def l )
 (while (setq def (tblnext "BLOCK" (null def)))    
   (if (= 4 (logand 4 (cdr (assoc 70 def))))      
     (setq l (cons (cdr (assoc 2 def)) l))
   )
 )
 (reverse l)
)

(defun isXRef ( blockname )
 (= 4 (boole 1 4 (cond ( (GetBlockFlag blockname) ) ( 0 ))))
)

(defun isOverlay ( blockname )
 (= 8 (boole 1 8 (cond ( (GetBlockFlag blockname) ) ( 0 ))))
)

(defun GetBlockFlag ( blockname )
 (if (setq def (tblobjname "BLOCK" blockname))
   (cdr
     (assoc 70
       (entget def)
     )
   )
 )
)

(defun XrefPath ( blockname )
 (cdr (assoc 1 (tblsearch "BLOCK" blockname)))
)

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