.NET

Reply
*Roland Feletic
Message 1 of 6 (356 Views)

DeepClone BlockReference

356 Views, 5 Replies
11-18-2008 08:23 AM

I want to make a copy of
some BlockReferences, they can be dynamic therefor I have to use
DeepClone. When I try it with something like the following code nothing
happens. I think the problem is the currSpace. What should be instead for the
ownerPointer?

 

{code}


DBObject
tmpOriginalEntity = (
Entity
size=2>)myT.GetObject(objId,

size=2>OpenMode
.ForWrite);


BlockReference
tmpOriginalBlock = tmpOriginalEntity

size=2>as

size=2>BlockReference
;


if (tmpOriginalBlock !=
null)


{


    IdMapping
size=2> idMap =
new
IdMapping
size=2>();


    DBObject
size=2> currSpace = (
DBObject
size=2>)myT.GetObject(db.CurrentSpaceId,

size=2>OpenMode
.ForWrite);


    DBObject
size=2> tmpnewBlockRef = tmpOriginalBlock.DeepClone(currSpace, idMap,
false);


}


{code}
Active Member
Roland_Feletic
Posts: 8
Registered: ‎10-09-2006
Message 2 of 6 (355 Views)

Re: DeepClone BlockReference

11-18-2008 08:28 AM in reply to: *Roland Feletic
Again without formating:


DBObject tmpOriginalEntity = (Entity)myT.GetObject(objId, OpenMode.ForWrite);

BlockReference tmpOriginalBlock = tmpOriginalEntity as BlockReference;

if (tmpOriginalBlock != null)

{

IdMapping idMap = new IdMapping();

DBObject currSpace = (DBObject)myT.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);

DBObject tmpnewBlockRef = tmpOriginalBlock.DeepClone(currSpace, idMap, false);

} Edited by: feletic@pauser.at on Nov 18, 2008 5:29 PM
*Tony Tanzillo
Message 3 of 6 (355 Views)

Re: DeepClone BlockReference

11-18-2008 11:50 AM in reply to: *Roland Feletic

You dont call DeepClone on a DBObject, you call
the

DeepCloneObjects method of the Database.


 

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000
through 2009

href="http://www.acadxtabs.com">http://www.acadxtabs.com

 


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Roland Feletic" <feletic_at_pauser_dot_at> wrote in message
href="news:6074184@discussion.autodesk.com">news:6074184@discussion.autodesk.com
...


I want to make a copy of
some BlockReferences, they can be dynamic therefor I have to
use DeepClone. When I try it with something like the following code
nothing happens. I think the problem is the currSpace. What should be instead
for the ownerPointer?

 

{code}


DBObject
tmpOriginalEntity = (
Entity
size=2>)myT.GetObject(objId,

size=2>OpenMode
.ForWrite);


BlockReference
tmpOriginalBlock = tmpOriginalEntity

size=2>as

size=2>BlockReference
;


size=2>

if (tmpOriginalBlock
!=
null)


{


    IdMapping
size=2> idMap =
new
IdMapping
size=2>();


    DBObject
size=2> currSpace = (
DBObject
size=2>)myT.GetObject(db.CurrentSpaceId,

size=2>OpenMode
.ForWrite);


    DBObject
size=2> tmpnewBlockRef = tmpOriginalBlock.DeepClone(currSpace, idMap,
false);


}



size=2>{code}
*Roland Feletic
Message 4 of 6 (355 Views)

Re: DeepClone BlockReference

11-19-2008 01:27 AM in reply to: *Roland Feletic

Thank you, Tony.

Now I did it like the following code and it works.
But may I ask you one question. When do I use DeepClone?

 


IdMapping
size=2> idMap =
new
IdMapping

face=Arial>();



size=2>ObjectIdCollection
entityCollection =
color=#0000ff size=2>new

size=2>ObjectIdCollection

face=Arial>();


entityCollection.Add(objId);


db.DeepCloneObjects(entityCollection, db.CurrentSpaceId,
idMap,


size=2>false
);


 



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


You dont call DeepClone on a DBObject, you call
the

DeepCloneObjects method of the Database.


 

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000
through 2009

href="http://www.acadxtabs.com">http://www.acadxtabs.com

 


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Roland Feletic" <feletic_at_pauser_dot_at> wrote in message
href="news:6074184@discussion.autodesk.com">news:6074184@discussion.autodesk.com
...


I want to make a copy of
some BlockReferences, they can be dynamic therefor I have to
use DeepClone. When I try it with something like the following code
nothing happens. I think the problem is the currSpace. What should be
instead for the ownerPointer?

 

{code}


DBObject
tmpOriginalEntity = (
Entity
size=2>)myT.GetObject(objId,

size=2>OpenMode
.ForWrite);


BlockReference
tmpOriginalBlock = tmpOriginalEntity

size=2>as

size=2>BlockReference
;


size=2>

if
(tmpOriginalBlock !=
null
size=2>)


