Stencil (open buildings command) in GC from a reference file

I have an instance where I need to project a curve from my GC model onto a reference file. the reference file (3D triangulated) consists of triangles to indicate its surface. these triangles are shapes and nothing else. I know that I can use the stencil command in open buildings to project my curve onto these triangles, but how would you do this in GC?

Parents
  • Here a very short video.

    1. as Wayne suggested, createthe Range and get polygons from Range

    2. convert these polygons to Bsplinesurfaces

    3. get the cure from the same Range and extrud to bsplinesurface

    4. get curve from surface-surface intersection



  • Hi Karsten,

    That is a good approach. I didn't think of that as a first step. Much nicer approach.

    One point for you Richard is the type of data you need out the other side. Are you after Bspline curve info or lines etc, might change the way to choose to create the curve.

    One thing I noticed about your approach Karsten is when I applied it to my example file the curve node does include a range of unsuccessful curves in the node. If you add it to a Watch, in my example I ended up with around 500 elements most of which were not successful. And they appeared as separate pieces which makes sense given the original bsplinesurfaces were all individual pieces. So adding a new node say like a curve by compositecurves returns an error as it has unsuccessful members .

    If we did include a bit of an expression in the input box for the new curve, say something like:

    from CV in curve1 where CV.Success == true

    it would give us a new single curve.

    I did a quick test with a loop in a function script that did a check to make sure the curve had a length > 0

    But an expression might be faster, just depends on what you are doing I suppose.

    I included the txt file of the transactions if anyone is interested.

    Thanks

    Wayne

    transaction 1 stateChange 'Add baseCS'
    {
        gcModel
        {
            node User.Objects.baseCS Bentley.GC.NodeTypes.CoordinateSystem
            {
                Technique                 = 'AtDGNModelOrigin';
                DGNModelName              = 'Design Model';
                SymbolSize                = 1;
                GraphLocation             = <auto> {40.0, 40.0};
            }
        }
    }
    
    transaction 2 stateChange 'Add point1, point2'
    {
        gcModel
        {
            node User.Objects.point2 Bentley.GC.NodeTypes.Point
            {
                Technique                 = 'ByCartesianCoordinates';
                CoordinateSystem          = baseCS;
                XTranslation              = <free> 527112.307762145;
                YTranslation              = <free> 72819.8991319005;
                ZTranslation              = 50000;
                GraphLocation             = <auto> {314.0, 235.43};
            }
            node User.Objects.point1 Bentley.GC.NodeTypes.Point
            {
                Technique                 = 'ByCartesianCoordinates';
                CoordinateSystem          = baseCS;
                XTranslation              = <free> 355389.29129902;
                YTranslation              = <free> 354893.94018261;
                ZTranslation              = <free> 0.0;
                GraphLocation             = <auto> {314.0, 40.0};
            }
        }
    }
    
    transaction 3 stateChange 'Add range1'
    {
        gcModel
        {
            node User.Objects.range1 Bentley.GC.NodeTypes.Range
            {
                Technique                 = 'ByLowHighRangePoints';
                LowPoint                  = point1;
                HighPoint                 = point2;
                GraphLocation             = {579.0, 169.667};
            }
        }
    }
    
    transaction 4 stateChange 'Add polygon1'
    {
        gcModel
        {
            node User.Objects.polygon1 Bentley.GC.NodeTypes.Polygon
            {
                Technique                 = 'FromElementsInRange';
                ElementRange              = range1;
                RangeAction               = RangeOption.Inside;
                ScaleFactor               = 1.0;
                GraphLocation             = {776.333, 164.333};
            }
        }
    }
    
    transaction 5 stateChange 'Add bsplineSurface1'
    {
        gcModel
        {
            node User.Objects.bsplineSurface1 Bentley.GC.NodeTypes.BSplineSurface
            {
                Technique                 = 'FromClosedCurve';
                ClosedCurve               = polygon1;
                GraphLocation             = {937.0, 3.667};
            }
        }
    }
    
    transaction 6 stateChange 'Add point3', suppressed
    {
        gcModel
        {
            node User.Objects.point3 Bentley.GC.NodeTypes.Point
            {
                Technique                 = 'ByFunction';
                Function                  = function (Polygon InputPolygons, int ReduceDetail)
                                            {
                                            Point MyPointList = {};
                                            double MyXYZList = {};
                                            for (int i = 0; i <InputPolygons.Count; ++i)
                                            {
                                            Point MyPolyPoints = new Point().ByParameterAlongCurve(InputPolygons[i].ControlPolygon.LineSegments,0);
                                                    for (int j = 0; j < MyPolyPoints.Count; ++j)
                                                    {
                                                    if (MyXYZList.Contains(MyPolyPoints[j].XYZ) == false)
                                                            {
                                                            MyXYZList.Add(MyPolyPoints[j].XYZ);
                                                            Point MyPt = new Point().ByCoordinateList(baseCS,MyPolyPoints[j].XYZ);
                                                            MyPointList.Add(MyPt);            
                                                            }
                                              
                                                    }
                                              
                                            }
                                                if (ReduceDetail >1)
                                                {
                                                int MyFilter = Series(0,MyPointList.Count,ReduceDetail);
                                                Point MyPointListFiltered = MembersAt(MyPointList,MyFilter);
                                                return MyPointListFiltered;
                                                }
                                                else
                                                {
                                                return MyPointList;
                                                }
                                            };
                DebuggerTrigger           = DebuggerTriggerLevel.Breakpoints;
                InputPolygons             = polygon1;
                ReduceDetail              = 0;
                GraphLocation             = {1143.0, 77.666, 0.0, 155.43};
            }
        }
    }
    
    transaction 7 stateChange 'Add mesh1', suppressed
    {
        gcModel
        {
            node User.Objects.mesh1 Bentley.GC.NodeTypes.Mesh
            {
                Technique                 = 'FromPointSet';
                Points                    = point3;
                GraphLocation             = {1372.871, 102.422};
            }
        }
    }
    
    transaction 8 stateChange 'Add point4'
    {
        gcModel
        {
            node User.Objects.point4 Bentley.GC.NodeTypes.Point
            {
                Technique                 = 'ByCartesianCoordinates';
                CoordinateSystem          = baseCS;
                XTranslation              = <free> 506185.488551585;
                YTranslation              = <free> 423256.862795336;
                ZTranslation              = <free> 0.0;
                GraphLocation             = <auto> {1684.0, 40.0};
            }
        }
    }
    
    transaction 9 stateChange 'Add point5'
    {
        gcModel
        {
            node User.Objects.point5 Bentley.GC.NodeTypes.Point
            {
                Technique                 = 'ByCartesianCoordinates';
                CoordinateSystem          = baseCS;
                XTranslation              = <free> 315382.136925891;
                YTranslation              = <free> 350582.764882708;
                ZTranslation              = <free> 0.0;
                GraphLocation             = <auto> {1684.0, 235.43};
            }
        }
    }
    
    transaction 10 stateChange 'Add point6'
    {
        gcModel
        {
            node User.Objects.point6 Bentley.GC.NodeTypes.Point
            {
                Technique                 = 'ByCartesianCoordinates';
                CoordinateSystem          = baseCS;
                XTranslation              = <free> 554809.568482004;
                YTranslation              = <free> 150421.054530131;
                ZTranslation              = <free> 0.0;
                GraphLocation             = <auto> {1684.0, 430.86};
            }
        }
    }
    
    transaction 11 stateChange 'Add point7'
    {
        gcModel
        {
            node User.Objects.point7 Bentley.GC.NodeTypes.Point
            {
                Technique                 = 'ByCartesianCoordinates';
                CoordinateSystem          = baseCS;
                XTranslation              = <free> 264296.078264818;
                YTranslation              = <free> 32787.557061385;
                ZTranslation              = <free> 0.0;
                GraphLocation             = <auto> {1684.0, 626.29};
            }
        }
    }
    
    transaction 12 stateChange 'Add bsplineCurve1'
    {
        gcModel
        {
            node User.Objects.bsplineCurve1 Bentley.GC.NodeTypes.BSplineCurve
            {
                Technique                 = 'ByPoles';
                Poles                     = { point4,point5,point6,point7 };
                Order                     = 0;
                GraphLocation             = <auto> {1958.0, 40.0};
            }
        }
    }
    
    transaction 13 stateChange 'Add bsplineCurve2, bsplineSurface2, curve1'
    {
        gcModel
        {
            node User.Objects.bsplineSurface2 Bentley.GC.NodeTypes.BSplineSurface
            {
                Technique                 = 'SurfaceOfProjection';
                CurveToProject            = bsplineCurve1;
                OffsetAboveCurve          = 50000;
                OffsetBelowCurve          = 0;
                GraphLocation             = {2403.613, 211.88};
            }
            node User.Objects.bsplineCurve2 Bentley.GC.NodeTypes.BSplineCurve
            {
                Technique                 = 'ByPoles';
                GraphLocation             = {2351.773, -18.52};
            }
            node User.Objects.curve1 Bentley.GC.NodeTypes.Curve
            {
                Technique                 = 'SurfaceSurfaceIntersection';
                Surface0                  = bsplineSurface2;
                Surface1                  = bsplineSurface1;
                GraphLocation             = {2165.533, 268.52};
            }
        }
    }
    
    transaction 14 stateChange 'Change curve1; delete bsplineCurve2'
    {
        gcModel
        {
            delete User.Objects.bsplineCurve2;
            node User.Objects.curve1 Bentley.GC.NodeTypes.Curve
            {
                GraphLocation             = {2633.533, 346.92};
            }
        }
    }
    
    transaction 15 stateChange 'Add curve2, curve3, curve4; change curve1'
    {
        gcModel
        {
            node User.Objects.curve2 Bentley.GC.NodeTypes.Curve
            {
                Technique                 = 'ByFunction';
                Function                  = function (BSplineSurface InputSurface1,BSplineSurface InputSurface2)
                                            {
                                            Curve MyCurveList = {};
                                             
                                            for (int i = 0; i < InputSurface1.Count; ++i)
                                            {
                                            Curve MyCurve = new Curve().SurfaceSurfaceIntersection(InputSurface1[i],InputSurface2);
                                            if (MyCurve.Length > 0)
                                            {
                                            MyCurveList.Add(MyCurve);
                                            }
                                                
                                            }
                                             
                                            return MyCurveList;
                                             
                                             
                                            };
                InputSurface1             = bsplineSurface1;
                InputSurface2             = bsplineSurface2;
                GraphLocation             = {2881.915, 154.667};
            }
            node User.Objects.curve1 Bentley.GC.NodeTypes.Curve
            {
                GraphLocation             = {2874.333, 357.32};
            }
            node User.Objects.curve3 Bentley.GC.NodeTypes.Curve
            {
                Technique                 = 'CompositeCurves';
                Curves                    = curve2;
                GraphLocation             = {3229.915, 174.667};
            }
            node User.Objects.curve4 Bentley.GC.NodeTypes.Curve
            {
                Technique                 = 'CompositeCurves';
                Curves                    = curve1;
                GraphLocation             = {3242.515, 368.267};
            }
        }
    }
    
    transaction 16 stateChange 'Change curve1, curve2, curve3, curve4'
    {
        gcModel
        {
            node User.Objects.curve2 Bentley.GC.NodeTypes.Curve
            {
                GraphLocation             = {2874.715, 215.467, 0.0, 142.41};
            }
            node User.Objects.curve1 Bentley.GC.NodeTypes.Curve
            {
                GraphLocation             = {2868.733, 18.12};
            }
            node User.Objects.curve3 Bentley.GC.NodeTypes.Curve
            {
                GraphLocation             = {3222.715, 235.467};
            }
            node User.Objects.curve4 Bentley.GC.NodeTypes.Curve
            {
                GraphLocation             = {3236.915, 29.067};
            }
        }
    }
    
    transaction 17 stateChange 'Add expression1; change curve4'
    {
        gcModel
        {
            node User.Objects.curve4 Bentley.GC.NodeTypes.Curve
            {
                Technique                 = 'CompositeCurves';
                Curves                    = from CV in curve1 where CV.Success == true;
            }
            node User.Objects.expression1 Bentley.GC.NodeTypes.Expression
            {
                Technique                 = 'Default';
                Value                     = from CV in curve1 where CV.Success == true;
                GraphLocation             = {3061.126, -231.455, 0.0, 233.538};
            }
        }
    }
    
    transaction 18 stateChange 'Add mesh2', suppressed
    {
        gcModel
        {
            node User.Objects.mesh2 Bentley.GC.NodeTypes.Mesh
            {
                Technique                 = 'ImprintCurveToMesh';
                Mesh                      = mesh1;
                Curve                     = bsplineCurve1;
                Direction                 = baseCS.ZDirection;
                SegmentsNumber            = 20;
                AutoHideInputs            = true;
                GraphLocation             = {2306.865, 63.07};
            }
        }
    }
    
    transaction 19 stateChange 'Add polygon2', suppressed
    {
        gcModel
        {
            node User.Objects.polygon2 Bentley.GC.NodeTypes.Polygon
            {
                Technique                 = 'FromMesh';
                Mesh                      = mesh2;
                AutoHideInputs            = true;
                GraphLocation             = {2554.87, 72.622};
            }
        }
    }
    
    transaction 20 stateChange 'Add point8, point9', suppressed
    {
        gcModel
        {
            node User.Objects.point9 Bentley.GC.NodeTypes.Point
            {
                Technique                 = 'ByFunction';
                Function                  = function (Polygon InputPolygons, int ReduceDetail)
                                            {
                                            Point MyPointList = {};
                                            double MyXYZList = {};
                                            for (int i = 0; i <InputPolygons.Count; ++i)
                                            {
                                            Point MyPolyPoints = new Point().ByParameterAlongCurve(InputPolygons[i].ControlPolygon.LineSegments,0);
                                                    for (int j = 0; j < MyPolyPoints.Count; ++j)
                                                    {
                                                    if (MyXYZList.Contains(MyPolyPoints[j].XYZ) == false)
                                                            {
                                                            MyXYZList.Add(MyPolyPoints[j].XYZ);
                                                            Point MyPt = new Point().ByCoordinateList(baseCS,MyPolyPoints[j].XYZ);
                                                            MyPointList.Add(MyPt);            
                                                            }
                                              
                                                    }
                                              
                                            }
                                                if (ReduceDetail >1)
                                                {
                                                int MyFilter = Series(0,MyPointList.Count,ReduceDetail);
                                                Point MyPointListFiltered = MembersAt(MyPointList,MyFilter);
                                                return MyPointListFiltered;
                                                }
                                                else
                                                {
                                                return MyPointList;
                                                }
                                            };
                DebuggerTrigger           = DebuggerTriggerLevel.Breakpoints;
                InputPolygons             = polygon2;
                ReduceDetail              = 0;
                GraphLocation             = {2478.286, 309.614, 0.0, 155.43};
            }
            node User.Objects.point8 Bentley.GC.NodeTypes.Point
            {
                Technique                 = 'ByFunction';
                Function                  = function (Point InputPoints1, Point InputPoints2)
                                            {
                                            Point MyPointList = {};
                                            double Pointlist1 = Round(InputPoints1.XYZ,2);
                                            double Pointlist2 = Round(InputPoints2.XYZ,2);
                                            for (int i = 0; i <Pointlist2.Count; ++i)
                                            {
                                            if (Pointlist1.Contains(Pointlist2[i]) == false)
                                                            {
                                                            Point MyPt = new Point().ByCoordinateList(baseCS,Pointlist2[i]);
                                                            MyPointList.Add(MyPt);            
                                                            }
                                             
                                            }
                                            return MyPointList;
                                            };
                DebuggerTrigger           = DebuggerTriggerLevel.Breakpoints;
                InputPoints1              = point3;
                InputPoints2              = point9;
                GraphLocation             = {2771.446, 419.374};
            }
        }
    }
    
    transaction 21 stateChange 'Add polyLine2', suppressed
    {
        gcModel
        {
            node User.Objects.polyLine2 Bentley.GC.NodeTypes.PolyLine
            {
                Technique                 = 'ByVertices';
                Vertices                  = from pt in point8 orderby pt.Y;
                GraphLocation             = {3124.499, 386.137};
            }
        }
    }
    

  • Thanks Wayne, good observation and very helpful script. I didn't check the output for empty Elements as I only create a small test case. Not sure if it's a Time issue when you check a small curve against a huge Terrain. For that situation it may be an idea to create a range around the curve and select the polygons from here.



Reply Children
No Data