Dynamo.Graph.Workspaces.WorkspaceModel.Clear C# (CSharp) Method

Clear() public method

Clears this workspace of nodes, notes, and connectors.
public Clear ( ) : void
return void
        public virtual void Clear()
        {
            workspaceLoaded = false;
            Log(Resources.ClearingWorkSpace);

            DynamoSelection.Instance.ClearSelection();

            // The deletion of connectors in the following step will trigger a
            // lot of graph executions. As connectors are deleted, nodes will
            // have invalid inputs, so these executions are meaningless and may
            // cause invalid GC. See comments in MAGN-7229.
            foreach (NodeModel node in Nodes)
                node.RaisesModificationEvents = false;

            foreach (NodeModel el in Nodes)
            {
                el.Dispose();

                foreach (PortModel p in el.InPorts)
                {
                    for (int i = p.Connectors.Count - 1; i >= 0; i--)
                        p.Connectors[i].Delete();
                }
                foreach (PortModel port in el.OutPorts)
                {
                    for (int i = port.Connectors.Count - 1; i >= 0; i--)
                        port.Connectors[i].Delete();
                }
            }

            ClearNodes();
            ClearNotes();
            ClearAnnotations();
            presets.Clear();

            ClearUndoRecorder();
            ResetWorkspace();

            X = 0.0;
            Y = 0.0;
            Zoom = 1.0;
            // Reset the workspace offset
            OnCurrentOffsetChanged(this, new PointEventArgs(new Point2D(X, Y)));
            workspaceLoaded = true;
        }
WorkspaceModel