point grid by function - correctly labeled

Hi there,

I couldn't find any help on this topic - so two questions.

  • Is there any manual dealing with gc scripting - especially dealing with functions (for Connect Edition Version of GC)?
  • I'm fiddling around with a point grid function which gives me the correct point grid but just indexed incementally.
    How can I get this to give me a 'correct' indexed point grid[i][j]
    ...it's probably just some brackets at the right place.....

transaction 1 modelChange 'Add baseCS, cs1'
{
    node User.Objects.baseCS Bentley.GC.NodeTypes.CoordinateSystem
    {
        Technique                 = 'AtModelOrigin';
        DGNModelName              = 'Design Model';
        SymbolSize                = 1;
    }
    node User.Objects.cs1 Bentley.GC.NodeTypes.CoordinateSystem
    {
        Technique                 = 'ByUniversalTransform';
        CoordinateSystem          = baseCS;
        XTranslation              = <free> 4.77462954680272;
        YTranslation              = <free> -2.11263502763131;
        ZTranslation              = <free> 3.88403542625826;
        XRotation                 = 10;
        YRotation                 = 5;
    }
}

transaction 2 modelChange 'Add NrGrid'
{
    node User.Objects.NrGrid Bentley.GC.NodeTypes.Slider
    {
        Technique                 = 'Default';
        Value                     = 5.0;
        Minimum                   = 2;
        Maximum                   = 20;
        Resolution                = 1;
        SnapToTicks               = true;
    }
}

transaction 3 modelChange 'Add pts1'
{
    node User.Objects.pts1 Bentley.GC.NodeTypes.Point
    {
        Technique                 = 'ByFunction';
        Function                  = function (CoordinateSystem cs01)
                                    {          
                                     
                                      for (int i = 0; i < NrGrid.Value; ++i)
                                        {
                                            for (int j = 0; j < NrGrid.Value; ++j)
                                            {
                                                    
                                                Point pts1 = new Point(this) ;
                                                pts1.ByCartesianCoordinates(cs1,i,j,0);
                                            }
                                        }   
                                        
                                    };
        cs01                      = cs1;
    }
}

Ingo

Parents
  • Hi Ingo,

    There is information about scripting in the GenerativeComponents Help which is accessible in CONNECT Edition under the AECOsim Building Designer "Computational Design" workflow's Help ribbon tab's Content icon. It's in the section GCScript Programming.

    The SIG workshops November 2017 "Simple Scripting" and July 2018 "Zero to Simple Scripting" also deal with scripting. Latter SIG workshop recording still needs to be posted to the GC SIG learning path (https://learn.bentley.com/app/Public/ViewLearningPathDetails?lpId=111738).

    In your Point.ByFunction, points will need to be generated in a two-level hierarchy for indexing as two-dimensional array. In the outer loop, add "Point pntlist = new Point(this);" in the inner loop, change how you create the Point pts1, so that pts1 are grand-children of pts1. If this is confusing, then it's because your variable name in the function is the same as the Point node's top level name. The line in the inner loop becomes "Point pts1 = new Point(pntlist);" I suggest renaming that latter variable to e.g. "pnt":

    transaction 3 modelChange 'Add pts1'
    {
        node User.Objects.pts1 Bentley.GC.NodeTypes.Point
        {
            Technique                 = 'ByFunction';
            Function                  = function (CoordinateSystem cs01)
                                        {          
                                         
                                          for (int i = 0; i < NrGrid.Value; ++i)
                                            {
                                                Point pntlist = new Point(this);
                                                
                                                for (int j = 0; j < NrGrid.Value; ++j)
                                                {
                                                        
                                                    Point pnt = new Point(pntlist) ;
                                                    pnt.ByCartesianCoordinates(cs1,i,j,0);
                                                }
                                            }   
                                            
                                        };
            cs01                      = cs1;
        }
    }
    

    The point lists "pntlist" generated in each iteration of the outer loop are children of the top level Point node "pts1". The points "pnt" generated in the inner loop are generated as children to each "pntlist", and, therefore, as grand-children to "pts1". This generates a two-dimensional array of points. pts1[i][j] then indexes the j's grand-child point in the i's child point list of pts1.

    HTH,

         Volker

       

    Answer Verified By: Ingo 

Reply
  • Hi Ingo,

    There is information about scripting in the GenerativeComponents Help which is accessible in CONNECT Edition under the AECOsim Building Designer "Computational Design" workflow's Help ribbon tab's Content icon. It's in the section GCScript Programming.

    The SIG workshops November 2017 "Simple Scripting" and July 2018 "Zero to Simple Scripting" also deal with scripting. Latter SIG workshop recording still needs to be posted to the GC SIG learning path (https://learn.bentley.com/app/Public/ViewLearningPathDetails?lpId=111738).

    In your Point.ByFunction, points will need to be generated in a two-level hierarchy for indexing as two-dimensional array. In the outer loop, add "Point pntlist = new Point(this);" in the inner loop, change how you create the Point pts1, so that pts1 are grand-children of pts1. If this is confusing, then it's because your variable name in the function is the same as the Point node's top level name. The line in the inner loop becomes "Point pts1 = new Point(pntlist);" I suggest renaming that latter variable to e.g. "pnt":

    transaction 3 modelChange 'Add pts1'
    {
        node User.Objects.pts1 Bentley.GC.NodeTypes.Point
        {
            Technique                 = 'ByFunction';
            Function                  = function (CoordinateSystem cs01)
                                        {          
                                         
                                          for (int i = 0; i < NrGrid.Value; ++i)
                                            {
                                                Point pntlist = new Point(this);
                                                
                                                for (int j = 0; j < NrGrid.Value; ++j)
                                                {
                                                        
                                                    Point pnt = new Point(pntlist) ;
                                                    pnt.ByCartesianCoordinates(cs1,i,j,0);
                                                }
                                            }   
                                            
                                        };
            cs01                      = cs1;
        }
    }
    

    The point lists "pntlist" generated in each iteration of the outer loop are children of the top level Point node "pts1". The points "pnt" generated in the inner loop are generated as children to each "pntlist", and, therefore, as grand-children to "pts1". This generates a two-dimensional array of points. pts1[i][j] then indexes the j's grand-child point in the i's child point list of pts1.

    HTH,

         Volker

       

    Answer Verified By: Ingo 

Children