{


   
IdMapping
idMap =
size=2>new

size=2>IdMapping
();


    DBObject
size=2> currSpace = (
DBObject
size=2>)myT.GetObject(db.CurrentSpaceId,

size=2>OpenMode
.ForWrite);


    DBObject
size=2> tmpnewBlockRef = tmpOriginalBlock.DeepClone(currSpace, idMap,
false);


}



size=2>{code}
*Tony Tanzillo
Message 5 of 6 (355 Views)

Re: DeepClone BlockReference

11-19-2008 10:17 PM in reply to: *Roland Feletic

You don't use DeepClone().

 

The DeepCloneObjects() method calls it (or its native
counterpart)

as part of the cloning process.

 


 

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000
through 2009

href="http://www.acadxtabs.com">http://www.acadxtabs.com

 


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Roland Feletic" <feletic_at_pauser_dot_at> wrote in message
href="news:6074895@discussion.autodesk.com">news:6074895@discussion.autodesk.com
...


Thank you, Tony.

Now I did it like the following code and it
works. But may I ask you one question. When do I use DeepClone?

 


IdMapping
size=2> idMap =
new
IdMapping

face=Arial>();



size=2>ObjectIdCollection
entityCollection =
color=#0000ff size=2>new

size=2>ObjectIdCollection

face=Arial>();


entityCollection.Add(objId);


db.DeepCloneObjects(entityCollection, db.CurrentSpaceId,
idMap,


size=2>false
);


 



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


You dont call DeepClone on a DBObject, you call
the

DeepCloneObjects method of the Database.


 

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD
2000 through 2009

href="http://www.acadxtabs.com">http://www.acadxtabs.com

 


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Roland Feletic" <feletic_at_pauser_dot_at> wrote in message
href="news:6074184@discussion.autodesk.com">news:6074184@discussion.autodesk.com
...


I want to make a copy of
some BlockReferences, they can be dynamic therefor I
have to use DeepClone. When I try it with something like the
following code nothing happens. I think the problem is the currSpace. What
should be instead for the ownerPointer?

 

{code}


DBObject
tmpOriginalEntity = (
Entity
size=2>)myT.GetObject(objId,

size=2>OpenMode
.ForWrite);


BlockReference
tmpOriginalBlock = tmpOriginalEntity

size=2>as

size=2>BlockReference
;


size=2>

if
(tmpOriginalBlock !=
null
size=2>)


{


   
IdMapping
idMap =
size=2>new

size=2>IdMapping
();


   
DBObject
currSpace = (
size=2>DBObject
)myT.GetObject(db.CurrentSpaceId,
OpenMode
size=2>.ForWrite);


   
DBObject
tmpnewBlockRef =
tmpOriginalBlock.DeepClone(currSpace, idMap,

size=2>false
);


}



size=2>{code}
*Roland Feletic
Message 6 of 6 (355 Views)

Re: DeepClone BlockReference

11-20-2008 03:01 AM in reply to: *Roland Feletic

Thank you.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


You don't use DeepClone().

 

The DeepCloneObjects() method calls it (or its native
counterpart)

as part of the cloning process.

 


 

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000
through 2009

href="http://www.acadxtabs.com">http://www.acadxtabs.com

 


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Roland Feletic" <feletic_at_pauser_dot_at> wrote in message
href="news:6074895@discussion.autodesk.com">news:6074895@discussion.autodesk.com
...


Thank you, Tony.

Now I did it like the following code and it
works. But may I ask you one question. When do I use DeepClone?

 


IdMapping
size=2> idMap =
new
IdMapping

face=Arial>();



size=2>ObjectIdCollection
entityCollection =
new
color=#2b91af size=2>ObjectIdCollection

face=Arial>();


entityCollection.Add(objId);


db.DeepCloneObjects(entityCollection, db.CurrentSpaceId,
idMap,


size=2>false
);


 



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


You dont call DeepClone on a DBObject, you call
the

DeepCloneObjects method of the Database.


 

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD
2000 through 2009

href="http://www.acadxtabs.com">http://www.acadxtabs.com

 


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Roland Feletic" <feletic_at_pauser_dot_at> wrote in message

href="news:6074184@discussion.autodesk.com">news:6074184@discussion.autodesk.com
...


I want to make a copy of
some BlockReferences, they can be dynamic therefor I
have to use DeepClone. When I try it with something like the
following code nothing happens. I think the problem is the currSpace.
What should be instead for the ownerPointer?

 

{code}


DBObject
tmpOriginalEntity = (

size=2>Entity
)myT.GetObject(objId,
color=#2b91af size=2>OpenMode
.ForWrite);


BlockReference
tmpOriginalBlock = tmpOriginalEntity

size=2>as

size=2>BlockReference
;


size=2>

if
(tmpOriginalBlock !=
null
size=2>)


{


   
IdMapping
idMap =
size=2>new

size=2>IdMapping
();


   
DBObject
currSpace = (
size=2>DBObject
)myT.GetObject(db.CurrentSpaceId,
OpenMode
size=2>.ForWrite);


   
DBObject
tmpnewBlockRef =
tmpOriginalBlock.DeepClone(currSpace, idMap,

size=2>false
);


}



size=2>{code}
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.