Author Topic: Xref 2 Block  (Read 7917 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Xref 2 Block
« Reply #15 on: January 19, 2006, 10:44:09 AM »
Thanks for the link Jeff.  I don't see anything that helps in this situation.  The only reason why I asked is because when updateding my plot routine, I had to release the plot configurations that I opened in the Odbx document to stop a crash that was pretty consistant.  I didn't crash after I ran the code posted here, so I figured it was okay, but I just wanted to make sure.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2021
Re: Xref 2 Block
« Reply #16 on: January 19, 2006, 10:57:32 AM »
Tim

Thanks for the XrefBlockInsert.lsp routine. My coworker has made another request. He wants to window select multiple xrefs <unit plans within a building>
and have them converted into one block. This is way out of my league, so I defer to you experts.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Xref 2 Block
« Reply #17 on: January 19, 2006, 11:01:24 AM »
I can't write it right now, but it shouldn't be too hard to change the lisp I provided.  Just use a selection set, make sure what is selected is an xref.  Make the block name, and the open each drawing with ObjectDBX and copy the objects into the new block.  Maybe change what I did into a sub-routine, and then just pass the xref, and the block name to it.  I think I would do that.

If no one writes one, then I will try when I have time.  How would you (co-worker) want the block named?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2021
Re: Xref 2 Block
« Reply #18 on: January 19, 2006, 11:29:13 AM »
Tim

Thanks. That vl stuff is beyond me. The block can be named something like "Footprint".

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

LE

  • Guest
Re: Xref 2 Block
« Reply #19 on: January 19, 2006, 11:37:12 AM »
Master Tim while you are on the mood, I do not have the time to write any good code that could do ALL my interior elevations, I need for a house I am designing, it is a kind of complex, since is not just a boxy project... Hope you got time and willing to do it, I have a dead-line by the end of this month....


Sorry I could not resist.... He he....  :evil:  :evil:  :evil:

GDF

  • Water Moccasin
  • Posts: 2021
Re: Xref 2 Block
« Reply #20 on: January 19, 2006, 12:10:00 PM »
Luis

I see the fruit does not fall far from the tree <your icon image>.
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Xref 2 Block
« Reply #21 on: January 19, 2006, 01:12:17 PM »
Here you go.
Code: [Select]
(defun c:Xrefs2Block (/ ActDoc BlkCol LayCol Message NewBlkName ss Ent EntData BlkName BlkRefObj XrefList dbxApp
                        LayList ObjList FullPath NewBlk)

(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(setq BlkCol (vla-get-Blocks ActDoc))
(setq LayCol (vla-get-Layers ActDoc))
(setq Message "\n Enter block name: ")
(if
 (and
  (while
   (or
    (not NewBlkName)
    (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-Item (list BlkCol NewBlkName))))
   )
   (not (while (= (setq NewBlkName (getstring T Message)) "")))
   (setq Message "\n Block name already exist, please type another: ")
  )
  (setq ss (ssget '((0 . "INSERT"))))
 )
 (progn
  (while (setq Ent (ssname ss 0))
   (and
    (setq EntData (entget Ent))
    (setq BlkName (cdr (assoc 2 EntData)))
    (setq BlkRefObj (vla-item BlkCol BlkName))
    (= (vla-get-IsXref BlkRefObj) :vlax-true)
    (setq XrefList (cons Ent XrefList))
   )
   (ssdel Ent ss)
  )
  (setq dbxApp
   (if (< (atoi (setq oVer (substr (getvar "acadver") 1 2))) 16)
    (vla-GetInterfaceObject (vlax-get-acad-object) "ObjectDBX.AxDbDocument")
    (vla-GetInterfaceObject (vlax-get-acad-object) (strcat "ObjectDBX.AxDbDocument." oVer))
   )
  )
  (foreach Ename XrefList
   (setq BlkName (cdr (assoc 2 (entget Ename))))
   (vlax-for i LayCol
    (if
     (and
      (wcmatch (setq LayName (vla-get-Name i)) (strcat BlkName "|*"))
      (= (vla-get-LayerOn i) :vlax-true)
      (= (vla-get-Freeze i) :vlax-false)
     )
     (setq LayList (cons (substr LayName (+ 2 (strlen BlkName))) LayList))
    )
   )
   (if (not NewBlk)
    (setq NewBlk (vlax-invoke BlkCol 'Add '(0.0 0.0 0.0) NewBlkName))
   )
   (if (setq FullPath (findfile (vla-get-Path (vlax-ename->vla-object Ename))))
    (progn
     (vla-Open dbxApp FullPath)
     (vlax-for i (vla-get-ModelSpace dbxApp)
      (if (vl-position (vla-get-Layer i) LayList)
       (setq ObjList (cons i ObjList))
      )
     )
     (vlax-invoke dbxApp 'CopyObjects ObjList NewBlk)
    )
    (prompt (strcat "\n Can not find \"" FullPath "\" drawing to open."))
   )
   (setq LayList nil)
   (setq ObjList nil)
  )
  (vlax-release-object dbxApp)
  (setq dbxApp nil)
 )
)
(princ)
)
This works on my test drawing.  If the xref's are rotated or scaled, then it won't correct that.  No error trapping either.

Master Tim <snip>

This just makes me want to try and figure out a code.  :roll:
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: Xref 2 Block
« Reply #22 on: January 19, 2006, 01:14:56 PM »
This just makes me want to try and figure out a code.  :roll:

No.... I don't need nothing.... thanks....  :kewl:

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Xref 2 Block
« Reply #23 on: January 19, 2006, 01:50:59 PM »
No.... I don't need nothing.... thanks.... :kewl:
I know, you are WAY better than I am at code anyway, but the challenge would be fun.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: Xref 2 Block
« Reply #24 on: January 19, 2006, 02:00:47 PM »
I know, you are WAY better than I am at code anyway, but the challenge would be fun.

Hey.... there is only one person in the world, that really knows everything.... the name is unnamed.....

Actually... to do block-outs it would be very easy.... have no idea of how many will benefit of such routine... in my case, I have to come up with all interior elevations for the type of projects I have to do....
« Last Edit: January 19, 2006, 07:21:31 PM by LE »

Jeff_M

  • King Gator
  • Posts: 3948
  • C3D user & customizer
Re: Xref 2 Block
« Reply #25 on: January 19, 2006, 06:25:07 PM »
Hey Tim, your routines for the xref to block look good, except I notice that if there is anything drawn on Layers 0 or Defpoints in the xref they do not get copied.........note that there is never a layer called XRName|0 or XRName|Defpoints ?

I thought I'd also mention that I couldn't figure out why your attempt at using the XRDatabase failed. Then I tried & tried & tried and finally realized that the XRDB has the Xref layers already. SO it appears you can do a lot of things with the XRDB, copyobjects to another owner is not one of them since you cannot place items on an Xref layer.

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Xref 2 Block
« Reply #26 on: January 19, 2006, 06:46:18 PM »
Hey Tim, your routines for the xref to block look good, except I notice that if there is anything drawn on Layers 0 or Defpoints in the xref they do not get copied.........note that there is never a layer called XRName|0 or XRName|Defpoints ?
Good point.  I didn't even think about those two layers. Thanks.  This should be an easy fix if it's wanted.

I thought I'd also mention that I couldn't figure out why your attempt at using the XRDatabase failed. Then I tried & tried & tried and finally realized that the XRDB has the Xref layers already. SO it appears you can do a lot of things with the XRDB, copyobjects to another owner is not one of them since you cannot place items on an Xref layer.
Yea.  I was thinking that maybe you cuold change the layer before copying, but then I said no way, that wouldn't work.  So I decided to go the ObjectDBX route.

Now that you mention things about layers, I wonder if I should run through the list when I first open the drawing, and unlock all the layers, or does that matter with ObjectDBX?  I don't think I have run into this issue, but I don't lock layers, so I wouldn't, but if someone knows the please post.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Xref 2 Block
« Reply #27 on: January 19, 2006, 07:16:14 PM »
Now that you mention things about layers, I wonder if I should run through the list when I first open the drawing, and unlock all the layers, or does that matter with ObjectDBX? I don't think I have run into this issue, but I don't lock layers, so I wouldn't, but if someone knows the please post.
In my testing, it doesn't matter.  If the layer is locked, it will bring it over locked.  I ran it again after it brought in the locked layer, and it still shows like it should.  That is cool.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2021
Re: Xref 2 Block
« Reply #28 on: January 20, 2006, 10:25:38 AM »
Tim

Thanks for your time and routine for addressing my question. I really do thank you.

We do mostly tax credit low income housing <like appartments> here at our office. We xref the unit plans into the building plan. A typical building plan can have multiple units of the same type, often mirrored and rotated. The request was based upon the need to simplify the process of doing an xref bind insert with a minimum of layers turned on. This new block would be used for the site plan.

I thought that others along with our inhouse use could benefit from a routine that could make a block out of all xrefs selected with only the current layers visible used.
Your latest routine only captured three of the ten unit plans within the xref. Also the new block does not match the rotation or mirrored state found in the xref.

I am going to have to learn this vl lisp stuff when I get the time. Anyway thanks for taking the time on this request. This is still an open request if anyone is up to the challange. This is way beyond my meger lisp knowledge.

Maybe Luis will come up with an arx function to do the trick. He He.

Anyway for not we will just have to do the bind insert option.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Xref 2 Block
« Reply #29 on: January 20, 2006, 11:13:21 AM »
One would have to know about Matrices, and I do not.  I looked into them a little, but didn't get what I felt was a good enough understanding of how to use them/ make them.  I want to learn this, just because I think it would be fun, so if anyone has a link to a good Matrix explanation, please post.

Your latest routine only captured three of the ten unit plans within the xref.
You saying that you picked 10 xrefs, and only three were returned?  That is not right.  Are any of them nested?  I don't know how it will handel nested ones.

If I get somemore free time, I will see what I can do.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.