How to update blocks inserted as wblocks ?

How to update blocks inserted as wblocks ?

Anonymous
Not applicable
325 Views
11 Replies
Message 1 of 12

How to update blocks inserted as wblocks ?

Anonymous
Not applicable
Hello VBA users,

I need to update blocks inserted as wblocks.
I used to apply the DefineBlock method provided with AcVbEXT library when I
was working under AutoCAD 14.01.
Since I've installed A2K, I don't reach to call the
ACVBEXTLib.ActiveXExtension application. The second code line listed below
generates an error :

Dim appACVBEXT As ACVBEXTLib.ActiveXExtension
Set appACVBEXT =
ThisDrawing.Application.GetInterfaceObject("ActiveXExtension.Application.1")

Does anybody knows if the AcVbEXT library is still compatible with A2K ?
Otherwise, how can I redefine wblocks without sending LISP commands ?

Thanks for any help,
Serge.
0 Likes
326 Views
11 Replies
Replies (11)
Message 2 of 12

Anonymous
Not applicable
What's a "wblock"? WBlock is a command.
__
"Serge Heinrich" wrote in message
news:876ecj$ia75@adesknews2.autodesk.com...
> Hello VBA users,
>
> I need to update blocks inserted as wblocks.
> I used to apply the DefineBlock method provided with AcVbEXT library
when I
> was working under AutoCAD 14.01.
> Since I've installed A2K, I don't reach to call the
> ACVBEXTLib.ActiveXExtension application. The second code line listed
below
> generates an error :
>
> Dim appACVBEXT As ACVBEXTLib.ActiveXExtension
> Set appACVBEXT =
>
ThisDrawing.Application.GetInterfaceObject("ActiveXExtension.Application.
1")
>
> Does anybody knows if the AcVbEXT library is still compatible with A2K
?
> Otherwise, how can I redefine wblocks without sending LISP commands ?
>
> Thanks for any help,
> Serge.
>
>
0 Likes
Message 3 of 12

Anonymous
Not applicable
I've not attempted this Serge, so I don't know if it will work. But in
normal AutoCAD, you can redefine a block by just inserting a file with the
same name as an existing block. Have you tried using the InsertBlock method
with an updated version of the file that created your block in the first
place?

"Serge Heinrich" wrote in message
news:876ecj$ia75@adesknews2.autodesk.com...
> Hello VBA users,
>
> I need to update blocks inserted as wblocks.
> I used to apply the DefineBlock method provided with AcVbEXT library when
I
> was working under AutoCAD 14.01.
> Since I've installed A2K, I don't reach to call the
> ACVBEXTLib.ActiveXExtension application. The second code line listed below
> generates an error :
>
> Dim appACVBEXT As ACVBEXTLib.ActiveXExtension
> Set appACVBEXT =
>
ThisDrawing.Application.GetInterfaceObject("ActiveXExtension.Application.1")
>
> Does anybody knows if the AcVbEXT library is still compatible with A2K ?
> Otherwise, how can I redefine wblocks without sending LISP commands ?
>
> Thanks for any help,
> Serge.
>
>
0 Likes
Message 4 of 12

Anonymous
Not applicable
Yes, Frank, it works. Thanks for your help.
But in AutoCAD you can cancel the insertion of the new block reference after
having confirmed the message "This block aleready exists. Do you want to
redefine it ?", so you can update the block without creating a new
reference.
With VBA, if I use the InsertBlock method, it will create a new reference
that I'll have to delete.
In order to update all the blocks of the drawing, I'd have preferred to use
a method which applies to Block objects (such as DefineBlock provided with
AcVbEXT library) in only one loop "For each objBlock in ThisDrawing.Blocks",
rather than the InsertBlock method which applies to BlockReference objects,
that will constrain me to loop in every block references in the ModelSpace
and in every PaperSpace layouts.

Frank Oquendo a écrit dans le message :
877509$l0f16@adesknews2.autodesk.com...
> I've not attempted this Serge, so I don't know if it will work. But in
> normal AutoCAD, you can redefine a block by just inserting a file with the
> same name as an existing block. Have you tried using the InsertBlock
method
> with an updated version of the file that created your block in the first
> place?
>
0 Likes
Message 5 of 12

Anonymous
Not applicable
Paul,
In fact, inserting a block or a wblock reference in VBA uses the same method
"ThisDrawing.ActiveSpace.InsertBlock(...)", and the result is the same: a
new block reference.
But in the first case you specify the name of a block that aleready exists
in the drawing, and in the second case you specify the path and the name of
a drawing that will be used to create a block (after the insertion, there's
no way to see which method has been used, because there's no dynaminc link
between the block and the file ; it's not like an Xref).

Paul Turvill a écrit dans le message :
8774qe$l0g22@adesknews2.autodesk.com...
> What's a "wblock"? WBlock is a command.
0 Likes
Message 6 of 12

Anonymous
Not applicable
No problem. Just do something like this:

For Each blk in ThisDrawing.Blocks
Set blkref = ThisDrawing.ModelSpace.InsertBlock( & blk.name &
".dwg", yada yada)
blkref.Delete
Next

--
Get free software and more at: http://www.stonemedia.com/~franko

"Serge Heinrich" wrote in message
news:878u27$t591@adesknews2.autodesk.com...
> Yes, Frank, it works. Thanks for your help.
> But in AutoCAD you can cancel the insertion of the new block reference
after
> having confirmed the message "This block aleready exists. Do you want to
> redefine it ?", so you can update the block without creating a new
> reference.
> With VBA, if I use the InsertBlock method, it will create a new reference
> that I'll have to delete.
> In order to update all the blocks of the drawing, I'd have preferred to
use
> a method which applies to Block objects (such as DefineBlock provided with
> AcVbEXT library) in only one loop "For each objBlock in
ThisDrawing.Blocks",
> rather than the InsertBlock method which applies to BlockReference
objects,
> that will constrain me to loop in every block references in the ModelSpace
> and in every PaperSpace layouts.
>
>
> Frank Oquendo a écrit dans le message :
> 877509$l0f16@adesknews2.autodesk.com...
> > I've not attempted this Serge, so I don't know if it will work. But in
> > normal AutoCAD, you can redefine a block by just inserting a file with
the
> > same name as an existing block. Have you tried using the InsertBlock
> method
> > with an updated version of the file that created your block in the first
> > place?
> >
>
>
0 Likes
Message 7 of 12

Anonymous
Not applicable
BTW, be sure to screen out the ModelSpace and all PaperSpace blocks.

"Frank Oquendo" wrote in message
news:879uto$2q819@adesknews2.autodesk.com...
> No problem. Just do something like this:
>
> For Each blk in ThisDrawing.Blocks
> Set blkref = ThisDrawing.ModelSpace.InsertBlock( & blk.name
&
> ".dwg", yada yada)
> blkref.Delete
> Next
>
> --
> Get free software and more at: http://www.stonemedia.com/~franko
>
> "Serge Heinrich" wrote in message
> news:878u27$t591@adesknews2.autodesk.com...
> > Yes, Frank, it works. Thanks for your help.
> > But in AutoCAD you can cancel the insertion of the new block reference
> after
> > having confirmed the message "This block aleready exists. Do you want to
> > redefine it ?", so you can update the block without creating a new
> > reference.
> > With VBA, if I use the InsertBlock method, it will create a new
reference
> > that I'll have to delete.
> > In order to update all the blocks of the drawing, I'd have preferred to
> use
> > a method which applies to Block objects (such as DefineBlock provided
with
> > AcVbEXT library) in only one loop "For each objBlock in
> ThisDrawing.Blocks",
> > rather than the InsertBlock method which applies to BlockReference
> objects,
> > that will constrain me to loop in every block references in the
ModelSpace
> > and in every PaperSpace layouts.
> >
> >
> > Frank Oquendo a écrit dans le message :
> > 877509$l0f16@adesknews2.autodesk.com...
> > > I've not attempted this Serge, so I don't know if it will work. But in
> > > normal AutoCAD, you can redefine a block by just inserting a file with
> the
> > > same name as an existing block. Have you tried using the InsertBlock
> > method
> > > with an updated version of the file that created your block in the
first
> > > place?
> > >
> >
> >
>
>
0 Likes
Message 8 of 12

Anonymous
Not applicable
What do you mean ?
Aren't blocks childs of Document object ?

I think that I just have to screen out ThisDrawing.Blocks. Tell me if I'm
wrong.

Thanks a lot for your help.

Frank Oquendo a écrit dans le message :
879var$2qd17@adesknews2.autodesk.com...
> BTW, be sure to screen out the ModelSpace and all PaperSpace blocks.
>
> "Frank Oquendo" wrote in message
> news:879uto$2q819@adesknews2.autodesk.com...
> > No problem. Just do something like this:
> >
> > For Each blk in ThisDrawing.Blocks
> > Set blkref = ThisDrawing.ModelSpace.InsertBlock( &
blk.name
> &
> > ".dwg", yada yada)
> > blkref.Delete
> > Next
> >
> > --
> > Get free software and more at: http://www.stonemedia.com/~franko
> >
> > "Serge Heinrich" wrote in message
> > news:878u27$t591@adesknews2.autodesk.com...
> > > Yes, Frank, it works. Thanks for your help.
> > > But in AutoCAD you can cancel the insertion of the new block reference
> > after
> > > having confirmed the message "This block aleready exists. Do you want
to
> > > redefine it ?", so you can update the block without creating a new
> > > reference.
> > > With VBA, if I use the InsertBlock method, it will create a new
> reference
> > > that I'll have to delete.
> > > In order to update all the blocks of the drawing, I'd have preferred
to
> > use
> > > a method which applies to Block objects (such as DefineBlock provided
> with
> > > AcVbEXT library) in only one loop "For each objBlock in
> > ThisDrawing.Blocks",
> > > rather than the InsertBlock method which applies to BlockReference
> > objects,
> > > that will constrain me to loop in every block references in the
> ModelSpace
> > > and in every PaperSpace layouts.
> > >
> > >
> > > Frank Oquendo a écrit dans le message :
> > > 877509$l0f16@adesknews2.autodesk.com...
> > > > I've not attempted this Serge, so I don't know if it will work. But
in
> > > > normal AutoCAD, you can redefine a block by just inserting a file
with
> > the
> > > > same name as an existing block. Have you tried using the InsertBlock
> > > method
> > > > with an updated version of the file that created your block in the
> first
> > > > place?
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 9 of 12

Anonymous
Not applicable
ModelSpace and and all Layouts (PaperSpace) are blocks. These blocks will
show up in the Blocks collection along with all the others. Just check the
name of each block as you iterate through the collection and leave the ones
that contain the string "ModelSpace" and "PaperSpace" alone. Another note:
be sure to use InStr, not = since all the layouts have "PaperSpace" in them
but the non-current ones have a numeral appended.

--
Get free software and more at
http://msnhomepages.talkcity.com/protectionfault/foquendo

"Serge Heinrich" wrote in message
news:87ed3p$i2a20@adesknews2.autodesk.com...
> What do you mean ?
> Aren't blocks childs of Document object ?
>
> I think that I just have to screen out ThisDrawing.Blocks. Tell me if I'm
> wrong.
>
> Thanks a lot for your help.
>
>
> Frank Oquendo a écrit dans le message :
> 879var$2qd17@adesknews2.autodesk.com...
> > BTW, be sure to screen out the ModelSpace and all PaperSpace blocks.
> >
> > "Frank Oquendo" wrote in message
> > news:879uto$2q819@adesknews2.autodesk.com...
> > > No problem. Just do something like this:
> > >
> > > For Each blk in ThisDrawing.Blocks
> > > Set blkref = ThisDrawing.ModelSpace.InsertBlock( &
> blk.name
> > &
> > > ".dwg", yada yada)
> > > blkref.Delete
> > > Next
> > >
> > > --
> > > Get free software and more at: http://www.stonemedia.com/~franko
> > >
> > > "Serge Heinrich" wrote in message
> > > news:878u27$t591@adesknews2.autodesk.com...
> > > > Yes, Frank, it works. Thanks for your help.
> > > > But in AutoCAD you can cancel the insertion of the new block
reference
> > > after
> > > > having confirmed the message "This block aleready exists. Do you
want
> to
> > > > redefine it ?", so you can update the block without creating a new
> > > > reference.
> > > > With VBA, if I use the InsertBlock method, it will create a new
> > reference
> > > > that I'll have to delete.
> > > > In order to update all the blocks of the drawing, I'd have preferred
> to
> > > use
> > > > a method which applies to Block objects (such as DefineBlock
provided
> > with
> > > > AcVbEXT library) in only one loop "For each objBlock in
> > > ThisDrawing.Blocks",
> > > > rather than the InsertBlock method which applies to BlockReference
> > > objects,
> > > > that will constrain me to loop in every block references in the
> > ModelSpace
> > > > and in every PaperSpace layouts.
> > > >
> > > >
> > > > Frank Oquendo a écrit dans le message
:
> > > > 877509$l0f16@adesknews2.autodesk.com...
> > > > > I've not attempted this Serge, so I don't know if it will work.
But
> in
> > > > > normal AutoCAD, you can redefine a block by just inserting a file
> with
> > > the
> > > > > same name as an existing block. Have you tried using the
InsertBlock
> > > > method
> > > > > with an updated version of the file that created your block in the
> > first
> > > > > place?
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 10 of 12

Anonymous
Not applicable
You don't have to compare strings. The Block object has
an IsLayout property that returns True if the block is
a layout.

Serge Heinrich wrote:
>
> What do you mean ?
> Aren't blocks childs of Document object ?
>
> I think that I just have to screen out ThisDrawing.Blocks. Tell me if I'm
> wrong.
>
> Thanks a lot for your help.
>
> Frank Oquendo a écrit dans le message :
> 879var$2qd17@adesknews2.autodesk.com...
> > BTW, be sure to screen out the ModelSpace and all PaperSpace blocks.
> >
> > "Frank Oquendo" wrote in message
> > news:879uto$2q819@adesknews2.autodesk.com...
> > > No problem. Just do something like this:
> > >
> > > For Each blk in ThisDrawing.Blocks
> > > Set blkref = ThisDrawing.ModelSpace.InsertBlock( &
> blk.name
> > &
> > > ".dwg", yada yada)
> > > blkref.Delete
> > > Next
> > >
> > > --
> > > Get free software and more at: http://www.stonemedia.com/~franko
> > >
> > > "Serge Heinrich" wrote in message
> > > news:878u27$t591@adesknews2.autodesk.com...
> > > > Yes, Frank, it works. Thanks for your help.
> > > > But in AutoCAD you can cancel the insertion of the new block reference
> > > after
> > > > having confirmed the message "This block aleready exists. Do you want
> to
> > > > redefine it ?", so you can update the block without creating a new
> > > > reference.
> > > > With VBA, if I use the InsertBlock method, it will create a new
> > reference
> > > > that I'll have to delete.
> > > > In order to update all the blocks of the drawing, I'd have preferred
> to
> > > use
> > > > a method which applies to Block objects (such as DefineBlock provided
> > with
> > > > AcVbEXT library) in only one loop "For each objBlock in
> > > ThisDrawing.Blocks",
> > > > rather than the InsertBlock method which applies to BlockReference
> > > objects,
> > > > that will constrain me to loop in every block references in the
> > ModelSpace
> > > > and in every PaperSpace layouts.
> > > >
> > > >
> > > > Frank Oquendo a écrit dans le message :
> > > > 877509$l0f16@adesknews2.autodesk.com...
> > > > > I've not attempted this Serge, so I don't know if it will work. But
> in
> > > > > normal AutoCAD, you can redefine a block by just inserting a file
> with
> > > the
> > > > > same name as an existing block. Have you tried using the InsertBlock
> > > > method
> > > > > with an updated version of the file that created your block in the
> > first
> > > > > place?
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >

--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.tanzillo@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/
0 Likes
Message 11 of 12

Anonymous
Not applicable
Good point. I forgot about that.

--
Get free software and more at:
http://msnhomepages.talkcity.com/protectionfault/foquendo

"Tony Tanzillo" wrote in message
news:389B84BF.A728F2CC@worldnet.att.net...
> You don't have to compare strings. The Block object has
> an IsLayout property that returns True if the block is
> a layout.
>
> Serge Heinrich wrote:
> >
> > What do you mean ?
> > Aren't blocks childs of Document object ?
> >
> > I think that I just have to screen out ThisDrawing.Blocks. Tell me if
I'm
> > wrong.
> >
> > Thanks a lot for your help.
> >
> > Frank Oquendo a écrit dans le message :
> > 879var$2qd17@adesknews2.autodesk.com...
> > > BTW, be sure to screen out the ModelSpace and all PaperSpace blocks.
> > >
> > > "Frank Oquendo" wrote in message
> > > news:879uto$2q819@adesknews2.autodesk.com...
> > > > No problem. Just do something like this:
> > > >
> > > > For Each blk in ThisDrawing.Blocks
> > > > Set blkref = ThisDrawing.ModelSpace.InsertBlock( &
> > blk.name
> > > &
> > > > ".dwg", yada yada)
> > > > blkref.Delete
> > > > Next
> > > >
> > > > --
> > > > Get free software and more at: http://www.stonemedia.com/~franko
> > > >
> > > > "Serge Heinrich" wrote in message
> > > > news:878u27$t591@adesknews2.autodesk.com...
> > > > > Yes, Frank, it works. Thanks for your help.
> > > > > But in AutoCAD you can cancel the insertion of the new block
reference
> > > > after
> > > > > having confirmed the message "This block aleready exists. Do you
want
> > to
> > > > > redefine it ?", so you can update the block without creating a new
> > > > > reference.
> > > > > With VBA, if I use the InsertBlock method, it will create a new
> > > reference
> > > > > that I'll have to delete.
> > > > > In order to update all the blocks of the drawing, I'd have
preferred
> > to
> > > > use
> > > > > a method which applies to Block objects (such as DefineBlock
provided
> > > with
> > > > > AcVbEXT library) in only one loop "For each objBlock in
> > > > ThisDrawing.Blocks",
> > > > > rather than the InsertBlock method which applies to BlockReference
> > > > objects,
> > > > > that will constrain me to loop in every block references in the
> > > ModelSpace
> > > > > and in every PaperSpace layouts.
> > > > >
> > > > >
> > > > > Frank Oquendo a écrit dans le
message :
> > > > > 877509$l0f16@adesknews2.autodesk.com...
> > > > > > I've not attempted this Serge, so I don't know if it will work.
But
> > in
> > > > > > normal AutoCAD, you can redefine a block by just inserting a
file
> > with
> > > > the
> > > > > > same name as an existing block. Have you tried using the
InsertBlock
> > > > > method
> > > > > > with an updated version of the file that created your block in
the
> > > first
> > > > > > place?
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
>
> --
> /*********************************************************/
> /* Tony Tanzillo Design Automation Consulting */
> /* Programming & Customization for AutoCAD & Compatibles */
> /* ----------------------------------------------------- */
> /* tony.tanzillo@worldnet.att.net */
> /* http://ourworld.compuserve.com/homepages/tonyt */
> /*********************************************************/
0 Likes
Message 12 of 12

Anonymous
Not applicable
Toni,
Is the AcVbExt extension compatible with A2K ?
I've found the AcadX extension on your web site, but it doesn't provide the
DefineBlock method.
Do you consider that it's no more useful since it is possible to update
blocks by inserting and deleting them ?

Tony Tanzillo a écrit dans le message :
389B84BF.A728F2CC@worldnet.att.net...
> You don't have to compare strings. The Block object has
> an IsLayout property that returns True if the block is
> a layout.
0 Likes