Table of Contents

Method AddLookupParameter

Namespace
GeometryHelper.Dxf
Assembly
GeometryHelper.dll

AddLookupParameter(string, string, GeoPoint3, IEnumerable<DxfBlockLookupInput>, IEnumerable<DxfBlockLookupRow>)

Makes the block dynamic, where it is not, and gives it a lookup parameter with its lookup action: a table of rows, each a label and the values it gives other parameters' properties, which each INSERT of the block shows as the dynamic property of the parameter's name, AutoCAD's Lookup parameter and Lookup action as its Block Editor makes them. Set to a row's label, the property sets the other properties to the row's values; any of those set, it shows the label of the row of their values, or Custom where no row holds them.

public void AddLookupParameter(string name, string description, GeoPoint3 location, IEnumerable<DxfBlockLookupInput> inputs, IEnumerable<DxfBlockLookupRow> rows)

Parameters

name string

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

description string

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

location GeoPoint3

Where the parameter's grip stands, in the block's coordinates.

inputs IEnumerable<DxfBlockLookupInput>

The input columns of the table, each the property of another parameter of this block (Distance(DxfBlockLinearParameter), X(DxfBlockPointParameter), Y(DxfBlockPointParameter), X(DxfBlockXYParameter), Y(DxfBlockXYParameter), Distance(DxfBlockPolarParameter), Angle(DxfBlockPolarParameter), Angle(DxfBlockRotationParameter)), each once.

rows IEnumerable<DxfBlockLookupRow>

The rows, each a label and a value for each input column (DxfBlockLookupRow), the labels apart, letters of either case the same.

Remarks

A panel of a Width and a Height given AddLookupParameter("Size", "Panel size", new GeoPoint3(50, -20, 0), new[] { DxfBlockLookupInput.Distance(width), DxfBlockLookupInput.Distance(height) }, new[] { new DxfBlockLookupRow("Small", 100, 50), new DxfBlockLookupRow("Large", 200, 80) }) gives every INSERT the property Size, allowed Small and Large; set to Large, Width goes to 200 and Height to 80, stretching what they stretch; Width set to 150 afterwards, Size reads Custom. The lookup property is set and read as AutoCAD keeps it: by its label, a string, letters of either case the same.

The parameter and the action are written as AutoCAD saved those of ACadSharp's lookup sample: the parameter (its element named Lookup, the next Lookup1 and on) with its grip and the grip's two location components; the action (named after it, Lookup1 for the first) with the table row by row, each input column of its parameter's node, of reals, labelled Custom where no row matches, and the lookup column of the parameter, of text, looking back (reverse lookup on), so that the property may be set; five nodes of the evaluation graph and three edges, and a pair of edges each way between the action and each parameter it reads or sets, as AutoCAD pairs them, each of the flags 4 (93) as the sample's: AutoCAD 2021 read a block whose pairs were of the flags nought as dynamic, and none of its INSERTs (plugin v21, 24e-e). An INSERT keeps the label it shows in its cache, as AutoCAD keeps it; one of the block itself, of no cache, shows the label of the first row of the block's own values, Small for its Width 100 and Height 50, else Custom, as AutoCAD 2021 read it (plugin v21b) and as DynamicBlockReferencePropertyCollection reads it.

A column of an XY parameter's distance along x or along y is written of the connection UpdatedDistanceX or UpdatedDistanceY, of a polar parameter's distance UpdatedDistance, and of a polar or a rotation parameter's angle UpdatedAngle, of the units 1 (96) where a distance's are 2, its values in radians. AutoCAD 2021 read and set them as the library does (plugin D25b): a needle's Way of the rows East 0, North a quarter turn and West pi, set to North, turned it a quarter turn, and its Angle set to pi read West, to 1 Custom. An angle is taken into a turn and matched within the vector tolerance, not round the circle: a row of 2 pi sets nought and reads Custom, and one of -pi / 2 sets 3 pi / 2 and reads the row of 3 pi / 2, as AutoCAD 2021 read them.

Exceptions

ArgumentNullException

Thrown when the name, the inputs, the rows or one of them is null.

ArgumentException

Thrown when the name is empty, the name or the description holds a line break, a coordinate of the location is not a finite number, there are no inputs or no rows, an input is of another block or given twice, two rows have one label or a row is labelled Custom, a row has not one value for each input, or a distance is not above the point tolerance of Default or not of its parameter's value set, or an angle is not of its parameter's value set. Nothing is written then.

InvalidOperationException

Thrown when the block cannot be dynamic, as AddLinearParameter(string, string, GeoPoint3, GeoPoint3, double, DxfBlockParameterValueSet) says.

NotSupportedException

Thrown when the block has a flip parameter, as AddLinearParameter(string, string, GeoPoint3, GeoPoint3, double, DxfBlockParameterValueSet) says. Nothing is written then.