BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

Parametric design
About Rhino & Grasshopper and PARAM-O.
SOLVED!

Referencing ARCHICAD geometry through Python or C#

Anonymous
Not applicable
Hi!
I'm looking for a way to activate/simulate the "Set one 2D curve in ARCHICAD" through Python or C#.
Anyone familiar with the Grasshopper.Kernel SDK https://developer.rhino3d.com/wip/api/grasshopper/html/723c01da-9986-4db2-8f53-6f3a7494df75.htm and know how to prompt this command?


Explaination:
1. User clicks the toogle button and send a "True" boolean to Python/C# script
2. Python/C# component triggers the "Set one 2D curve in ARCHICAD" for selected component
3. User is directed to ARCHICAD to select one curve (same as happens when you right click on component and selects "Set one 2D curve in ARCHICAD"

I've been reding about controlling grasshopper components through code here:
http://james-ramsden.com/grasshopper-without-wires-transmit-data-to-any-component/
http://james-ramsden.com/read-and-edit-persistent-data-in-grasshopper-components/

Anyone who can help me out with this?
Thanks!
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Anonymous
Not applicable
TOPIC IS SOLVED OVER AT DISCOURSE

Here's the python code:
#Import libraries
import Grasshopper
import System

#Declare variables for Component Name & Menu Event
compName = "2DC"
menuEvent = "Set one 2D curve in ARCHICAD"

#Loop over objects in active document
for obj in Grasshopper.Instances.ActiveCanvas.Document.Objects:
    if obj.NickName == compName:
        menu = System.Windows.Forms.ToolStripDropDown()
        obj.AppendMenuItems(menu)

        for item in menu.Items:
            if item.Text == menuEvent:
                item.PerformClick()

View solution in original post

5 REPLIES 5
leceta
Expert
a parallel conversation is going on at McNeel's forum:
https://discourse.mcneel.com/t/programatically-launch-components-menu-item/69224/6

Ideally, someone here could give us some insight into the matter... I'm getting stuck with the exercise.

thanks
Solution
Anonymous
Not applicable
TOPIC IS SOLVED OVER AT DISCOURSE

Here's the python code:
#Import libraries
import Grasshopper
import System

#Declare variables for Component Name & Menu Event
compName = "2DC"
menuEvent = "Set one 2D curve in ARCHICAD"

#Loop over objects in active document
for obj in Grasshopper.Instances.ActiveCanvas.Document.Objects:
    if obj.NickName == compName:
        menu = System.Windows.Forms.ToolStripDropDown()
        obj.AppendMenuItems(menu)

        for item in menu.Items:
            if item.Text == menuEvent:
                item.PerformClick()
Anonymous
Not applicable
Hi, nice to see new faces working with GH Connection
Did it actually work?
What are you trying to do? Loop over element between AC and GH?
leceta
Expert
I guess he was trying to activate remotely (using Human UI generated forms) an archicad component´s menu item.
Anonymous
Not applicable
This is exactly what I'm looking for. I'm trying to set up a Human Interface for a GH-Archihcad connection script. And I need a *Set Curve in Archicad * button. (Also a set multiple windows button) Thing is I'm no good with Python. Any chance you could share your script?
Learn and get certified!