.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Newbie question n.1

4 REPLIES 4
Reply
Message 1 of 5
cabbi
325 Views, 4 Replies

Newbie question n.1

Hi all,

I've to compose a new dwg file from a series of blocks in some other dwg files. I'm completely new to AutoCAD (but a C# programmer) so, I need some clue on how to do this in C#.

Looking on this discussion group I wrote this method and it works fine:

public static AcadBlock CopyBlock(AcadBlock sourceBlock, AcadDocument sourceDoc, AcadDocument destDoc)
{
AcadBlock[] newBlocks = {sourceBlock};
Object idPairs = new Object();
sourceDoc.CopyObjects(newBlocks, destDoc.Blocks, ref idPairs);
return destDoc.Blocks.Item(sourceBlock.Name);
}

but the new block on the source document is not visible. I have to edit it manaully and change something on it to get it showed!

What am I missing???

TIA,
Cabbi
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: cabbi

http://through-the-interface.typepad.com/through_the_interface/2006/08/import_blocks_f.html


wrote in message news:5520638@discussion.autodesk.com...
Hi all,

I've to compose a new dwg file from a series of blocks in some other dwg
files. I'm completely new to AutoCAD (but a C# programmer) so, I need some
clue on how to do this in C#.

Looking on this discussion group I wrote this method and it works fine:

public static AcadBlock CopyBlock(AcadBlock sourceBlock, AcadDocument
sourceDoc, AcadDocument destDoc)
{
AcadBlock[] newBlocks = {sourceBlock};
Object idPairs = new Object();
sourceDoc.CopyObjects(newBlocks, destDoc.Blocks, ref idPairs);
return destDoc.Blocks.Item(sourceBlock.Name);
}

but the new block on the source document is not visible. I have to edit it
manaully and change something on it to get it showed!

What am I missing???

TIA,
Cabbi
Message 3 of 5
cabbi
in reply to: cabbi

Nice tip!

As far as I discovered in my few days in vaste AutoCAD world, I can control the AutoCAD with .NET in two different manners:
1. from an external .NET application using 'AutoDesk.AutoCAD.Iterop'
2. from inside AutoCAD by generatin a DLL using
'Autodesk.AutoCAD.ApplicationServices'
'Autodesk.AutoCAD.DatabaseServices'
... (and so on)

So my question was focused on the first way!

But I'm wandering if the 1. option gives the same all functionalities as option 2., did it?

Cabbi
Message 4 of 5
cabbi
in reply to: cabbi

I think I got the point:CopyObjects will only copy the block definition, so I need to add this block to the document's ModelSpace:

destDoc.ModelSpace.InsertBlock(....);

and if the result shloud be diplayed immediatly:

destDoc.Regen(...);

Any comments?
Something more missing?

Cabbi
Message 5 of 5
Anonymous
in reply to: cabbi

Method #1 is using the ActiveX/Automation API which is *not* the topic of
this newsgroup. This newsgroup is about method #2 which uses the .NET API
(or wrappers) which are (mostly) built on top of the native C++ ObjectARX
API.

Generally speaking, the ActiveX API is (much!) more limited than the C++
and/or .NET API. However, some tasks may be easier to accomplish
(less/simplier code) with the ActiveX API. Most people will also find the
.NET API (and C#/VB.NET) easier than coding to ObjectARX with C++.

Finally, it can be easier to use the exact same ActiveX API code/binary with
multiple versions of AutoCAD; this can be difficult (at best) using either
the .NET APIs or ObjectARX.

Dan

wrote in message news:5523953@discussion.autodesk.com...
Nice tip!

As far as I discovered in my few days in vaste AutoCAD world, I can control
the AutoCAD with .NET in two different manners:
1. from an external .NET application using 'AutoDesk.AutoCAD.Iterop'
2. from inside AutoCAD by generatin a DLL using
'Autodesk.AutoCAD.ApplicationServices'
'Autodesk.AutoCAD.DatabaseServices'
... (and so on)

So my question was focused on the first way!

But I'm wandering if the 1. option gives the same all functionalities as
option 2., did it?

Cabbi

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost