All,I'm trying to get the CurveVector of a ParametricCellElement I've created so that I can use to extrude the shape using DgnExtrusionDetail.for the extrusion I use the following code, which works when I create a LineStringElement as test case:
DPoint3d[] points = new DPoint3d[] { new DPoint3d(40000, 0, 0), new DPoint3d(50000, 0, 0), new DPoint3d(50000, 2000, 0), new DPoint3d(47000, 2000, 0), new DPoint3d(47000, 10000, 0), new DPoint3d(50000, 10000, 0), new DPoint3d(50000, 12000, 0), new DPoint3d(40000, 12000, 0), }; LineStringElement element = new LineStringElement(Session.Instance.GetActiveDgnModel(), null, points); element.AddToModel(); CurveVector curve = CurvePathQuery.ElementToCurveVector(element); DgnExtrusionDetail detail = new DgnExtrusionDetail(curve, DVector3d.UnitZ * -extrusionLength, true); SolidPrimitive solid = SolidPrimitive.CreateDgnExtrusion(detail); Element extrudedEle = DraftingElementSchema.ToElement(Session.Instance.GetActiveDgnModel(), solid, null); extrudedEle.AddToModel();
CurveVector curve = CurvePathQuery.ElementToCurveVector(cellElement); //Returns null
CurveVector curve = CurvePathQuery.ElementToCurveVector(CurvePathQuery.GetFromElementRef(cellElement.GetNativeElementRef())); //Straight up crashes
NamedGroupCollection namedGroupColl = new NamedGroupCollection(Session.Instance.GetActiveDgnModelRef()); var namedGroup = namedGroupColl.FindByElementId(cellElement.ElementId); var ele = namedGroup.GetElement(); //ng.GetElement returns null CurveVector curve = CurvePathQuery.ElementToCurveVector(ele); //Null refs because ele is null
Hi Remy,
Remy Moerland said:I've been unabe to find a reason for why CurvePathQuery.ElementToCurveVector wouldn't work for ParametricCellElements
personally I am not surprised it does not work. A cell is just a container, regardless it's "classic cell" or parametric cell, not curve geometry. And even when ICurvePathQuery::GetCurveVector (which is called at background) would be able to iterate the cell content, how other element types like 3D solids should be processed?
Remy Moerland said:Any pointers or suggestions would be greatly appreciated
I think you should use ElementGraphicsProcessor to access Parametric cell content.
See e.g. this discussion (but similar topic was discussed more times, so try to search for it).
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi Jan,Thanks for the suggestion, I looked into the discussion you linked (And the linked discussion there in) and indeed managed to make an extrusion using the methods explained there, using the ElementGraphicsProcessor. However because this loops over the child elements, and creates them anew as an element all reference and information about the Parametric cell is lost. Meaning that if I change the variation after placement the extrusion doesn't update with it (something it does do if I just use the extrustion tool on a parametric cell in microstation). Is there a way to attach the created extrusion back to the ParametricCell so it updates when I change the variation?Regards,Remy
Remy Moerland said:Is there a way to attach the created extrusion back to the ParametricCell so it updates when I change the variation?
My knowledge of parametric cells is limited, but is it possible to do it manually? ... to use parametric cell (not just constrained geometry with variables) for an extrusion to created parametric 3D solid?
Regards,
Remy Moerland said: I looked into the discussion you linked and indeed managed to make an extrusion using the methods explained there, using the ElementGraphicsProcessor. Is there a way to attach the created extrusion back to the ParametricCell so it updates when I change the variation?
ElementGraphicsProcessor
The ElementGraphicsProcessor provides a mechanism to extract geometry from elements. The extracted geometry is just that: geometry, with no intelligence.
The origin of the ElementGraphicsProcessor was, I believe, to enable the production of visualisations (i.e. facets) and iModels (i.e. geometry for consumption by external apps). It intentionally excludes meta-data linked to any particular application, so you cannot use the elements generated by the ElementGraphicsProcessor to reconstruct the original data.
Regards, Jon Summers LA Solutions
Remy Moerland said:However whenever I try to get the CurveVector from a ParametricCellElement instead, it returns null
I though about your question once more and I think (but it's a guess only, no test code written ;-) that in fact there are two different scenarios, when discussed from API perspective:
SolidPrimitive.CreateDgnExtrusion method allows to extrude base CurveVector. But parametric object (parametric cell or constrained element) is not curve.
I think you have to use SmartFeature API (SmartFeature is parametric modeling API) to create parametric solid from parametric profile. Unfortunately this API is now available only in C++.
Hi Jan,Sorry I had no time to get back to your answers yesterday.Thanks for the additional information. I'll look into the SmartFeature API Regards,Remy
What is a CurveVector? From the SDK doc, a CurveVector is a container of curve primitive(s). And then what is a curve primitive? Please see below pic:
So we can understand only Line, LineString, PointString, Arc, kinds of Curve can be treated as Curve Primitive. Cell is not a curve primitive. In other words, we can think CurveVector as a linear geometry (not an element, just geometry).
Jan Šlegr said:I think you have to use SmartFeature API (SmartFeature is parametric modeling API) to create parametric solid from parametric profile. Unfortunately this API is now available only in C++.
SmartFeature API is available in .NET(C# ). Please see below object browser in VS:
Hi Yongan,
Yongan.Fu said:SmartFeature API is available in .NET(C# ). Please see below object browser in VS:
Thanks for this information, because it's not mentioned in SDK documentation.
I'd like to add the information that it's available in ConstraintCommonNet assembly, because it's not normally referenced in addin projects.