Author Topic: Xref 2 Block  (Read 4088 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2081
Xref 2 Block
« on: June 29, 2006, 02:44:43 PM »
Tim

Your routine Xrefs2Block is one of the slickest routines, I use it all of the time.

I encouter an error if I have the xrefs opened also. Just wonder if you have encounter this also, or
if there is a fix for it.

Select objects:
; error: Automation Error. Description was not provided.
Command:

Otherwise it works perfectly.

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 #1 on: June 29, 2006, 02:50:46 PM »
I don't use it.  Can you post the version you are using, as I'm not sure I have the code handy either?  The problem seems like I didn't code for it to check to make sure one could open the file.  It might be an easy fix, or a hard one.  If you post it, I will look when I have time.

Glad you like it.
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 #2 on: June 29, 2006, 02:58:52 PM »
Tim

I don't use it.  Can you post the version you are using, as I'm not sure I have the code handy either?  The problem seems like I didn't code for it to check to make sure one could open the file.  It might be an easy fix, or a hard one.  If you post it, I will look when I have time.

Glad you like it.

Thanks for looking at it.
I use this routine two or three times a week.

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 #3 on: June 29, 2006, 03:20:08 PM »
Gary,

The problem is right here, as I thought.
Code: [Select]
(if (setq FullPath (findfile (vla-get-Path XrefObj)))
          (progn
            (vla-Open dbxApp FullPath)
There is a couple of things that we could do.  One that Joe Burke does is check to see if the draiwng is open by the one calling the routine, and then get it from there.  Good way of doing it, or we could copy the file somewhere so that we can open it with ObjectDBX.  I don't have time to code it right now, but if no one else does, then I will get around to it.
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 #4 on: June 29, 2006, 03:49:58 PM »
Tim

Gary,

The problem is right here, as I thought.
Code: [Select]
(if (setq FullPath (findfile (vla-get-Path XrefObj)))
          (progn
            (vla-Open dbxApp FullPath)
There is a couple of things that we could do.  One that Joe Burke does is check to see if the draiwng is open by the one calling the routine, and then get it from there.  Good way of doing it, or we could copy the file somewhere so that we can open it with ObjectDBX.  I don't have time to code it right now, but if no one else does, then I will get around to it.

Thanks, could it be modified to open as read only?

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 #5 on: June 29, 2006, 04:00:32 PM »
Not with ObjectDBX for some reason, or I haven't found it yet.  That would be really nice if it could.
Tim

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

Please think about donating if this post helped you.

Joe Burke

  • Guest
Re: Xref 2 Block
« Reply #6 on: June 30, 2006, 06:39:37 AM »
Hi Gary and Tim,

Hope I'm not stepping on toes, meaning yours, Tim.  :-)

Gary, if you change the line Tim mentioned and add the following function it should work. I gave it a quick test.

Code: [Select]
;; Function decides whether to use an open document or
;; ODBX if the  file at path isn't open.
;; Argument: full path
;; Returns: a document object (srcdoc)
(defun DocAtPath ( path / *acad* version file srcdoc )
  (setq *acad* (vlax-get-acad-object))
  ;check the documents collection
  (vlax-for x (vla-get-documents *acad*)
    (if (= (strcase path) (strcase (vlax-get x 'FullName)))
      (setq srcdoc x)
    )
  )
  ;otherwise use ObjectDBX
  (if (not srcdoc)
    (cond
      ;2004 or later
      ;revised 11/10/2005 to allow future versions
      ;like "ObjectDBX.AxDbDocument.17" - Tony Tanzillo
      ;((> (atoi (getvar "AcadVer")) 15)
      ((> (setq version (atoi (getvar "AcadVer"))) 15)
        (setq srcdoc
          (vla-GetInterfaceObject *acad*
            (strcat "ObjectDBX.AxDbDocument." (itoa version))))
        (vla-open srcdoc path)
      )
      ;prior to 2004
      (T
        (if
          (and
            (vl-catch-all-error-p
              (vl-catch-all-apply
                'vla-GetInterfaceObject
                  (list *acad* "ObjectDBX.AxDbDocument")))
            (setq file (findfile "AxDb15.dll"))
          )
          (startapp "regsvr32.exe" (strcat "/s \"" file "\""))
        ) ;if
        (setq srcdoc (vla-GetInterfaceObject *acad* "ObjectDBX.AxDbDocument"))
        (vla-open srcdoc path)
      )
    ) ;cond
  ) ;if
  srcdoc
) ;end

Joe Burke

  • Guest
Re: Xref 2 Block
« Reply #7 on: June 30, 2006, 06:42:10 AM »
oops...

Gary,

;(vla-Open dbxApp FullPath) ;change this
(setq dbxApp (DocAtPath FullPath)) ;to this

Joe Burke

  • Guest
Re: Xref 2 Block
« Reply #8 on: June 30, 2006, 07:13:07 AM »
Gary,

And remove this part since that's done in the other function, if needed.

;      (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))))

GDF

  • Water Moccasin
  • Posts: 2081
Re: Xref 2 Block
« Reply #9 on: June 30, 2006, 11:10:35 AM »
Gary,

And remove this part since that's done in the other function, if needed.

;      (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))))

Joe

You can step on my toes any time <even with big heavy boots>. A perfect fix, and I learned something to boot. Thanks.
This is one hell of a routine, thanks Tim and Joe. Tim I now give this a 10 star rating <out of 10>.

I xref a lot, and this little jem sure comes in handy.

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 #10 on: June 30, 2006, 11:13:19 AM »
Hi Gary and Tim,

Hope I'm not stepping on toes, meaning yours, Tim.  :-)
No problem Joe.  I don't really have time right now, too much "real" work.  I'm glad someone could step in and correct this issue.  Thanks Joe.  :-)

Joe

You can step on my toes any time <even with big heavy boots>. A perfect fix, and I learned something to boot. Thanks.
This is one hell of a routine, thanks Tim and Joe. Tim I now give this a 10 star rating <out of 10>.

I xref a lot, and this little jem sure comes in handy.

Gary

Glad you like it Gary, and find it useful.  Thanks for the thumbs up ranking, I'm very happy now, on this Friday before the long weekend. :wink:
Tim

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

Please think about donating if this post helped you.