Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
  • Welcome
  • Products
  • Support
  • About
  • More
  • Cancel
GenerativeComponents
  • Product Communities
  • More
GenerativeComponents
GenerativeComponents Community Wiki Set a New Property Value to a Set of Selected Nodes
    • Sign in
    • +An Overview of GenerativeComponents
    • +Addin Content
    • +Bentley BIM Modeler Accreditation – Program Overview
    • +C# Sample Solution and other Add-ins
    • +GenerativeComponents Solutions
    • +Learn GenerativeComponents
    • +Reference Material
    • Support for GenerativeComponents
    • -Tutorials
      • 3D array copy surface
      • Add RFA data as BuildingContent to ABD with GC Extension
      • Cell Feature
      • Create a Set of Random Points
      • Creation of Global function from Custom function
      • Creation of Parabolic curve
      • Free Form Roof Example
      • GC Excel Feature
      • GenerativeComponents Essentials Course
      • How To Create Surface From Lines & Curves
      • How to Export GC elements
      • How to get concrete sections in the cross-section dialog in Generative Components
      • Landscape Bridge Example
      • +LawCurve
      • List Of Points With A Loop Example
      • Mesh feature 3d print
      • Modular Multiplication On Circle
      • +Operation Node
      • +Optimization with the Optimizer node type
      • Palm Tree Modeler
      • Point By Function Example
      • Points On Curve
      • Prime Number Pattern
      • Selection of Points
      • Selection of points based on Query Expressions
      • Selection of points based on range of indices
      • Set a New Property Value to a Set of Selected Nodes
      • Simple Bridge Example
      • Simple Equations To Describe Form Example
      • Simple Free Form Roof Example
      • Sin Tower
      • Skeleton
      • Sunflower Seed Pattern Modelling
      • Surface Division Basic Steps
      • Surface from Rails and Swept Sections
      • The use of Packager in Generative Components
      • +Tools and Techniques
      • Ulam Spiral From A Rectangular Spiral
      • Video Tutorials
      • Video Tutorials - Short Techniques
    • +User Projects
    • +Visualized Parametric Experimentations
    • +zed_Older Content

     
     Questions about this article, topic, or product? Click here. 

    Set a New Property Value to a Set of Selected Nodes

      Product(s): OpenBuildings Generative Components
      Version(s): CONNECT Edition
      Environment:  N\A

     

    Problem Description

    How can we set a new property value to a set of selected nodes based on a given criteria?
    In this wiki, the above requirement will be achieved with a sample problem related to selection of point nodes. We are going to select all the point nodes with X coordinates value equals to 100 and modify the part values of these selected point nodes.

    Solution

    The selection of nodes can be done with function Nodes(). This library function returns a list of all nodes or the nodes that fulfill the given criteria. Below are some examples of how the function works

    Get all nodes:
    Nodes()

    Get all Line nodes:
    Nodes(n=> n is Line)

    Get all nodes whose names start with "bspline":
    Nodes(n => n .Name.StartsWith('bspline')

    Get all nodes that have less than 5 vertices:
    Nodes(n => n is polygon && n.vertices.Count <5)

    To set the property of the selected nodes, we need to use the function SetPropertyValue(). This function sets a value to the mentioned property of the object. Below is one example of how it works.

    Set value 1 to the property LineWeight of the node line01
    SetPropertyValue(line01, 'LineWeight', 1)
    Note: the property name always needs to put in string format i.e quoted.

    With combination of the above functions and GC scripting, we can write a small function inside the FunctionCall node to achieve as mentioned in the problem description.

    function ( )
    {
        Node[] a = Nodes(n=> n is Point && n.X ==100);   // Select all point nodes those have X coordinate value equals to 100
        foreach( PointNode in a) 
        {
         SetPropertyValue(PointNode, 'Part', {'Grids','Bubbles'});   //set property 'Part' equals to value {'Grids','Bubbles'}
        }
        
        return a;
    
    }

    Update Model after the function is applied.

    Please go through the sample file Selection of Nodes and set property value.gct.

    • GC CONNECT Edition
    • nodes
    • GCscript
    • GenerativeComponents CONNECT Edition
    • OpenBuildings GenerativeComponents
    • Share
    • History
    • More
    • Cancel
    • Anik Mal Created by Bentley Colleague Anik Mal
    • When: Wed, Apr 1 2020 1:19 PM
    • Anik Mal Last revision by Bentley Colleague Anik Mal
    • When: Fri, May 15 2020 1:19 AM
    • Revisions: 7
    • Comments: 0
    Recommended
    Related
    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2021 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies