Method AddRotationParameter
- Namespace
- GeometryHelper.Dxf
- Assembly
- GeometryHelper.dll
AddRotationParameter(string, string, GeoPoint3, double, double)
Makes the block dynamic, where it is not, and gives it a rotation parameter: an angle about a base point that each INSERT of the block shows as the dynamic property of its name, in radians, AutoCAD's Rotation parameter as its Block Editor makes one. Tie the parameter to the entities it turns with AddRotateAction(DxfBlockRotationParameter, IEnumerable<DxfEntity>).
public DxfBlockRotationParameter AddRotationParameter(string name, string description, GeoPoint3 basePoint, double radius, double angle)
Parameters
namestringThe label of the parameter, the name of the property, as Angle.
descriptionstringThe description of the property; null or empty for none.
basePointGeoPoint3The point the angle turns about, in the block's coordinates.
radiusdoubleHow far the parameter's grip stands from the base point, above the point tolerance.
angledoubleThe block's own angle, in radians counter-clockwise from the block's x axis: the grip stands at the radius in that direction.
Returns
- DxfBlockRotationParameter
The parameter, as written.
Remarks
An arrow along x from (50, 25) given AddRotationParameter("Angle", "Turn of the arrow", new GeoPoint3(50, 25, 0),
30, 0) and a rotate action of the arrow gives every INSERT the property Angle of nought; set to Math.PI / 2, the
arrow turns a quarter turn counter-clockwise about (50, 25) and points along y. A value is taken into a turn, from
nought up to 2 pi, as the property reads it.
The parameter is written as AutoCAD saved the rotation parameter of ACadSharp's sample: the base point, the end point at the radius and the angle, the base angle point at the radius along the block's x axis (from which the angle is measured), the value set of none (the flags 3, from nought to a whole turn), its element named Rotation; its grip at the end point with the grip's two location components; four nodes of the evaluation graph and three edges.
Exceptions
- ArgumentNullException
Thrown when the name is null.
- ArgumentException
Thrown when the name is empty, the name or the description holds a line break, or a coordinate of the base point is not a finite number. Nothing is written then.
- ArgumentOutOfRangeException
Thrown when the radius is not a finite number above the point tolerance of Default, or the angle is not a finite number.
- 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.
AddRotationParameter(string, string, GeoPoint3, double, double, DxfBlockParameterValueSet)
Makes the block dynamic, where it is not, and gives it a rotation parameter, as AddRotationParameter(string, string, GeoPoint3, double, double) does, of the angles it may take, AutoCAD's Value Set of the parameter: from a minimum to a maximum in steps of an increment, or one of a list, in radians.
public DxfBlockRotationParameter AddRotationParameter(string name, string description, GeoPoint3 basePoint, double radius, double angle, DxfBlockParameterValueSet valueSet)
Parameters
namestringThe label of the parameter, the name of the property, as Angle.
descriptionstringThe description of the property; null or empty for none.
basePointGeoPoint3The point the angle turns about, in the block's coordinates.
radiusdoubleHow far the parameter's grip stands from the base point, above the point tolerance.
angledoubleThe block's own angle, in radians counter-clockwise from the block's x axis.
valueSetDxfBlockParameterValueSetThe angles the property may take, in radians within a turn (Increments(double, double, double), List(IEnumerable<double>)); null for any.
Returns
- DxfBlockRotationParameter
The parameter, as written.
Remarks
An arrow along x from (50, 25) given AddRotationParameter("Angle", null, new GeoPoint3(50, 25, 0), 30, 0,
DxfBlockParameterValueSet.Increments(0, 2 * Math.PI, Math.PI / 12)) turns in steps of 15 degrees: Angle set to 40
degrees turns it 45, 370 degrees 15 and -10 degrees 345, as AutoCAD 2021 took them (plugin D25). An angle is taken
round the circle: of the steps of 15 from 0 to 90 degrees, 120 goes to 90 and 300 to 0, the bound nearer round the
circle; of the list 0, 90, 180 and 270, 338 goes to 0. A tie goes to the value behind the angle asked, clockwise, as
Value says.
The set is written as AutoCAD writes the set of a linear parameter, which AutoCAD 2021 read and kept: an increment of the flags 7, its minimum, maximum and increment (141 to 143); a list of the flags 8, its angles counted by 175 (144).
Exceptions
- ArgumentNullException
Thrown when the name is null.
- ArgumentException
Thrown when the name is empty, the name or the description holds a line break, a coordinate of the base point is not a finite number, or the value set reaches beyond a turn (2 pi) or does not hold the angle, taken into a turn, within the vector tolerance of Default. Nothing is written then.
- ArgumentOutOfRangeException
Thrown when the radius is not a finite number above the point tolerance of Default, or the angle is not a finite number.
- 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.