CopyObjects function problem

CopyObjects function problem

Anonymous
Not applicable
1,157 Views
6 Replies
Message 1 of 7

CopyObjects function problem

Anonymous
Not applicable
Hello, is there anybody in there?

Function, which should create new layout, a copy of available layout, in one
document, written on C#:
================
private void layout_new(String strFrom, String strTo,
Autodesk.AutoCAD.Interop.AcadDocument doc)
{
Autodesk.AutoCAD.Interop.Common.AcadLayout objLayOut;
Autodesk.AutoCAD.Interop.Common.AcadLayout objNewLayOut;

objNewLayOut = doc.Layouts.Add(strTo);
objLayOut=colLayOuts.Item(strFrom);
object[] objEntArray = new object[objLayOut.Block.Count];
int intCnt = 0;

foreach (Autodesk.AutoCAD.Interop.Common.AcadObject objEnt in
objLayOut.Block)
{
objEntArray[intCnt] = objEnt;
intCnt=intCnt+1;
}

try
{
doc.CopyObjects(objEntArray[1], objNewLayOut.Block,
ref missing);
objNewLayOut.CopyFrom((Autodesk.AutoCAD.Interop.Common.AcadPlotConfiguration)objLayOut);
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.ToString());
}

}
================


Gives out a COMException (0x8021007B) "Incorrect file of objects"
at line "doc.CopyObjects(objEntArray[1], objNewLayOut.Block, ref missing);"

Prompt, please, in what there can be a problem?
Beforehand thanks!


Wish you were here, All!
np: Jimmy Page - Liquid Mercury
0 Likes
1,158 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
Hello, is there anybody in there?

Artem Shutov to All × Wed, 24 May 2006 07:29:15 +0000:

... _missing_ ...

AS> doc.CopyObjects(objEntArray[1],
objNewLayOut.Block,
AS> ref missing);

Sorry , mean doc.CopyObjects(objEntArray, objNewLayOut.Block, ref
missing);

and:

AS> Gives out a COMException (0x8021007B) "Incorrect array of objects"

... _missing_ ...

Wish you were here, Artem!
np: Jimmy Page & Robert Plant - Shining In The Light
0 Likes
Message 3 of 7

Anonymous
Not applicable
Try this code:
[code]
private static void DuplicateLayout(String strFrom, String strTo,
Autodesk.AutoCAD.Interop.AcadDocument doc)
{
Autodesk.AutoCAD.Interop.Common.AcadLayout objLayOut = null;
Autodesk.AutoCAD.Interop.Common.AcadLayout objNewLayOut = null;

try
{
objLayOut = doc.Layouts.Item(strFrom);
objNewLayOut = doc.Layouts.Item(strTo);
}
catch (System.Exception)
{
objNewLayOut = doc.Layouts.Add(strTo);
}

if (objLayOut != null && objNewLayOut != null)
{
Object missing = Type.Missing;
try
{
Autodesk.AutoCAD.Interop.Common.AcadEntity[] blks =
new Autodesk.AutoCAD.Interop.Common.AcadEntity[objLayOut.Block.Count];
for (int j=0; j < blks.Length; j++) {
blks = objLayOut.Block.Item(j);
}
doc.Database.CopyObjects(blks, objNewLayOut.Block, ref missing);
objNewLayOut.CopyFrom((Autodesk.AutoCAD.Interop.Common.AcadPlotConfiguration)objLayOut);
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.ToString());
}
}
}
[/code]
0 Likes
Message 4 of 7

Anonymous
Not applicable
Hello, is there anybody in there?

Alexander Rivilis at Wed, 24 May 2006 23:23:25 +0000:

AR> Try this code:
AR> [code]

... _ÐÒÏÐÕÝÅÎÏ_ ...

AR> [/code]

Many thanks!
It works!

Wish you were here, Alexander!
np: John Mayall - What'd I Say
0 Likes
Message 5 of 7

Anonymous
Not applicable
In which dll do I find Autodesk.AutoCAD.Interop.Common?
0 Likes
Message 6 of 7

Anonymous
Not applicable
Add Reference > COM Tab > AutoCAD 200? Type Library.

Regards - Nathan
0 Likes
Message 7 of 7

Anonymous
Not applicable
Ok, I got an exclamation mark on the added AutoCad refference in Visual Studio.

Do you know how it can be that?
0 Likes