Article | 70002189 |
Type | Wish |
Product | Engine |
Version | 9003 |
Date Added | 4/1/2022 12:00:00 AM |
Fixed | 10.1001.0.1 (4/1/2022 12:00:00 AM) |
Submitted by | Wayne Romer |
Summary
Move Model entities to an other Document with out clone to new instances
Solution
In version 1001.0.1 we modify VDF so it can move Model entities from one document to an other with out need to clone into new instances
See following example
//create a new temporary document that will be used to open an existing file VectorDraw.Professional.Components.vdDocumentComponent dc = new VectorDraw.Professional.Components.vdDocumentComponent(); object nfile = dc.Document.GetOpenFileNameDlg(0, "", 0);//select an existing file if (nfile == null) return; //open the existing file from the temporary document if (!dc.Document.Open(nfile.ToString())) return; vdDocument todocument = doc; vdDocument fromdocument = dc.Document; //set the destination document to be able to recover duplicate object handles vdDocument.OpenFlagsEnum openflag = todocument.Openflags; todocument.Openflags |= vdDocument.OpenFlagsEnum.RecoverAll; //enumerate all source document model entities and move each one to the destination document model entities do { //begin from the last in the collection to the first one vdFigure fig = fromdocument.Model.Entities.Last; if (fig == null) break; //remove the entity from the source model fromdocument.Model.Entities.RemoveItem(fig); fig.SetUnRegisterDocument(null); //add the object instance to the destination model entities todocument.Model.Entities.AddItem(fig); //keep the source Guid handle of the source document to the destination if it is possible. if (todocument.FileProperties.UseGuidHandleTable) todocument.HandleTableGuid.SetObjectGuid(fig, fromdocument.HandleTableGuid.GetObjectGuid(fig)); //keep the source object handle of the source document to the destination if it is possible. todocument.RegisterObjectHandle(fig, null); } while (fromdocument.Model.Entities.Count > 0); todocument.Openflags = openflag; //dispose and clear the memory from the temporary source document dc.Dispose(); dc = null; //do a redraw to see the results doc.ZoomExtents(); doc.Redraw(true);