Table of Contents

Method AddLinearParameter

Namespace
GeometryHelper.Dxf
Assembly
GeometryHelper.dll

AddLinearParameter(string, string, GeoPoint3, GeoPoint3, double, DxfBlockParameterValueSet)

Makes the block dynamic, where it is not, and gives it a linear parameter: a distance from a base point to an end point that each INSERT of the block shows as the dynamic property of its name, AutoCAD's Linear parameter of two grips as its Block Editor makes one. Tie the parameter to the entities it moves with AddStretchAction(DxfBlockLinearParameter, GeoPoint2, GeoPoint2, IEnumerable<DxfEntity>), AddMoveAction(DxfBlockLinearParameter, IEnumerable<DxfEntity>) and AddScaleAction(DxfBlockLinearParameter, IEnumerable<DxfEntity>).

public DxfBlockLinearParameter AddLinearParameter(string name, string description, GeoPoint3 basePoint, GeoPoint3 endPoint, double labelOffset, DxfBlockParameterValueSet valueSet)

Parameters

name string

The label of the parameter, the name of the property, as Width.

description string

The description of the property; null or empty for none.

basePoint GeoPoint3

The point the distance is measured from, in the block's coordinates.

endPoint GeoPoint3

The point the distance is measured to, which the property moves.

labelOffset double

How far the label stands off the line, to its left looking from the base point to the end point: -20 puts the label of a Width along x 20 below it.

valueSet DxfBlockParameterValueSet

The values the distance may take (Increments(double, double, double), List(IEnumerable<double>)); null for any.

Returns

DxfBlockLinearParameter

The parameter, as written.

Remarks

A rectangle 100 by 50 from the origin given AddLinearParameter("Width", "Overall width", new GeoPoint3(0, 0, 0), new GeoPoint3(100, 0, 0), -20, DxfBlockParameterValueSet.Increments(50, 300, 10)) and a stretch of its right edge is the block AutoCAD 2021 read as dynamic (plugin v17): every INSERT of it shows Width 100, and a Width set to 200 moves the right edge to x = 200; 75 goes to 70, 77 to 80 and 400 to 300 by the value set.

The first parameter makes the block dynamic, as AutoCAD's Block Editor saves it: its BLOCK_RECORD is given the extended data AcDbDynamicBlockTrueName (its name), AcDbDynamicBlockGUID (a new GUID) and AcDbBlockRepETag, each of its entities a tag of AcDbBlockRepETag, and its extension dictionary the evaluation graph (ACAD_ENHANCEDBLOCK) and the purge preventer; the classes of the objects are listed in the CLASSES section. Each parameter is written as AutoCAD writes one, with its end grip and base grip, each with its two location components: seven nodes of the graph and six edges. Its element is named Linear, the next Linear1 and on, as AutoCAD names them. The block may be given several, each a property of its INSERTs in the order they were added.

An INSERT of the block shows the block's own distance until its property is set, by AutoCAD or by Value, which works the block out into an anonymous copy the INSERT places; DynamicBlockReferencePropertyCollection reads either. An entity appended after the last parameter or action has no tag, which AutoCAD 2021 did not need (plugin v17, 24a-c).

Exceptions

ArgumentNullException

Thrown when the name or a point is null.

ArgumentException

Thrown when the name is empty, the name or the description holds a line break, the base point and the end point are within the point tolerance of Default, or the value set does not hold the distance between them, the block's own value.

ArgumentOutOfRangeException

Thrown when the offset is not a finite number.

InvalidOperationException

Thrown when the block is in no file, is erased, is model space, paper space or the block of a layout, is anonymous or of an external reference, or its drawing is older than R2010 (AC1024), the oldest AutoCAD was seen to read such a block of.

NotSupportedException

Thrown when the block has a flip parameter, which is written alone in its block (AddFlipParameter(string, string, GeoPoint3, GeoPoint3)). Nothing is written then.