Author Topic: ObjectDBX Xref for block  (Read 9003 times)

0 Members and 1 Guest are viewing this topic.

OcCad

  • Guest
Re: ObjectDBX Xref for block
« Reply #15 on: November 01, 2007, 02:18:11 PM »
I'm still getting the same return. When I try to see where it gets messed up it seems its as if its here:

Code: [Select]
    (setq dwgName InsName)

    ;create an ObjectDBX Document
    (setq dbxDoc (vla-GetInterfaceObject (vlax-get-acad-object)
         ObjectDBX.AxDbDocument.16))
      (vlax-invoke dbxDoc "Open" dwgName)

    ;get the desired block

"dwgName" will return a value however "dbxDoc" returns nil as does "dbxBlocks."

VovKa

  • Swamp Rat
  • Posts: 1150
  • Ukraine
Re: ObjectDBX Xref for block
« Reply #16 on: November 01, 2007, 02:47:43 PM »
is dbx server registered?
version of Acad?

T.Willey

  • Needs a day job
  • Posts: 5218
Re: ObjectDBX Xref for block
« Reply #17 on: November 01, 2007, 02:48:29 PM »
See if this will get what you are looking for.  It's what I use courtesy of Jeff M.
Code: [Select]
(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))
 )
)

What version of Cad are you on?
Tim

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

Please think about donating if this post helped you.

OcCad

  • Guest
Re: ObjectDBX Xref for block
« Reply #18 on: November 01, 2007, 02:49:40 PM »
AC 2008

VovKa

  • Swamp Rat
  • Posts: 1150
  • Ukraine
Re: ObjectDBX Xref for block
« Reply #19 on: November 01, 2007, 03:11:07 PM »
if still getting an error, then register dbx server
Code: [Select]
((lambda (v)
   (if (not
(vl-registry-read
   (strcat "HKEY_CLASSES_ROOT\\ObjectDBX.AxDbDocument." v "\\CLSID")
)
       )
     (startapp "regsvr32.exe"
       (strcat "/s \"" (findfile (strcat "AxDb" v ".dll")) "\"")
     )
   )
 )
  (substr (getvar "ACADVER") 1 2)
)

OcCad

  • Guest
Re: ObjectDBX Xref for block
« Reply #20 on: November 01, 2007, 03:14:02 PM »
still...

"; error: ActiveX Server returned an error: Parameter not optional" :-(

MP

  • Seagull
  • Posts: 17423
Re: ObjectDBX Xref for block
« Reply #21 on: November 01, 2007, 03:20:35 PM »
If you're using 2008 object dbx should already be registered:

Code: [Select]
(   (lambda ( version )
        (vl-registry-read
            (strcat "HKEY_CLASSES_ROOT\\ObjectDBX.AxDbDocument"
                (if (eq 15 version)
                    "\\CLSID"
                    (strcat "." (itoa version) "\\CLSID")
                )
            )
        )
    )
    (atoi (getvar "acadver"))
)

=> "{49998808-648A-4A9C-A7A5-B1672775D9AB}"
« Last Edit: November 01, 2007, 03:22:12 PM by MP »
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

OcCad

  • Guest
Re: ObjectDBX Xref for block
« Reply #22 on: November 01, 2007, 03:24:01 PM »
May you know what parameter is registering as not optional?

T.Willey

  • Needs a day job
  • Posts: 5218
Re: ObjectDBX Xref for block
« Reply #23 on: November 01, 2007, 03:29:53 PM »
Copy/paste the last code I posted to the command line, and post back what it returns.
Tim

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

Please think about donating if this post helped you.

VovKa

  • Swamp Rat
  • Posts: 1150
  • Ukraine
Re: ObjectDBX Xref for block
« Reply #24 on: November 01, 2007, 03:30:24 PM »
put it this way
Code: [Select]
(setq dbxDoc (vla-GetInterfaceObject
(vlax-get-acad-object)
(strcat "ObjectDBX.AxDbDocument." (substr (getvar "acadver") 1 2))
      )
  )
what value doe's (findfile dwgName) return?

OcCad

  • Guest
Re: ObjectDBX Xref for block
« Reply #25 on: November 01, 2007, 03:36:46 PM »
TW: #<VLA-OBJECT IAxDbDocument 11150390>

Code: [Select]
(defun c:xrs ()
 
  (command "-layer" "make" "S-ANNO-XREF" "color" "7" "" "ltype" "continuous" "" "s" "" "")
 (INITDIA)
  (command "xattach" pause)

    (setq EntName  (entlast))
    (setq EntData  (entget EntName))
    (setq InsName  (cdr (assoc 2 EntData)))
    (setq InsScale (cdr (assoc 41 EntData)))
    (setq InsPoint (cdr (assoc 10 EntData)))   

 (vl-load-com)

     ;Register DBX Server
     (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))
      )
     )
    (setq dwgName InsName)

    ;create an ObjectDBX Document
    (setq dbxDoc (vla-GetInterfaceObject (vlax-get-acad-object)
         ObjectDBX.AxDbDocument.16))
      (vlax-invoke dbxDoc "Open" dwgName)

    ;get the desired block
    (setq dbxBlocks (vla-get-blocks dbxDoc))
    (setq dbxBlock (vla-item dbxBlocks "Detail Bdr"))

    (setq dbxEname (vlax-vla-object->ename dbxBlock))
      (setq dbxEntData (entget dbxEname))
        (setq dbxBlockInsert (cdr (assoc 331 dbxEntData)))
        (setq dbxScale (cdr (assoc 41 (entget dbxBlockInsert))))

    (vlax-release-object dbxDoc)
      (setq dbxDoc nil)
   
   (command "scale" EntName "" InsPoint (/ 1 dbxScale))

;;after the insert
  (setq EL (entget (entlast)))
  (prompt (strcat "\nInserted " (cdr (assoc 2 EL)) " at scale " (rtos (* 12 (cdr (assoc 41 EL)))) " = 1' "))

 (princ)
)

T.Willey

  • Needs a day job
  • Posts: 5218
Re: ObjectDBX Xref for block
« Reply #26 on: November 01, 2007, 03:43:00 PM »
In the code replace all the calls to 'dbxDoc' to 'dbxApp' and then remove (or comment out) the portion of the code that assigns 'dbxDoc' as you don't need it.  The way I show (or VovKa shows) is a better way to get it.
Tim

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

Please think about donating if this post helped you.

OcCad

  • Guest
Re: ObjectDBX Xref for block
« Reply #27 on: November 01, 2007, 03:48:11 PM »
Thats closer. Now no nils up until "dbxblocks"

T.Willey

  • Needs a day job
  • Posts: 5218
Re: ObjectDBX Xref for block
« Reply #28 on: November 01, 2007, 03:51:22 PM »
Thats closer. Now no nils up until "dbxblocks"
Did you change the call to the new variable?  The easiest way is to do a find/replace on the whole file.  That is if you are using Notepad, or some other program that works like that.  How are you editing your file?
Tim

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

Please think about donating if this post helped you.

VovKa

  • Swamp Rat
  • Posts: 1150
  • Ukraine
Re: ObjectDBX Xref for block
« Reply #29 on: November 01, 2007, 03:54:46 PM »
one more error:
insted of
(setq InsName  (cdr (assoc 2 EntData)))
write
(setq InsName (cdr (assoc 1 (tblsearch "BLOCK"(cdr (assoc 2 EntData))))))