Method AddVisibilityParameter
- Namespace
- GeometryHelper.Dxf
- Assembly
- GeometryHelper.dll
AddVisibilityParameter(string, string, GeoPoint3, IEnumerable<DxfBlockVisibilityState>)
Makes the block dynamic, where it is not, and gives it a visibility parameter: named states, each showing some of the block's entities and hiding the others the states name, which each INSERT of the block shows as the dynamic property of the parameter's name, AutoCAD's Visibility parameter as its Block Editor makes one. Each INSERT shows the first state until its property is set (Value).
public void AddVisibilityParameter(string name, string description, GeoPoint3 location, IEnumerable<DxfBlockVisibilityState> states)
Parameters
namestringThe label of the parameter, the name of the property, as Mark.
descriptionstringThe description of the property; null or empty for none.
locationGeoPoint3Where the parameter's grip stands, in the block's coordinates.
statesIEnumerable<DxfBlockVisibilityState>The states, the first the one the block is kept in; each a name and the entities of this block shown in it (DxfBlockVisibilityState).
Remarks
A sign of a frame, a cross and a tick given AddVisibilityParameter("Mark", "What the sign shows", new GeoPoint3(20,
-10, 0), ...) with the states Cross (the cross), Tick (the tick) and Blank (nothing) gives every INSERT the property
Mark of the value Cross, allowed Cross, Tick and Blank. The entities a state names are those the parameter governs:
each is shown in the states that name it and hidden in the others; an entity named in no state, the frame, is not
governed and is shown in every state. The block itself is kept in its first state, as AutoCAD keeps it: each governed
entity not named in the first state is made invisible (Visible false), the tick here.
The parameter is written as AutoCAD writes one, as AutoCAD 2021 saved the visibility parameter of ACadSharp's sample: the parameter (its element named Visibility State) at the location, with the governed entities and each state with the entities shown in it, its grip and the grip's two location components, four nodes of the evaluation graph and three edges, the classes listed; the block is made dynamic as AddLinearParameter(string, string, GeoPoint3, GeoPoint3, double, DxfBlockParameterValueSet) makes it. Linear parameters and their stretches may come before or after it.
Every state lists the block's other parameters, their grips and its actions, those added before the visibility parameter and those added after it, as AutoCAD's Block Editor lists them in each state of its Door sample: so a Width of the sign is shown, with its grip, in Cross, Tick and Blank alike. AutoCAD 2021 read a state listing none as hiding them, Width not visible in any state and its grip not shown (plugin GhDb1).
Exceptions
- ArgumentNullException
Thrown when the name, the states 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 states, two states have one name (letters of either case the same), or an entity of a state is not of this block or is erased. Nothing is written then.
- InvalidOperationException
Thrown when the block has a visibility parameter already, as AutoCAD's Block Editor gives a block one, or 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.