Table of Contents

CadTool

from OpenCAD2D import CadTool

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

A tool of a tool palette: a block to insert, a hatch to lay, a command to run, or a line of text or a separator that parts the others. A block tool names the block and the drawing it comes from, its scale, rotation, and whether the scale or rotation is asked on the command line; a hatch tool the pattern, angle and scale; a command tool the command line it runs. The three kinds that draw also carry what AutoCAD's Tool Properties calls overrides: the layer, colour, linetype and lineweight the objects it makes are drawn with, each left null to use the current one. A tool is made with one of the For methods, or from an object of a drawing with CadTool.FromObject.

Properties and fields

Angle

.NET

@property
def Angle(self) -> float
@Angle.setter
def Angle(self, value: float) -> None

Gets or sets the rotation of a block tool's insertion, or the angle of a hatch tool's pattern or gradient, in degrees; 0 until set.

Associative

.NET

@property
def Associative(self) -> bool
@Associative.setter
def Associative(self, value: bool) -> None

Gets or sets whether the hatch a hatch tool makes follows its boundary; true until set.

BlockName

.NET

@property
def BlockName(self) -> str
@BlockName.setter
def BlockName(self, value: str | None) -> None

Gets or sets the name of the block in its drawing; empty, with a CadTool.File, for the whole drawing inserted as one block.

Color

.NET

@property
def Color(self) -> str | None
@Color.setter
def Color(self, value: str | None) -> None

Gets or sets the colour of the objects the tool makes: ByLayer, ByBlock or an index 1 to 255 as text; null for the current colour.

Command

.NET

@property
def Command(self) -> str
@Command.setter
def Command(self, value: str | None) -> None

Gets or sets the command line a command tool runs: a command's name or alias, then the answers to its first prompts, parted by spaces or semicolons, as typed (CIRCLE 0,0 50); a leading ^C^C and an underscore, as a menu macro of AutoCAD writes them, are left off.

Description

.NET

@property
def Description(self) -> str
@Description.setter
def Description(self, value: str | None) -> None

Gets or sets the description shown in the tool's tooltip.

Explode

.NET

@property
def Explode(self) -> bool
@Explode.setter
def Explode(self, value: bool) -> None

Gets or sets whether a block tool explodes what it inserts; false until set.

File

.NET

@property
def File(self) -> str | None
@File.setter
def File(self, value: str | None) -> None

Gets or sets the drawing a block tool's block comes from; null, or the drawing open, for a block the drawing has. A file that cannot be found falls back to the block of the drawing open of the same name.

Gradient

.NET

@property
def Gradient(self) -> str
@Gradient.setter
def Gradient(self, value: str | None) -> None

Gets or sets the gradient of a hatch tool of the type Gradient, by the name AutoCAD's dialog gives it: GR_LINEAR.

HasOverrides

.NET

@property
def HasOverrides(self) -> bool

Gets whether the tool sets a layer, colour, linetype or lineweight of its own.

HatchType

.NET

@property
def HatchType(self) -> CadHatchType
@HatchType.setter
def HatchType(self, value: CadHatchType) -> None

Gets or sets what a hatch tool fills with: a pattern, lines of the user's, a solid fill or a gradient.

Icon

.NET

@property
def Icon(self) -> str | None
@Icon.setter
def Icon(self, value: str | None) -> None

Gets or sets the icon of a command tool, the name of one of the presenter's own: Line, Polyline, Circle, Arc, Text, MText, Rectangle, Ellipse, Spline, Point, Move, Copy, Rotate, Scale, Mirror, Offset, Trim, Extend, Fillet, Chamfer, Stretch, Explode, Erase, Dimension, Aligned, Angular, Radius, Diameter, Leader, Table and the others the ribbon has; null or a name it has not gives the plain command icon.

Kind

.NET

@property
def Kind(self) -> CadToolKind

Gets what the tool is; it does not change.

Layer

.NET

@property
def Layer(self) -> str | None
@Layer.setter
def Layer(self, value: str | None) -> None

Gets or sets the layer the objects the tool makes are on; null for the current layer. A layer the drawing has not is made.

LineWeight

.NET

@property
def LineWeight(self) -> int | None
@LineWeight.setter
def LineWeight(self, value: int | None) -> None

Gets or sets the lineweight of the objects the tool makes, in hundredths of a millimetre as DXF writes it (25 is 0.25 mm), or -1 for ByLayer, -2 for ByBlock, -3 for the default; null for the current lineweight.

Linetype

.NET

@property
def Linetype(self) -> str | None
@Linetype.setter
def Linetype(self, value: str | None) -> None

Gets or sets the linetype of the objects the tool makes, as ByLayer, ByBlock or the name of one the drawing has; null for the current linetype.

Name

.NET

@property
def Name(self) -> str
@Name.setter
def Name(self, value: str | None) -> None

Gets or sets the name shown under the tool's icon; for a text tool the words themselves, for a separator empty.

Pattern

.NET

@property
def Pattern(self) -> str
@Pattern.setter
def Pattern(self, value: str | None) -> None

Gets or sets the pattern of a hatch tool of the type Pattern, as ANSI31; one of the presenter's own, or one a support folder of the drawing has.

PromptForRotation

.NET

@property
def PromptForRotation(self) -> bool
@PromptForRotation.setter
def PromptForRotation(self, value: bool) -> None

Gets or sets whether a block tool asks the rotation on the command line, as AutoCAD's Prompt for rotation; false until set.

PromptForScale

.NET

@property
def PromptForScale(self) -> bool
@PromptForScale.setter
def PromptForScale(self, value: bool) -> None

Gets or sets whether a block tool asks the scale on the command line, as AutoCAD's Prompt for scale; false until set.

Scale

.NET

@property
def Scale(self) -> float
@Scale.setter
def Scale(self, value: float) -> None

Gets or sets the scale of a block tool's insertion, or of a hatch tool's pattern; 1 until set.

Spacing

.NET

@property
def Spacing(self) -> float
@Spacing.setter
def Spacing(self, value: float) -> None

Gets or sets the spacing between the lines of a hatch tool of the type UserDefined; 1 until set.

Methods

Clone

.NET

def Clone(self) -> CadTool

Gets a copy, with every setting the tool has.

ForBlock

.NET

@staticmethod
def ForBlock(name: str, file: str, blockName: str) -> CadTool

Makes a block tool.

ForCommand

.NET

@staticmethod
def ForCommand(name: str, command: str, icon: str | None = ...) -> CadTool

Makes a command tool.

ForHatch

.NET

@staticmethod
def ForHatch(name: str, pattern: str) -> CadTool

Makes a hatch tool of a pattern of the presenter's own set or a support folder, at angle 0 and scale 1.

ForSeparator

.NET

@staticmethod
def ForSeparator() -> CadTool

Makes a separator, a rule between tools.

ForText

.NET

@staticmethod
def ForText(text: str) -> CadTool

Makes a line of text to part the tools with.

FromObject

.NET

@staticmethod
def FromObject(document: CadDocument, entity: DxfEntity) -> CadTool

Makes a tool of an object of a drawing, as dragging it onto a palette does in AutoCAD: a block reference becomes a block tool (its block, the drawing open as source, the scale of the reference), a hatch a hatch tool (its pattern or fill, angle and scale), and a line, circle, arc, polyline, ellipse, spline, point, text, multiline text or dimension a command tool that runs the command which draws it. Each takes the object's layer, colour, linetype and lineweight as its overrides; a true colour, which a drawing's current colour cannot be, is left unset.