Author Topic: Wblock with ObjectDBX and Visual Lisp  (Read 5144 times)

0 Members and 1 Guest are viewing this topic.

mmalbr

  • Guest
Wblock with ObjectDBX and Visual Lisp
« on: December 12, 2008, 11:22:53 AM »
What's wrong in the code below?

Should export a new drawing for a block contained in another design without opening it

(setq
*acad* (vlax-get-acad-object)
doc (vla-get-activedocument *acad*)
desenho "C:\\Arquivos de programas\\AutoCAD 2007\\support\\db_samp.dwg"
)
(setq oDBX (vla-GetInterfaceObject *acad* "ObjectDBX.AxDbDocument.17"))
(vla-open oDBX desenho)

(vlax-for layout (vla-get-layouts oDBX)
(vlax-for blk (vla-get-block layout)
(if (and
(= (vla-get-objectname blk) "AcDbBlockReference")
(= (strcase (vla-get-name blk)) "CHAIR7")
)
(setq nomes_lst (cons blk nomes_lst))
)
)
nomes_lst
)
(setq SAwallobj (vlax-make-safearray vlax-vbObject '(0 . 0)))
(vlax-safearray-fill SAwallobj (car nomes_lst)) ; error here
(vla-wblock oDBX "c:/bloco.dwg" SAwallobj) ; and error here too



Marcos Mendes
Visit my site:
http://www.autolisp.com.br/

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Wblock with ObjectDBX and Visual Lisp
« Reply #1 on: December 12, 2008, 11:30:09 AM »
It looks like vla-wblock is looking for a selection set rather than a safearray

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

mmalbr

  • Guest
Re: Wblock with ObjectDBX and Visual Lisp
« Reply #2 on: December 12, 2008, 11:47:08 AM »
(vla-wblock oDBX "c:/bloco.dwg" SAwallobj)

SAwallobj is SAFEARRAY, but is not it working!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Wblock with ObjectDBX and Visual Lisp
« Reply #3 on: December 12, 2008, 12:03:12 PM »
Welcome to the Swamp. :-)
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.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Wblock with ObjectDBX and Visual Lisp
« Reply #4 on: December 12, 2008, 12:16:57 PM »
Hi Marcos. Welcome to the Swamp!

As Ronjonp noted, you are passing an array to the WBLOCK method which is expecting a SelectionSet. Since you cannot create or use selection sets in an ObjectDBX document wou will need to do this another way. Try creating the new drawing, then use the CopyObjects (which CAN use the array you created) method to get the entities into that new drawing

efernal

  • Bull Frog
  • Posts: 206
Re: Wblock with ObjectDBX and Visual Lisp
« Reply #5 on: December 12, 2008, 12:26:02 PM »
ei, marcos, em menos de uma hora você já obteve 4 respostas...
aqui é o lugar, cara...
abs...
e.fernal

e.fernal

mmalbr

  • Guest
Re: Wblock with ObjectDBX and Visual Lisp
« Reply #6 on: December 12, 2008, 01:02:37 PM »
Pois é ... gostei daqui!

valeu mesmo!

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Wblock with ObjectDBX and Visual Lisp
« Reply #7 on: December 12, 2008, 01:06:50 PM »
See if this help you out some....no error checking included.
Code: [Select]

(defun copytocurrentdwg (copydoc blkname / *acad* doc objlst odbx)
  (setq *acad* (vlax-get-acad-object)
doc    (vla-get-activedocument *acad*)
  )

  (setq oDBX (vla-GetInterfaceObject *acad* "ObjectDBX.AxDbDocument.17"))
  (vl-catch-all-apply 'vla-open (list odbx copydoc))

  (vlax-for layout (vla-get-layouts oDBX)
    (vlax-for blk (vla-get-block layout)
      (if (and
    (= (vla-get-objectname blk) "AcDbBlockReference")
    (= (strcase (vla-get-name blk)) (strcase blkname))
  )
(setq objlst (cons blk objlst))
      )
    )
  )
  (vla-copyobjects
    odbx
    (vlax-safearray-fill
      (vlax-make-safearray
vlax-vbobject
(cons 0 (1- (length objlst)))
      )
      objlst
    )
    (vla-get-modelspace
      (vla-get-activedocument (vlax-get-acad-object))
    )
  )
  (vla-saveas odbx (vla-get-name odbx))
  (vlax-release-object odbx)
  (princ)
)
;;Lets run it (this copies to the current open drawing)
(copytocurrentdwg
  "C:\\Arquivos de programas\\AutoCAD 2007\\support\\db_samp.dwg"
  "CHAIR7"
)
« Last Edit: December 12, 2008, 03:21:41 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Spike Wilbury

  • Guest
Re: Wblock with ObjectDBX and Visual Lisp
« Reply #8 on: December 12, 2008, 01:08:48 PM »
and for those of us, that do not speak Portuguese...

I think Marcos, is saying:

Quote
In less than an hour, I got four answers, I like this place...

That's why I like here!!!

It Worth's !


:)

mmalbr

  • Guest
Re: Wblock with ObjectDBX and Visual Lisp
« Reply #9 on: December 12, 2008, 01:09:30 PM »
Hi Marcos. Welcome to the Swamp!

As Ronjonp noted, you are passing an array to the WBLOCK method which is expecting a SelectionSet. Since you cannot create or use selection sets in an ObjectDBX document wou will need to do this another way. Try creating the new drawing, then use the CopyObjects (which CAN use the array you created) method to get the entities into that new drawing

Thanks .. I will try this way!

mmalbr

  • Guest
Re: Wblock with ObjectDBX and Visual Lisp
« Reply #10 on: December 12, 2008, 01:20:05 PM »
See if this help you out some....no error checking included.

Thanks .. I will try