Below, we take a look at one aspect of parametric NURB spline curve evaluation and an overview of recent AEC DevBlog posts.
First, however, another update on my vacation :-)
Marvels of the Song of the Gulls
I am winding up my vacation on the Island of Ischia that I first discovered three years back.
It is one of my favourite places in the world, where I visited natural wonders such as hot thermal springs of Sorgeto in Panza, where you can build your own bathtub to mix the hot spring water with the cold waves from the sea, and the antique natural roman bath of Cavascura on the Maronti Beach that includes a natural sauna in hewn rock that has been running uninterrupted for 3000 years.
On the way here, I first got off at the wrong ferry stop in Procida. That also proved very nice, with all the families taking their numerous kids for a Sunday walk, to chat and play in the main square.
From the ferry, I walked up to the Chiesa della Annunziata and on to the Piano Liguori and then explored the peninsula of San Pancrazio with its spectacular old church and caves. Here is the view from Piano Liguori back towards Procida and Naples.
I visited the Trani family restaurant, olives and vineyard. They even built their own staircase access to the sea, tunnelling through the almost vertical rock facing the water.
It was a huge pleasure chatting with one of the Trani sons and listening to his joy over the traditional agricultural work amidst the 'canto dei gabbiani', the song of the gulls, and the challenges of making it economically viable through some interaction with tourism.
I later saw this wonderful example of a scalable implementation and thinking outside the box:
Parametric NURB Spline Curve Evaluation
Question: I use the Curve.Evaluate method to obtain equally spaced points along a curve.
This works fine for most curve types, but not on a NURB Spline that I created.
When I evaluate with regularly incremented parameter values, e.g. 0, .2, .4, .6, .8 and 1, the distances of the resulting positions along the curve are not visually equal. Using the same curve to create a ruled surface shows the lines and points appearing where one would expect.
Here is an example with the green lines displayed where ruled lines on the face occur, and text letters at the locations returned by the evaluate function:
Answer: The parameterisation of a NURB spline is such that regions of strong curvature are 'longer' in the parameter space than the actual curve length.
The assumption that a parameter measures uniformly along its length can only be made for lines and arcs. For ellipses and splines the parameter does not typically follow this pattern, because of the mathematics involved.
This is mentioned in the Developer Guide description of the parameter used in curve parameterisation:
"A ‘normalized’ parameter. The start value of the parameter is 0.0, and the end value is 1.0. For some curve types, this makes evaluation of the curve along its extents very easy; for example, the midpoint of a line is at parameter 0.5. (Note that for more complex curve equations like Splines this assumption cannot always be made)."
It is also explained in more detail in the Wikihelp community article on points hosted on curve edges.
The Revit Geometry API currently does not offer the ability to measure by segment-length or normalized segment-length. If it did, a more iterative solution would be easy to describe.
Recent AEC DevBlog Overview
Here is an overview of some of the posts by my colleagues on the AEC DevBlog in the past few weeks:
- Bubble end and free end arguments: explores the detailed meaning of the two XYZ parameters bubbleEnd and freeEnd to the NewReferencePlane method.
- Regenerating the model: provides yet another example in the long list of situations requiring an extra regeneration or transaction.
- SQLite version conflict with a Revit add-in discusses methods to resolve a DLL version conflict.
- Hiding sections in ViewPlan presents sample code to filter out the plan views, filter the sections created on each one of them, and call HideElements to suppress them in the view.
- Determining if a family instance requires a host can be achieved using RevitLookup and the HOST parameter on the family itself.
- Retrieving paint material for walls uses the Face HasRegions property and GetRegions method.
- Disassociating a family parameter from an element parameter is possible using the FamilyManager AssociateElementParameterToFamilyParameter method.
- Accessing the material value of a panel uses the MATERIAL_ID_PARAM built-in parameter on the panel type referenced by the panel element.
- Using Rebar.CreateFromCurves with curves: if a Rebar shape includes any straight edges, then its first and last curves must be straight lines, unless it is completely made up of arcs.
- Revit API error in projects with web references can be fixed by changing the 'Generate Serialization Assembly' setting from 'Auto' to 'Off' in the Visual Studio project properties build tab.