HowTo : Coping entities from one document in to another
| Article | 60000410 |
| Type | HowTo |
| Product | Engine |
| Version | 6 |
| Date Added | 2/5/2008 |
| Submitted by | Igor Gegusin |
| Keywords | |
Subject
Coping entities from one document in to another
Summary
How can I copy some entities from one control to another ?
Solution
Using the VDF Prof. 6.x Wrapper or the VDProControl (vdraw.ocx/vdprocontrol.dll) you can try a code like :
Private Sub copy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles copy.Click
Dim coloritem As VectorDraw.Professional.vdObjects.vdColor
Dim cadfig As vdFigure
Dim selset As vdSelection
Dim docfrom As VectorDraw.Professional.vdObjects.vdDocument
Dim docto As VectorDraw.Professional.vdObjects.vdDocument
vdto.ActiveDocument.New()
vdfrom.ActiveDocument.Open(Application.StartupPath() + "\PD-23-from.vdi", 0, 0)
vdfrom.CommandAction.Zoom("e", 0, 0)
''create a temporary selection to add the entities you want to copy in destination document
selset = vdfrom.ActiveDocument.Selections.Add("tmpCopy")
selset.RemoveAll()
For Each cadfig In vdfrom.ActiveDocument.Entities
If cadfig.Visible = False Then Continue For
selset.AddItem(cadfig)
Next
''get the the VectorDraw FrameWork document objects.
docfrom = vdfrom.ActiveDocument.WrapperObject
docto = vdto.ActiveDocument.WrapperObject
''disable the undo write in destination document
docto.UndoHistory.PushEnable(False)
''Use the MergeSelection to copy the entites and table dependecies from source to destination document
docto.MergeSelection(selset.WrapperObject)
''Set the pallete and backround colors of destination same as the source document
docto.Palette.Background = docfrom.Palette.Background
docto.Palette.Forground = docfrom.Palette.Forground
docto.Palette.RemoveAll()
For Each coloritem In docfrom.Palette
docto.Palette.AddItem(coloritem.Clone())
Next
docto.Model.BkColorEx = docfrom.ActiveLayOut.BkColorEx
''pop back the undo mode of the destination to its original value.
docto.UndoHistory.PopEnable()
vdto.CommandAction.Zoom("e", 0, 0)
vdto.ActiveDocument.SaveAs(Application.StartupPath() + "\PD-23-to.vdi", VdConstFileVer.DefaultVersion)
End SubThe two VD controls are name vdfrom and vdto.