Class CadRemoteDocument
The multileader styles and table styles of a drawing.
public sealed class CadRemoteDocument
- Inheritance
-
CadRemoteDocument
- Inherited Members
Remarks
Reads are live: GetObject(string), GetObjects(CadObjectFilter) and GetSelectedObjects() ask the app now,
and give the library's own entities (DxfLine, DxfMText, DxfBlockReference...) made from the DXF text
of the objects. They are copies: changing one changes nothing in the app until Modify(DxfEntity) and
CommitChanges(). The Handle of such a copy is its handle in the copy's own small drawing; the handle
in the app's drawing is HandleOf(DxfEntity).
Writes are queued: Insert(DxfEntity, string), Modify(DxfEntity), Delete(string), AddLayer(CadRemoteLayer) and ModifyLayer(CadRemoteLayer) keep what they were given as it is at the call, and CommitChanges() sends them all and the app applies them as one undo step with the canvas drawn again: the layers first, then the objects in the order they were queued, so that an object can be put on a layer made in the same step. If the app refuses any of them (the owner of an object does not take the change, a block is missing from the drawing) nothing is applied, CommitChanges() throws with the reason and the queue is empty.
The user's picks (PickPoint(string, GeoPoint3?, TimeSpan?), PickObjects(string, TimeSpan?), PickObject(string, TimeSpan?)) wait for the user at the app's command line and canvas; the layers and layouts have their own members (Layers, CurrentLayer, Layouts, CurrentLayout).
An object inserted is not in the drawing until the commit, so Insert(DxfEntity, string) returns a ticket such as
~1 instead of its handle. A ticket stands for the object in GetObject(string), Delete(string)
and Select(IEnumerable<string>) once the commit is done, and CommitChanges() returns the real handles.
Properties
- Blocks
Gets the blocks of the drawing with their objects, sorted by name without regard to case, then by ordinal order, as the Block manager lists them: the blocks of the layouts (
*Model_Space,*Paper_Space) and those AutoCAD names itself (*D1,*U1) are left out. An external reference attached and loaded brings the blocks of its drawing as AutoCAD lists them,grid|TAGfor the block TAG ofgrid, each with IsDependent true and its objects the drawing's own. They are copies, asked of the app each time: changing one changes nothing in the app.
- CurrentDimensionStyle
Gets or sets the name of the dimension style new dimensions are drawn in, as the style box and Set Current do: the setting takes effect at once, as one undo step of the app (DIMSTYLE), not at CommitChanges().
- CurrentLayer
Gets or sets the name of the layer new objects are drawn on, which an object inserted with no layer of its own is put on.
- CurrentLayout
Gets or sets the tab the drawing shows,
Modelor the name of a layout, as clicking the tab does: switching is an undo step of the app (LAYOUT), and the objects of the layout shown are what the user sees and picks. The drawing is shown in the app first.
- CurrentView
Gets the part of the space shown that the canvas of the app shows, asked each time: the whole canvas, so wider or taller than a box given to SetCurrentView(GeoPoint2, GeoPoint2) where the shape differs.
- DimensionStyles
Gets the dimension styles of the drawing, sorted by name without regard to case, then by ordinal order. They are copies, asked of the app each time, with the text style, linetypes and arrowhead blocks they point at: changing one changes nothing in the app.
- Extents
Gets the extents the header of the drawing holds (
EXTMINandEXTMAX), asked of the app each time. A drawing with nothing drawn has the empty box a header starts with, whose least corner is above its greatest (IsEmpty).
- HasWindow
Gets whether the app shows the drawing in a window: false where the drawing's session has no view of the canvas, as in a test of the app with no window, where the view calls work on a view of 942 by 534 pixels showing 10 units of height about the origin. Asked each time.
- Id
Gets the id of the drawing, which holds as long as the app runs and is never given to another drawing.
- IsActive
Gets whether the drawing is the one the user works in; as the app last said (CadRemoteDocuments asks again each time it is walked).
- IsModified
Gets whether the drawing has changes not saved; as the app last said.
- Layers
Gets the layers of the drawing as the Layer manager lists them, in the order of its table. They are copies, asked of the app each time: change one and give it to ModifyLayer(CadRemoteLayer).
- Layouts
Gets the names of the tabs of the drawing in the order they are shown:
Model, then each layout. Asked of the app each time.
- Linetypes
Gets the names of the linetypes of the drawing, in the order of its table, asked of the app each time:
ByBlock,ByLayerandContinuousin a new drawing.
- Name
Gets the name of the drawing with its extension, as
A-101.dwg, orDrawing1.dwgfor one with no file yet; as the app last said.
- NamedViews
Gets the names of the named views of the drawing, as -VIEW ? lists them: in ordinal order, letters of either case alike. Asked each time.
- Path
Gets the full path of the drawing's file; empty for a drawing with no file yet; as the app last said.
- TextStyles
Gets the text styles of the drawing, sorted by name without regard to case, then by ordinal order. They are copies, asked of the app each time: changing one changes nothing in the app.
Methods
- Activate()
Shows the drawing in the app, as clicking its tab does.
- AddLayer(CadRemoteLayer)
Queues a new layer, to be made when CommitChanges() is called. The layers of a commit are made before its objects, so that an object inserted in the same commit can be on the layer. The layer is copied now, so changing it afterwards changes nothing.
- AddLayout(string, string, bool)
Asks the app to add a layout on a sheet, as LAYOUT New and the page setup do, one undo step; it does not become the tab shown.
- AddRecords(DxfDatabase)
Queues the table records and the blocks of a drawing of yours to be added to the drawing when CommitChanges() is called: its text styles, linetypes, blocks (each with its objects) and dimension styles that the small drawing of the commit has none of the name of, as Insert(GeoTransform3, DxfDatabase, bool) merges them. They are written before the layers and the objects of the commit, so that a layer can have the linetype, and an object the style or block, that the same commit adds. A record of a name the app's drawing has already is the app's own, as a merge keeps it, and the one given is left out. The records are copied now, so changing them afterwards changes nothing.
- AddViewport(string, IReadOnlyList<double>, string, IReadOnlyList<double>, IEnumerable<string>)
Asks the app to add a viewport to a layout that shows model space at a scale, as MVIEW with two corners does, one undo step.
- CheckStandard(string, double, double)
Checks the drawing against a drawing standard and scores it, as the app does: a score for each rule the standard runs, a total and the violations with their places. The standard is the text of a file of the schema
docs/schemas/opencad2d-standard-v1.schema.json.
- Close(bool)
Closes the drawing in the app, as the x of its row does, but with no question and no dialog: the app never asks the user about a drawing closed from here. A drawing with changes not saved is refused unless
discardis set, which throws the changes away. The app shows the next drawing, or its start screen where this was the last; the drawing is no longer in Documents, and every later call on it throws.
- CommitChanges()
Sends the queued inserts, modifies, deletes and layers and has the app apply them as one undo step, the canvas drawn again. Nothing queued is no request.
- Copy<T>(IEnumerable<T>, GeoVector2)
Copies objects by a displacement, as COPY does: two lines copied by (0, 50) add two lines 50 above them in the app. Sends the queued changes with it.
- Delete(DxfEntity)
Queues the erasing of an object read from this drawing.
- Delete(string)
Queues the erasing of an object.
- DeleteView(string)
Erases a named view, as -VIEW Delete does.
- ExportGraph(string, double)
Gets the graph of the drawing as one JSON document, as the app writes it (schema
opencad2d.graph, version 1): a node for each entity of ExportJson(string) and the edges that touch, contain, dimension and annotate.
- ExportGraph(string, double, int)
Gets the graph of the drawing as ExportGraph(string, double) does, cut at a number of edges: the first
maxEdgesedges of the whole graph in its order (kind, source, target), withtruncatedtrue andedgesFoundin the text where there were more.
- ExportJson(string)
Gets the drawing as one JSON document in millimetres, block references walked down to what they draw, as the app writes it (schema
opencad2d.drawing, version 1; seedocs/schemas): the entities in the order of their handles, with their layer, colour, linetype, box, words and geometry, and the tables of layers, styles, linetypes and blocks.
- Fits(string, double, double, double, double, double, IEnumerable<string>, double, double)
Asks the app whether a candidate place is free: nothing of the kinds asked about runs through it or comes within the margin of it.
- GetBlocks()
Gets the blocks of the drawing that an INSERT can place (layout blocks, anonymous blocks and external references left out), sorted by name without regard to case, then by ordinal order, with the entity count of each. Unlike Blocks, the entities of the definitions are not copied.
- GetBounds(string)
Gets the box every entity of a space takes as the app draws it: the letters of an SHX or TrueType word and not its insertion point, the picture of a dimension, a block however deep and scaled, the columns of an MTEXT. An entity that draws nothing has no row. A line from (0, 0) to (100, 40) has the box from (0, 0) to (100, 40).
- GetBoundsOf(IEnumerable<string>)
Gets the boxes of the entities of some handles as the app draws them, in the order given, each in the space that holds it. A handle the drawing has no entity of, or one that draws nothing, has no row.
- GetDatabase()
Gets a copy of the whole drawing as the app has it now, changes not saved included: the header, tables, blocks, layouts with their viewports and every object, read from the DXF text the app writes of its database. The file of the drawing is not touched. A program that draws or checks the drawing in its own process opens it with
CadDocument.From(database). The copy is a snapshot: later changes in the app are not in it.
- GetFreeSpace(string, double, double, double, double, IEnumerable<string>, double, double, double, double)
Asks the app for the empty rectangles of a frame: the largest rectangles, not turned, that no line or word of the kinds asked about runs through or comes within the margin of, and that cannot be made larger, the largest first.
- GetHandlesIn(string, string, IEnumerable<GeoPoint2>, double)
Asks the app for the handles of the entities of a space that lie in an area, whole: unlike SelectWindow(GeoPoint2, GeoPoint2) it is not held to the view of the window, so a drawing gives the same handles with a window or without. A box from (0, 0) to (100, 50) in
windowtakes a line from (10, 10) to (20, 10) and leaves a circle of radius 30 about (50, 25), whichcrossingtakes. The selection of the drawing is not changed.
- GetHistory(int)
Gets the last lines of the drawing's command line, the oldest first: each command, each prompt with its answer, each message, as the user sees them in the history. Nothing is typed or changed.
- GetLayoutSetups()
Asks the app how every layout is set up, model space first: its sheet, what is plotted, its scale and plot style. The answer is JSON text, an array with an object for each layout:
name,model,paper,widthandheight(millimetres),landscape,units,area,scale(as1:50, null where fitted),plotStyleandviewports.
- GetLayouts()
Gets the spaces of the drawing in tab order (
Modelfirst, then each layout), with each sheet's paper size and units, rotation, entity count and viewports. The drawing itself is not copied.
- GetLinetypes()
Gets the linetypes of the drawing, sorted by name without regard to case, then by ordinal order, with their descriptions, pattern lengths and dashes. The drawing itself is not copied.
- GetMultileaderStyles()
Gets the multileader styles of the drawing, sorted by name without regard to case, then by ordinal order. They are copies, asked of the app each time, and the drawing itself is not copied: a drawing of 10000 objects costs no more than one of none.
- GetObject(string)
Reads an object by its handle.
- GetObjects(CadObjectFilter)
Reads the objects that match a filter, in the order of the drawing: model space first, then each layout, each in the order its objects were made.
- GetOverlaps(string, IEnumerable<string>, IEnumerable<string>, IEnumerable<string>, double)
Finds the entities whose words overlap what is drawn near them, as the app's spatial query does: a word is the frame of a text (a TEXT, an MTEXT's runs, a dimension's words) turned as the text is, and it overlaps a line, an arc, a polyline or a hatch that runs through it, a filled area it lies in, and the frame of another word it shares an area with; what only touches it within the tolerance does not, nor a part of its own entity. A kind is the DXF name of an entity,
TEXT,MTEXT,DIMENSION,MULTILEADER,LINE,INSERT.
- GetProperties(IEnumerable<string>)
Asks the app what its Properties palette shows for some entities, as it would with them selected: for one line from (0, 0) to (300, 400) the label
Line (1)and, in the group Geometry,Length500.0000. Several entities of one kind show the rows they share, a value that differs asVaries. The selection of the drawing is not changed.
- GetSelectedObjects()
Reads the objects the user has selected in the drawing, in the order of their handles.
- GetTableStyles()
Gets the table styles of the drawing, sorted by name without regard to case, then by ordinal order. They are copies, asked of the app each time, and the drawing itself is not copied.
- GetVariable(string)
Gets the value of a system variable of the drawing as AutoLISP's
getvargives it: an int for a whole number or a switch, a double for a real (an angle in radians), a string for a text and adouble[]of three coordinates for a point, two for a variable AutoCAD keeps as a 2D point.
- HandleOf(DxfEntity)
Gets the handle an object read from this drawing has in the app's drawing.
- HandleOfTicket(string)
Gets the handle in the app's drawing of the object a ticket stands for, from what the commit that made it answered: no request is sent, where GetObject(string) of the ticket and HandleOf(DxfEntity) ask the app once. After an edit call (Move<T>(IEnumerable<T>, GeoVector2), Copy<T>(IEnumerable<T>, GeoVector2), Offset(DxfCurve, double, GeoPoint2)...) it has the handles of the objects inserted in the same commit.
- Insert(DxfEntity, string)
Queues an object to be added to the drawing. The entity is copied now, so changing it afterwards changes nothing; it can be one made in code (
new DxfLine(...)), or one read from this or another drawing of the same app, which is copied with the layers, styles and blocks it needs. A layer the drawing has not is made. An INSERT of a block the drawing has not brings the block's definition when the INSERT was made from a block of your own that holds objects (new DxfBlockReference(point, record)withrecordin aDxfDatabaseof yours); a block the drawing has already is the drawing's own, whatever yours holds. An INSERT of a block that is neither in the drawing nor defined with objects is refused at the commit. A dimension made in code is drawn by the app, with the drawing's current dimension style unless it names one. A text or MTEXT (or an attribute of an INSERT) that names a text style, or any object that names a linetype, is one the drawing has (the app's own record is kept) or AddRecords(DxfDatabase) adds in the same commit; one nobody has is refused at once, as the library refuses an object that names a style its drawing has not.
- ListObjects(IEnumerable<string>)
Asks the app for the lines AutoCAD's LIST writes for some entities: the kind and layer, the space, the handle and the shape of each (the length and angle of a line, the centre and radius of a circle). The app runs LIST in a command session of its own, so its command line, its selection and its undo list are as they were.
- Measure(DxfEntity)
Asks the app what an object would take on the page once added, without adding it: the box of everything it draws and the frame of each word, drawn by the app's own code in the app's own text styles, fonts and dimension styles. A dimension is drawn in the style it names. A text or MTEXT that names a text style names one the drawing has.
- MeasureLeader(string, double, double, double, double, string, double?)
Asks the app what a multileader of words would take once MLEADER made it, its arrow at one point and its landing at another, in a multileader style of the drawing.
- Mirror<T>(IEnumerable<T>, GeoPoint2, GeoPoint2, bool)
Mirrors objects across the line through two points, as MIRROR does: a text stays readable under MIRRTEXT 0, a dimension too. Sends the queued changes with it.
- Modify(DxfEntity)
Queues the changes made to an object read from this drawing, to be written over the object it was read from when CommitChanges() is called, which keeps its handle. A dimension is drawn again by the app.
- ModifyLayer(CadRemoteLayer)
Queues the look of a layer to be written over the look the layer of that name has, when CommitChanges() is called: the layer read from Layers and changed since. Everything but the name is written; a property left as the drawing has it changes nothing. The app refuses a layer of an external reference and the freezing of the current layer.
- Move<T>(IEnumerable<T>, GeoVector2)
Moves objects by a displacement, as MOVE does: a line from (0, 0) to (100, 0) moved by (10, 5) runs from (10, 5) to (110, 5) in the app. Sends the queued changes with it.
- Offset(DxfCurve, double, GeoPoint2)
Offsets a curve to the side of a point, as one pick of OFFSET with a distance typed: a line from (0, 0) to (100, 0) offset by 5 toward (50, 10) adds a line from (0, 5) to (100, 5) on the layer of the curve, which is kept. Sends the queued changes with it.
- Pan(GeoVector2)
Pans the view so that the drawing moves by the displacement, as -PAN does.
- PickObject(string, TimeSpan?)
Asks the user for one object and waits for the answer: one click ends it. If exactly one object was selected before the call, it is taken at once.
- PickObjects(string, TimeSpan?)
Asks the user for objects and waits for the answer, as a command asks "Select objects:": the user clicks them or drags a window and presses Enter. Objects the user had selected before the call are taken at once, as the app's commands take them. The objects are copies as GetObjects(CadObjectFilter) gives them, so HandleOf(DxfEntity) and Modify(DxfEntity) work on them.
- PickPoint(string, GeoPoint3?, TimeSpan?)
Asks the user for a point and waits for the answer. The drawing is shown, the prompt appears on the app's command line, and the user clicks on the canvas (with the snaps and the object snaps the drawing has on) or types the point. The app stays free for the user while the call waits. The point is in world coordinates, its Z nought.
- Regen()
Regenerates the drawing, as REGEN does.
- Release(CadRemoteSnapshot)
Tells the app to forget a snapshot and the memory it holds; one already released is no error.
- Reset(CadRemoteSnapshot)
Asks the app to put the drawing back as the snapshot kept it: its entities, tables, layouts, handles and header variables. The steps made since are forgotten, not made one more step, so that a thousand resets leave the app's memory where one does; the display is updated as after an undo.
- RestoreView(string)
Shows a named view, as -VIEW Restore does.
- Rotate<T>(IEnumerable<T>, GeoPoint2, double)
Turns objects about a base point, as ROTATE does: counter-clockwise, in radians, the angle taken from nought up to a whole turn as ROTATE takes it. Sends the queued changes with it.
- Save()
Saves the drawing to its file.
- SaveAs(string, string)
Saves the drawing to a file, which it is known by from then on.
- SaveView(string)
Saves the view on screen under a name, as -VIEW Save does; a name that is a view's already redefines it. One undo step of the app, VIEW.
- Scale<T>(IEnumerable<T>, GeoPoint2, double)
Scales objects about a base point, as SCALE does: a circle of radius 10 scaled by 2 is one of radius 20. Sends the queued changes with it.
- Select(IEnumerable<string>)
Selects objects in the drawing, as the user does, in place of what was selected.
- SelectAll()
Takes every object of the space the drawing works in, as the All option of "Select objects:" does, the first viewport of a layout left out. The objects the user has selected stay selected: Select(IEnumerable<string>) changes them.
- SelectCrossingWindow(GeoPoint2, GeoPoint2)
Takes the objects a window lies across or contains, as the Crossing option of "Select objects:" does, held to the view as SelectWindow(GeoPoint2, GeoPoint2) is. The objects the user has selected stay selected.
- SelectWindow(GeoPoint2, GeoPoint2)
Takes the objects that lie wholly inside a window, as the Window option of "Select objects:" does: where the app has a window, only objects its view shows. The objects the user has selected stay selected.
- SendCommand(string)
Types text on the drawing's command line, as the user would, and waits for the command to end. The drawing is shown first, since a command works on the drawing the user sees. Lines parted by a line feed are typed one after the other, and words in a line as if parted by Space, so
"ZOOM E "zooms to the extents and"LINE 0,0 100,0"starts a line and gives two points. Waits up to 30 seconds.
- SendCommand(string, TimeSpan)
Types text on the drawing's command line as SendCommand(string) does, and waits up to a time for the command to end. A command that asks the user for a point stays running after the time: the result says so, and the command goes on in the app.
- SetCurrentView(GeoPoint2, GeoPoint2)
Sets the view to show a box, fitted with no margin as ZOOM Window fits one.
- SetPageSetup(string, string, string, string, string, string)
Asks the app to change the page setup of a layout, one undo step; only what is given is changed.
- SetVariable(string, object)
Sets a system variable of the drawing as AutoLISP's
setvardoes; one the drawing keeps is an undo step of the app, SETVAR.
- TakeSnapshot()
Asks the app to keep the drawing as it stands, with the changes not saved, to put it back to with Reset(CadRemoteSnapshot): for a program that tries edits on the drawing again and again from the same start. What the user did before can still be undone after a reset while the app's undo list holds the point of the snapshot; where it does not (a reset to a later snapshot after a reset to an earlier one) the app reads the drawing back from the snapshot's bytes and starts its undo list afresh. What came after the snapshot is the episode.
- ZoomCenter(GeoPoint2, double)
Zooms to a height about a centre, as ZOOM Center does.
- ZoomExtents()
Zooms the drawing to its extents, as ZOOM Extents does: what the space shown draws, fitted with a margin of 5 %. One undo step of the app, ZOOM. The view calls work on the drawing the app shows, which is not this one until Activate() is called.
- ZoomObjects(IEnumerable<string>)
Zooms to objects, as ZOOM Object does: the box of the ones drawn in the space shown, fitted with a margin of 5 %; none drawn there leaves the view as it was.
- ZoomPrevious()
Goes back to the view before the last zoom or pan, as ZOOM Previous does.
- ZoomScaled(double)
Scales the view as it is about its centre, as ZOOM nX does: 2 shows half the width.
- ZoomWindow(GeoPoint2, GeoPoint2)
Zooms the drawing to a window, as ZOOM Window does: the window fitted with no margin. With the console view of the app with no window (942 by 534 pixels), (0, 0) to (10, 10) shows (-3.820, 0) to (13.820, 10).