Geometry
The parameter with the geometry value types can be used to create input controls for geometry elements like point, line or spline. The framework will take care of providing the right type of controls e.g. length input field for point coordinates and angle input for arc start/end angles. In the script, the value of such parameter will be converted to an actual geometry object from the module NemAll_Python_Geometry.
Tip
The framework takes care of converting the value from string like Line2D(1000,1100,5000,1500)
defined in PYP file, into an actual Line2D object.
You have to put the right string into PYP file as default value. To obtain it from a geometry
object, you can use the GeometryStringValueConverter.
Value types
Point
Vector
Axis placement
Defining <ValueType>
as AxisPlacement3D creates a parameter that returns an
AxisPlacement3D object as a result value.
<Parameter>
<Name>AxisPlacement</Name>
<Text>Axis placement</Text>
<Value>AxisPlacement3D(Origin(0,0,0)XDirection(1,0,0)ZDirection(0,1,1))</Value>
<ValueType>AxisPlacement3D</ValueType>
</Parameter>
Arc
Defining <ValueType>
as Arc2D creates a parameter that returns an Arc2D
object as a result value.
Defining <ValueType>
as Arc3D creates a parameter that returns an Arc3D
object as a result value.
<Parameter>
<Name>Arc3</Name>
<Text>Arc</Text>
<Value>Arc3D(CenterPoint(7000, 5000, 1000) XDirection(1, 0, 0) ZAxis(0, 0, 1) MinorRadius(1000) MajorRadius(2000) AxisAngle(0.78539816339744828) StartAngle(0.78539816339744828) EndAngle(4.7123889803846897) IsCounterClockwise(1))</Value>
<ValueType>Arc3D</ValueType>
</Parameter>
Circle
Line
Plane
Defining <ValueType>
as Plane3D creates a parameter that returns an
Plane3D object as a result value.
<Parameter>
<Name>Plane</Name>
<Text>Plane</Text>
<Value>Plane3D(Point(0,0,0)Vector(0,1,1))</Value>
<ValueType>Plane3D</ValueType>
</Parameter>
Polyline
Defining <ValueType>
as Polyline2D creates a parameter that returns a Polyline2D
object as a result value
Defining <ValueType>
as Polyline3D creates a parameter that returns a Polyline3D
object as a result value
Polygon
Spline
BSpline3D
Defining <ValueType>
as BSpline3D creates a parameter that returns a BSpline3D
object as a result value
<Parameter>
<Name>BSpline3</Name>
<Text>Point</Text>
<Value>BSpline3D(IsPeriodic(0)Degree(3)Weights()Knots(0,0,0,0,1,1,1,1)Points((12000,7000,0)(13000,9100,1000)(15000,6000,3000)(18000,9000,0)))</Value>
<ValueType>BSpline3D</ValueType>
</Parameter>
Geometry object
Defining <ValueType>
as GeometryObject creates a parameter that can be anything,
depending on the string provided in the <Value>
.
This value type can be initialized as a list, which makes it possible to create a collection of different geometry objects inside one parameter
<Parameter>
<Name>GeometryObjectList</Name>
<Text></Text>
<Value>[Arc3D(CenterPoint(0,5000,0)MinorRadius(1000)MajorRadius(1500)StartAngle(pi / 4 )EndAngle(pi * 3 / 2)XDirection(1,0,0)ZAxis(0,0,1)IsCounterClockwise(1));
Line2D(5000,0,7000,-2000);Polygon3D(Points((5000,7000,0)(8000,8000,0)(8000,5000,0)(5000,5000,0)(5000,7000,0)))]</Value>
<ValueType>GeometryObject</ValueType>
</Parameter>
Coordinates in one row
If a geometry object requires a point or a vector (2D or 3D) to be specified, its coordinates can be displayed in one row.
To achieve that, add the tag <XYZinRow>
to the geometry parameter:
<Parameter>
<Name>Point2</Name>
<Text>Point 2</Text>
<Value>Point3D(1000,1000,0)</Value>
<ValueType>Point3D</ValueType>
<XYZinRow>True</XYZinRow>
</Parameter>
Individual text for each coorinate
When for each of the x,y and z coordinates an individual text in the palette has to be set,
this can be achieved by defining all the texts in the <Text>
tag, seperated with a coma.
<Parameter>
<Name>RefPoint</Name>
<Text>From left,From front,From bottom</Text>
<Value>Point3D(1000,2000,3000)</Value>
<ValueType>Point3D</ValueType>
</Parameter>
Hide or disable a control
When a geometry parameter has to be disabled or hidden, this can be achieved with the
tags <Visible>
and <Enable>
as described in
this chapter.
However, if only a single component of the geometry parameter needs to be hidden or disabled
(e.g., a ), it can be achieved by introducing |
character in the tag.
<Parameter>
<Name>StartPoint</Name>
<Text>Start point</Text>
<Value>Point3D(5000,1000,0)</Value>
<ValueType>Point3D</ValueType>
<Visible>|StartPoint.Y:False<!--(1)!--></Visible>
</Parameter>
- This will hide the Y component of the point in the palette.
Examples on GitHub
The implementation of all geometrical value types is shown in the examples located in ...PaletteExamples/GeometryElements ( PYP | PY)
Min and max values
It is possible to set up minimum and maximum values for individual coordinates of a Point or Vector.
Add the tag <MinValue>
or <MaxValue>
to the parameter as follows:
<Parameter>
<Name>Point</Name>
<Text>Point with min/max</Text>
<Value>Point2D(1000,5000)</Value>
<ValueType>Point2D</ValueType>
<XYZinRow>True</XYZinRow>
<MinValue>Point2D(MinValue<!--(1)!-->,0)</MinValue>
<MaxValue>Point2D(10000,20000)</MaxValue>
</Parameter>
- This will set the min value to the one specified in
<Value>
tag, in this case to1000