VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to add AcadEntity to an AcadBlockReference

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
1149 Views, 7 Replies

How to add AcadEntity to an AcadBlockReference

I have an image (AcadRasterImage) that is already existing in the drawing
and stored in the variable ImageName (of type AcadRasterImage)

How do I add this to AcadBlockReference make a block out of the image?

The AddRaster method that I see allows only a new image to be created and
added to a AcadBlockReference but what I need it to add an existing image
(or for that matter, any object) to a Blockreference.

Any pointers?

Any help is apperciated.

Thanks in advance
Rakesh
7 REPLIES 7
Message 2 of 8
Bryco
in reply to: Anonymous

.AddRaster works for blocks, an image is a bit like an xref, it needs a path imagefile property will give you that. Now if you are trying to add a wipeout that is a different thing, you need to use asdkunsupp2000.arx or asdkunsupp2004.arx, they are available from this site.
Message 3 of 8
Anonymous
in reply to: Anonymous

To add to an entity to an existing block
use the "CopyObjects" method.

[code]
Dim image As AcadRasterImage
Dim pp, min, max
ThisDrawing.Utility.GetEntity image, pp
image.GetBoundingBox min, max

Dim blk As AcadBlock
Set blk = ThisDrawing.Blocks.Add(min, image.Handle)

Dim ent(0) As AcadEntity
Set ent(0) = image
Dim ret
ret = ThisDrawing.CopyObjects(ent, ThisDrawing.Blocks(image.Handle))

Dim blkRef As AcadBlockReference
Set blkRef = ThisDrawing.ModelSpace.InsertBlock(min, image.Handle, 1, 1,
1, 0)
image.Delete
[/code]

--
gl - Paul
"Rakesh Rao" wrote in message
news:5188477@discussion.autodesk.com...
I have an image (AcadRasterImage) that is already existing in the drawing
and stored in the variable ImageName (of type AcadRasterImage)

How do I add this to AcadBlockReference make a block out of the image?

The AddRaster method that I see allows only a new image to be created and
added to a AcadBlockReference but what I need it to add an existing image
(or for that matter, any object) to a Blockreference.

Any pointers?

Any help is apperciated.

Thanks in advance
Rakesh
Message 4 of 8
Anonymous
in reply to: Anonymous

Thanks, will try that.


"Paul Richardson" wrote in message
news:5188545@discussion.autodesk.com...
To add to an entity to an existing block
use the "CopyObjects" method.

[code]
Dim image As AcadRasterImage
Dim pp, min, max
ThisDrawing.Utility.GetEntity image, pp
image.GetBoundingBox min, max

Dim blk As AcadBlock
Set blk = ThisDrawing.Blocks.Add(min, image.Handle)

Dim ent(0) As AcadEntity
Set ent(0) = image
Dim ret
ret = ThisDrawing.CopyObjects(ent, ThisDrawing.Blocks(image.Handle))

Dim blkRef As AcadBlockReference
Set blkRef = ThisDrawing.ModelSpace.InsertBlock(min, image.Handle, 1, 1,
1, 0)
image.Delete
[/code]

--
gl - Paul
"Rakesh Rao" wrote in message
news:5188477@discussion.autodesk.com...
I have an image (AcadRasterImage) that is already existing in the drawing
and stored in the variable ImageName (of type AcadRasterImage)

How do I add this to AcadBlockReference make a block out of the image?

The AddRaster method that I see allows only a new image to be created and
added to a AcadBlockReference but what I need it to add an existing image
(or for that matter, any object) to a Blockreference.

Any pointers?

Any help is apperciated.

Thanks in advance
Rakesh
Message 5 of 8
Bryco
in reply to: Anonymous

Both .addraster and CopyObjects work but only copyobjects can add the wipeout, thanks for that Paul, nice trick
Message 6 of 8
Bryco
in reply to: Anonymous

On another note, manually it seems in acad 2006 you can't add a raster to an existing block. You can make a block of the raster or the raster and other objects. In these 2 conditions and in both vba conditions the block cannot be refedited. Manually, I found the best way was to make a block of the raster then insert that into the block. Below is the error message displayed when refediting. Perhaps there is a patch for this?
Errors found in references to other objects:
** Object reference missing: AcDbRasterImage, to AcDbRasterImageDef.
Message 7 of 8
Anonymous
in reply to: Anonymous

I just tried that...strange..
Message 8 of 8
Cad_Monkey
in reply to: Anonymous

> {quote:title=brycewalmsley8287 wrote:}{quote}
> Manually, I found the best way was to make a block of the raster then insert that into the block. Below is the error message displayed when refediting.

That was great advice, worked like a charm for me

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost