The optimal structural design is imperative to minimize material consumption and reduce the environmental impact of construction. Given the complexity in the formulation of structural design problems, the process of optimization is commonly performed using artificial intelligence (AI) global optimization, such as Genetic Algorithm (GA). However, the integration of AI-based optimization together with visual programming (VP) in building information modeling (BIM) projects warrants further investigation. This study proposes a workflow by combining structure analysis, VP, BIM, and GA to optimize trusses. The methodology encompasses several steps including: (i) generation of parametric trusses in Dynamo VP; (ii) performing the finite element modeling (FEM) using Robot Structural Analysis (RSA); (iii) retrieving and evaluating the FEM results interchangeably between Dynamo and RSA; (iv) finding the best solution using GA; and (v) importing the optimized model into Revit, enabling the user to perform simulations and engineering analysis, such as life cycle assessment (LCA) and quantity surveying. The feasibility of the proposed workflow was tested on benchmark problems and compared with open literature. The outcomes of this study offer insight into the opportunities and limitations of combining VP, GA, FEA, and BIM for structural optimization applications, particularly to enhance structural efficiency and sustainability in construction.