See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Is Xrefs a variable?

  1. #1
    AUGI Addict
    Join Date
    2006-04
    Location
    (getpoint "Anywhere on the Enter Key =>")
    Posts
    1,160
    Login to Give a bone
    0

    Default Is Xrefs a variable?

    Hi ALL,

    A drawing external reference can be shown by using rtext with following diesel expression:

    $(xrefs, ,)

    However, I can not found "xrefs" as a vaiable in autocad help menu.

    I can not apply the above to lsp routine.

    Is there anyone can tell what xrefs is & how does it work in lsp routine.


    I am using AutoCAD 2005 mechanical.

    Ke

  2. #2
    100 Club CADmium's Avatar
    Join Date
    2004-08
    Location
    Eberswalde, Germany, Europe
    Posts
    128
    Login to Give a bone
    0

    Default Re: Is Xrefs a variable?

    try this Code:

    Code:
    (defun XREFLIST(/ LISTE)
      (vlax-for BLOCK (vla-get-blocks(vla-get-activedocument(vlax-get-acad-object)))
        (if(=(vla-get-isxref BLOCK):vlax-true)
          (setq LISTE (cons (strcase(vla-get-name BLOCK))  LISTE))
        )
      )
      (mapcar
        '(lambda(X / Y)
           (if(and(setq Y(ssget "_x" (list '(0 . "INSERT")(cons 2 X))))
                  (setq Y(ssname Y 0))
                  (setq Y(vlax-ename->vla-object Y))
                  (setq Y(vla-get-path Y))
              )
             Y
           )    
         )  
        LISTE
      )  
    )

  3. #3
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Is Xrefs a variable?

    Quote Originally Posted by ke.li View Post
    . . .I can not found "xrefs" as a vaiable. . .
    No there is no variable storing xrefs.
    Is there anyone can tell what xrefs is . . . .
    an Xref is a block/nested drawing that you can separate from ordinary block in current drawing, but if you do not know the name
    you have to iterate trough all blocks in the definition table and look for dxf code 1 or 70
    code 1 tells you a path to the dwg file, and code 70 tells you the status of the xref, in next example 44 is overlay.
    . . .& how does it work in lsp routine. . .
    If you do not know the name
    (tblnext "BLOCK" T ) ; the very first block
    (tblnext "BLOCK" nil ) ; following blocks (70 . 44) (1 . "path") = xref
    (tblnext "BLOCK" nil ) ; (70 . 0) no code 1 = ordinary block

    if you know the name
    (tblsearch "BLOCK" "MyBlock" ) ; (70 . 0) no code 1 = ordinary block
    (tblsearch "BLOCK" "MyXref" ) ; (70 . 44) (1 . "path") = xref

    if you know the name { more dxf code }
    (entget (tblobjname "BLOCK" "MyBlock" ) ) ; (70 . 0) (1 . "") = ordinary block
    (entget (tblobjname "BLOCK" "MyXref" ) ) ; (70 . 44) (1 . "path") = xref
    Code:
    (defun XrList (/ BlockName BlockList XrefList )
      (setq BlockName (cdr (assoc 2 (tblnext "BLOCK" T ))) )
      (while BlockName
        (setq BlockList (append BlockList (list BlockName )) )
        (setq BlockName (cdr (assoc 2 (tblnext "BLOCK" nil ))) )
      )
      (foreach Block_In BlockList
        (setq XrefList (append XrefList (list (cdr (assoc 1 (tblsearch "BLOCK" Block_In ))))))
      )
      (setq XrefList (vl-remove nil XrefList ))
    )
    Usage
    Command: (XrList)

    : ) Happy Computing !

    kennet

  4. #4
    All AUGI, all the time Avatart's Avatar
    Join Date
    2004-06
    Location
    Upsidedown in dreamtown
    Posts
    928
    Login to Give a bone
    0

    Default Re: Is Xrefs a variable?

    Alternatively, I use this code to return a selection set of Xrefs:
    Code:
     
      (setq InsertList (ssget "X" '((0 . "INSERT"))))
      (while (< 0 (sslength InsertList))
        (if (/= nil (assoc 1 (setq Xref-Block (tblsearch "BLOCK" (cdr (assoc 2 (setq Xref-Insert (entget (ssname Insertlist 0)))))))));if
          (progn
     (setq XrefList (append XrefList (list Xref-Block)))
     (setq InsertList (ssdel (ssname InsertList 0) InsertList)));then
          (setq InsertList (ssdel (ssname InsertList 0) InsertList)));else
        )

  5. #5
    All AUGI, all the time Avatart's Avatar
    Join Date
    2004-06
    Location
    Upsidedown in dreamtown
    Posts
    928
    Login to Give a bone
    0

    Default Re: Is Xrefs a variable?

    Looks like Kennet and me were doing the same thing at the same time!

    Kennet!

  6. #6
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    1

    Default Re: Is Xrefs a variable?

    Quote Originally Posted by carl_hd_collins View Post
    Looks like Kennet and me were doing the same thing at the same time!

    Kennet!
    Yes, but you are missing the "other space" in your code ; )

    this code create two lists of dxf codes,
    one for xrefs = XrefList
    and one for blocks = BlockList
    Code:
    (setq BlockDXF (tblnext "BLOCK" T ) )
    (while BlockDXF
      (if (= (logand 4 (cdr (assoc 70 BlockDXF )) ) 4 )
        (setq XrefList  (append XrefList  (list BlockDXF )) )
        (setq BlockList (append BlockList (list BlockDXF )) )
      )
      (setq BlockDXF (tblnext "BLOCK" nil ))
    )
    : ) Happy Computing !

    kennet

  7. #7
    All AUGI, all the time Avatart's Avatar
    Join Date
    2004-06
    Location
    Upsidedown in dreamtown
    Posts
    928
    Login to Give a bone
    0

    Default Re: Is Xrefs a variable?

    Quote Originally Posted by kennet.sjoberg View Post
    Yes, but you are missing the "other space" in your code ; )

    this code create two lists of dxf codes,
    one for xrefs = XrefList
    and one for blocks = BlockList
    Code:
    (setq BlockDXF (tblnext "BLOCK" T ) )
    (while BlockDXF
      (if (= (logand 4 (cdr (assoc 70 BlockDXF )) ) 4 )
        (setq XrefList  (append XrefList  (list BlockDXF )) )
        (setq BlockList (append BlockList (list BlockDXF )) )
      )
      (setq BlockDXF (tblnext "BLOCK" nil ))
    )
    : ) Happy Computing !

    kennet
    That's because you are a better Lisper than me.

  8. #8
    AUGI Addict
    Join Date
    2006-04
    Location
    (getpoint "Anywhere on the Enter Key =>")
    Posts
    1,160
    Login to Give a bone
    0

    Default Re: Is Xrefs a variable?

    Quote Originally Posted by kennet.sjoberg View Post
    No there is no variable storing xrefs.


    : ) Happy Computing !

    kennet
    Hi Guys,

    Sorry for the late response as I was too busy to finish my work - I am not the boss, unfortunately...

    I tried your code & works well. Thanks for your wonderful tips!

    Ke

  9. #9
    Member
    Join Date
    2005-07
    Posts
    40
    Login to Give a bone
    0

    Default Re: Is Xrefs a variable?

    I was looking into certain aspects of this myself and I found your posts here very helpful.

    Rob

  10. #10
    All AUGI, all the time Avatart's Avatar
    Join Date
    2004-06
    Location
    Upsidedown in dreamtown
    Posts
    928
    Login to Give a bone
    0

    Default Re: Is Xrefs a variable?

    Quote Originally Posted by rmiller.90409 View Post
    I was looking into certain aspects of this myself and I found your posts here very helpful.

    Rob
    Glad be of service (even if my code was not as as Kennets)

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 11
    Last Post: 2010-04-08, 09:03 PM
  2. Project Navigator - xrefs? what xrefs?
    By rodg in forum CAD Management - General
    Replies: 0
    Last Post: 2008-11-04, 08:21 AM
  3. Project Navigator - xrefs? what xrefs?
    By rodg in forum CAD Management - General
    Replies: 0
    Last Post: 2008-11-04, 08:20 AM
  4. Variable height/variable count family (studs in a sloped wall)
    By DoTheBIM in forum Revit Architecture - Families
    Replies: 6
    Last Post: 2006-06-15, 02:48 PM
  5. XREFS - MSG not xrefs "Not Found"
    By spencer.67965 in forum VBA/COM Interop
    Replies: 0
    Last Post: 2005-01-18, 03:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •