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

DeepClone BlockReference

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
1097 Views, 5 Replies

DeepClone BlockReference


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

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


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


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


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


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}

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