70001993 How can I move objects from one layout to another

Article 70001993
Type HowTo
Product Engine
Version 9
Date Added 6/8/2021 12:00:00 AM
Fixed 9.9002.0.3 (6/8/2021 12:00:00 AM)
Submitted by hicom tech


How can I move objects from one layout to another


You can use the Clone() method to clone the entities of the active layout and then add these cloned items to the other layout, and setting original entities to Deleted. See this code that moves all vdLine objects of the model to a new layout named “test”:

        private void button1_Click(object sender, EventArgs e)
            doc = vdFramedControl1.BaseControl.ActiveDocument; // make sure that this document contains some vdLine objects
            vdLayout lay = new vdLayout(doc, "test"); // create and add a new layout
            lay.SetUnRegisterDocument(doc); lay.setDocumentDefaults();

            foreach (vdFigure item in doc.Model.Entities) // check all objects of the Model
                if (item is vdLine) // and if it is vdLine
                    vdFigure fig = item.Clone(doc) as vdFigure; // clone the object
                    lay.Entities.AddItem(fig); // add this to the new layout
                    item.Deleted = true;// delete the model’s line

Send comments on this topic.