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

CopyObjects function problem

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
646 Views, 6 Replies

CopyObjects function problem

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
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

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
Message 3 of 7
Anonymous
in reply to: Anonymous

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]
Message 4 of 7
Anonymous
in reply to: Anonymous

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
Message 5 of 7
d00_ape
in reply to: Anonymous

In which dll do I find Autodesk.AutoCAD.Interop.Common?
Message 6 of 7
NathTay
in reply to: Anonymous

Add Reference > COM Tab > AutoCAD 200? Type Library.

Regards - Nathan
Message 7 of 7
d00_ape
in reply to: Anonymous

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

Do you know how it can be that?

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