Author Topic: Xref 2 Block  (Read 17307 times)

0 Members and 2 Guests are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Xref 2 Block
« Reply #30 on: January 20, 2006, 11:42:58 AM »
Thanks Tim

Here is some matrix functions....I think.

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

Joe Burke

  • Guest
Re: Xref 2 Block
« Reply #31 on: January 21, 2006, 05:22:58 AM »
Tim and Jeff,

I've seen cases where CopyObjects with the XRDB as the source failed randomly. Well, at least as far as I could tell.

I also recall a topic in the Autodesk NG by James Allen where he reported the same thing. The conclusion there was why bother.

Joe Burke

  • Guest
Re: Xref 2 Block
« Reply #32 on: January 21, 2006, 06:00:01 AM »
Hi Gary,

I revised those functions since what you posted. Here's the latest set. The revisions correct a bug when a block's Normal is (0 0 -1).

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Xref 2 Block
« Reply #33 on: January 21, 2006, 08:52:57 AM »
Joe,
Thanks for the update. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Xref 2 Block
« Reply #34 on: January 21, 2006, 03:18:19 PM »
Thanks Joe for the update.

Code: [Select]
I revised those functions since what you posted. Here's the latest set. The revisions correct a bug when a block's Normal is (0 0 -1).

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

CADaver

  • Guest
Re: Xref 2 Block
« Reply #35 on: January 21, 2006, 09:53:29 PM »
Have you used already the "terminator" ? ...

whatever for??

how do you like the nested copy ?....

one of the two things i like about msta (the other is dim strings)

the what you see, what you get thing...

not even close to WYSIWYG linetypes, fonts, and lineweights.  you have no clue what the lkinetypes look like until you plot it. ignorant piece of software.

much better than acad no?

in a word, no.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Xref 2 Block
« Reply #36 on: January 23, 2006, 11:34:07 AM »
Hey Joe,

  Thanks for the Matrix codes.  I have been working one some (trying to understand them) and I came up with the same rotation calculations that you did, and they both don't seem to work correctly.  Maybe I'm using them wrong I don't know.  What I'm doing here is:

I get all the objects from the selected xref.
I copy them into the current drawing, into a new block definition.
I then apply the functions you provided to the xref selected.
I then apply the returned matrix to each object.
I then insert the block, hoping that it matches what is on the screen now
but the rotation is wrong, but the scaling is right.

What am I doing wrong?
Thanks in advance.
Tim

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

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Xref 2 Block
« Reply #37 on: January 23, 2006, 11:58:29 AM »
Tim,
You guys are way ahead of me so this may be off base.
But using the nentsel matrix results in a rotation in the wrong direction
where nentselp matrix gives the rotation in the correct direction.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Xref 2 Block
« Reply #38 on: January 23, 2006, 12:06:40 PM »
Tim,
You guys are way ahead of me so this may be off base.
But using the nentsel matrix results in a rotation in the wrong direction
where nentselp matrix gives the rotation in the correct direction.

I guess I could try and use that, but with the new way Gary wants it to work is more like a selection set, so I was trying to create the matrix off the object itself.  I guess I could have it go until enter is pressed, and just use either nentsel, or nentselp.  I guess this is kind of a learning chance for me, so I was hoping to learn how to do matrices with this routine.
Thanks for the info Alan.

ps.  That is really weird to me, that only one would be correct.
Tim

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

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Xref 2 Block
« Reply #39 on: January 23, 2006, 12:08:26 PM »
I was working on placing a rectangle around nested text which could be
scaled within nested blocks & rotated. I has worked in my testing but
who knows if all combinations of situations will work.
http://www.theswamp.org/forum/index.php?topic=7003.msg107478#msg107478
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Xref 2 Block
« Reply #40 on: January 23, 2006, 12:22:26 PM »
I was working on placing a rectangle around nested text which could be
scaled within nested blocks & rotated. I has worked in my testing but
who knows if all combinations of situations will work.
http://www.theswamp.org/forum/index.php?topic=7003.msg107478#msg107478
That is a lot of code to digest.  I will try and understand it all when I get a chance.

I would really prefer to get the matrix from the object, and not have to use either "nentsel/p" options.  But if I have to, then I have to.  We shall see.

Thanks again.
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: 2081
Re: Xref 2 Block
« Reply #41 on: January 23, 2006, 12:32:38 PM »
Thanks Tim, Allen, Jeff and everyone else for attacking this request. This stuff is way beyond my ability.

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

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Xref 2 Block
« Reply #42 on: January 23, 2006, 12:33:54 PM »
Thanks Tim, Allen, Jeff and everyone else for attacking this request. This stuff is way beyond my ability.

Gary
Mine too, but I love a challenge, and the learning it brings.  :evil:
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: 5251
Re: Xref 2 Block
« Reply #43 on: January 23, 2006, 01:27:18 PM »
Here is one that works.  Be careful and test it first.  My setup here seems to crash when I use the xref command after, but not when I use ".xref", so I'm thinking it is something with my Acad setup.  Let me know what happens.
What I fixed was soemthing I saw in a code by Joe Burke.  When he got the answer (matrix) from the function "ObjMatrix" he turned it into a variant, and then passed the variant to (vla-transformedby.... , and that seemed to work here also.  Make sure you have the lisps that he provided loaded, or it will error.

Thanks Joe.
Code: [Select]
(defun c:Xrefs2Block (/ ActDoc BlkCol LayCol Message NewBlkName ss Ent EntData BlkName BlkRefObj XrefList dbxApp
                        LayList ObjList FullPath NewBlk NewObjList LayToLock XrefObj)

(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))))
   (setq XrefObj (vlax-ename->vla-object 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 XrefObj)))
    (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))
      )
     )
     (setq NewObjList (vlax-invoke dbxApp 'CopyObjects ObjList NewBlk))
     (foreach Lay LayList
      (if
       (and
        (not (vl-catch-all-error-p (setq LayObj (vl-catch-all-apply 'vla-Item (list LayCol Lay)))))
        (= (vla-get-Lock LayObj) ':vlax-true)
       )
       (progn
        (vla-put-Lock LayObj :vlax-false)
        (setq LayToLock (cons LayObj LayToLock))
       )
      )
     )
     (foreach i NewObjList
      (vla-TransformBy i (vlax-tmatrix (ObjMatrix XrefObj)))
     )
     (mapcar 'vlax-release-object NewObjList)
     (vlax-release-object XrefObj)
     (setq NewObjList nil)
     (foreach Lay LayToLock
      (vla-put-Lock  Lay :vlax-true)
     )
     (setq LayToLock nil)
    )
    (prompt (strcat "\n Can not find \"" FullPath "\" drawing to open."))
   )
   (setq LayList nil)
   (setq ObjList nil)
  )
  (if NewBlk
   (vlax-invoke (vla-get-Block (vla-get-ActiveLayout ActDoc)) 'InsertBlock '(0.0 0.0 0.0) (vla-get-Name NewBlk) 1.0 1.0 1.0 0.0)
  )
  (vlax-release-object dbxApp)
  (setq dbxApp nil)
)
)
(princ)
)

ps.  Forgot to tell you, this will insert the block also.
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: 2081
Re: Xref 2 Block
« Reply #44 on: January 23, 2006, 02:12:26 PM »
Thanks Tim

; error: no function definition: OBJMATRIX

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