Table of Contents

CadRemoteServer

from OpenCAD2D import CadRemoteServer

class CadRemoteServer(System.Object) ยท CadRemoteServer in the .NET reference

The multileader styles and table styles of a drawing, read from outside.

Writing objects: the queued inserts, modifies and deletes of a client, applied as one undo step.

The side of the remote channel that lives in the app: it listens on a named pipe for the programs that drive the app (CadApplication of OpenCAD2D.Remote), announces itself in a file so that they find it, and answers each request on the thread of the drawings through the dispatcher it is given. It has no UI and is started by the app's host; where nothing starts it, nothing listens.

The whole drawing as the app has it now, asked from outside: for a program that draws or checks it in its own process.

What a program that debugs the app asks: the picture of its canvas, a drawing's command line, and what went wrong in it.

The drawing as JSON and as a graph, answered to a program that reads drawings.

feed of the channel of the tools: a command run inside the run, with the answers its prompts are given, as AutoLISP's command does it (the command is nested in the run's own, silently, so the run keeps its one undo step and its Esc).

The edits a client asks the core to make in one call, and the objects it answers a command's prompt with.

What a thing would take before it is added, the empty places of a frame, and whether a candidate fits, asked from outside.

The members of a request read strictly: one that is there and of the wrong kind is refused in words that name it, where the lenient GetDouble and GetString would take it for the fallback.

Reading objects: by handle, by filter, and the packing of them into the small drawing they travel in.

Waiting for the user to pick a point or objects in a drawing, on the drawing's own command line.

The Properties palette, the selection by where things are drawn, and LIST, asked from outside.

The table records a commit adds, the linetypes of a drawing and its current dimension style, from outside.

The requests the server answers.

The channel of the tools: a second server of the app that a program started by the app (a Python tool) drives, with the requests of a run on top of the ordinary ones. A run is the command the user typed, held open by the app while the tool works: its questions are asked on the drawing's command line, its commits are in the command's one undo step, and Esc ends it with every change taken back.

The sheets of a drawing, made and set up from outside: layouts, their page setup and their viewports.

A drawing kept as it stands and put back to it, asked from outside: for a program that runs episodes of edits in the app.

The boxes of the entities as they are drawn and the overlaps of their words, asked from outside.

A drawing checked against a drawing standard, asked from outside.

The text styles, dimension styles and blocks of a drawing, read from outside.

The layouts, linetypes and block summaries of a drawing, read from outside without copying the drawing.

The layers and the layouts of a drawing, read and set from outside.

The view, the named views, the system variables and the selection by area: the calls of a drawing's CadEditor from outside.

Constructors

__init__

.NET

def __init__(self, host: ICadRemoteHost, dispatcher: ICadRemoteDispatcher) -> None

Makes a server for an app; nothing listens until CadRemoteServer.Start.

Properties and fields

IsRunning

.NET

@property
def IsRunning(self) -> bool

Gets whether the server is listening.

PipeName

.NET

@property
def PipeName(self) -> str

Gets the name of the pipe the server listens on.

Methods

CreateRunCommand

.NET

def CreateRunCommand(
    self,
    name: str,
    usesSelection: bool,
    token: str,
    started: System.Action[CadRemoteToolRun],
) -> CadCommand

Makes the command of a tool, to put in the app's registry under the name the user types. The command is the run: it begins an undo step named after it, calls started so that the app can tell the tool, and then waits at NAME is working... (Esc to stop) while the tool asks its questions, commits and ends it (ask, commit, end, fail of the channel). The step is kept when the tool ends it well and taken back when it fails or Esc ends it, and the drawing is busy for every other command until then.

Dispose

.NET

def Dispose(self) -> None

Stops the server.

ForTools

.NET

@staticmethod
def ForTools(host: ICadRemoteHost, dispatcher: ICadRemoteDispatcher) -> CadRemoteServer

Makes the server of the tools of an app: the pipe OpenCAD2D.<process id>.tools, never announced in the instance folder, open whether or not the app allows other programs to connect, and taking a client only with a token CadRemoteServer.IssueToken gave. Call CadRemoteServer.Start on the thread of the drawings, as for the app's own server.

IssueToken

.NET

def IssueToken(self) -> str

Gives a tool the token it connects with: 32 random bytes as 64 hexadecimal letters. A token is good until CadRemoteServer.RevokeToken; the app gives each tool process its own and takes it back when the process ends.

NoteActivated

.NET

def NoteActivated(self) -> None

Writes the instance file again with the window's title and the time now as the time the app was last activated. The host calls it when the user activates the window, on the thread of the drawings.

NoteTitleChanged

.NET

def NoteTitleChanged(self) -> None

Writes the instance file again with the window's title as it is now, and the time the app was last activated as it was: the title of a window that opens its drawing after the server starts, or a drawing saved under another name, is not the one announced at the start, and a program that lists the apps reads it. The host calls it when its title changes, on the thread of the drawings.

RevokeToken

.NET

def RevokeToken(self, token: str) -> None

Takes a token back: the connections that carry it are refused at their next request and closed, and no new hello takes it. Does nothing for a token the server does not know.

Start

.NET

def Start(self) -> None

Opens the pipe, writes the instance file and starts listening. Call it on the thread of the drawings: it reads the window's title.

Stop

.NET

def Stop(self) -> None

Stops listening, closes the connections and deletes the instance file. Calling it again does nothing.

Operators and Python protocols

__enter__

def __enter__(self) -> Self

__exit__

def __exit__(self, *args: object) -> None