How to add a reference line

How to add a reference line to the canvas? A reference line is required after the element is dragged to the canvas

Do you mean something like Guided Dragging ?
When you copy the extension into your project you can adapt the code to meet your requirements.

If something else, what?

Yes, is there a reference line for the entire canvas like this

OK, so it’s not a guideline that you want. What is the purpose of that line? How is it used? What is its lifetime? Does it ever change, and if so, how and when?

This is the guide I want. I also want to add such a central axis (vertical and central) on this basis,

Appears when the element moves to the horizontal and vertical center, and disappears when it moves away

Yes, the GuidedDraggingTool is designed to look for nearby Parts by which to align the dragged Part. And now I see how you want to align to something larger.

However it isn’t clear what you are aligning to. The viewport? But that will change as the user scrolls or zooms. The document? But I don’t see any other Parts in your screenshot, so if the dragged node is the only node, the Diagram.documentBounds will just follow the dragged node’s actualBounds.