We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2023-03-15 12:31 PM - last edited on 2024-09-09 11:25 AM by Doreena Deng
Is there any way to lock GDL using API C++?
for example
1. When the api is executed, the cpu id is read, and if it is correct, a specific variable is created so that GDL can read this variable so that the value of GDL can be changed.
2. How to create a variable in the api c++ model view option so that GDL can read this variable and change the value of GDL if correct
It's not my opinion, it's a question I'm asking because I'm curious about how I can do it because someone told me that they are locking GDL using the api.
2023-03-15 08:19 PM
I asked AI and he said:
"It is not possible to "lock" GDL using the API in ARCHICAD. GDL is a programming language used to create parametric objects in ARCHICAD, and it can be freely modified by the user. The API provides a way to interact with ARCHICAD programmatically, but it does not provide a way to prevent the user from modifying GDL code.
That being said, it is possible to use the API to create custom parameters or variables that can be used by GDL scripts. For example, you could create a custom parameter that stores a value, and then read that value in a GDL script to modify the behavior of an object.
To create a custom parameter using the ARCHICAD API, you can use the ACAPI_Parameter_Create function. Here's an example of how you could create a custom parameter named "MyParam" that stores a Boolean value:
API_ParID paramId = ACAPI_Parameter_Create("MyParam", APIParBooleanType);
You can then set the value of the parameter using the ACAPI_Parameter_SetValue function:
API_ParValue paramValue;
BNZeroMemory(¶mValue, sizeof(paramValue));
paramValue.boolValue = true; // set the parameter value to true
ACAPI_Parameter_SetValue(paramId, ¶mValue, sizeof(paramValue));
In your GDL script, you can read the value of the parameter using the "Parameter" command:
Parameter("MyParam", MyParam)
The value of the "MyParam" variable in the GDL script will be set to the value of the "MyParam" custom parameter you created using the API.
Note that this approach does not "lock" GDL in any way, as the user can still modify the GDL code directly if they choose to do so. However, it does provide a way to create custom parameters that can be used to modify the behavior of objects created with GDL."
2023-03-16 03:13 AM - edited 2023-03-20 05:53 AM
The variable you are talking about is a variable within archicad.
That means you can call it from GDL.
thank you
2023-03-20 05:51 AM - edited 2023-03-20 05:52 AM
I'm trying to study ACAPI_Parameter_Create.
But which manual should I look at?
I couldn't find the function in apidevkit.chm.
It would be more appreciated if you could point me to a sample file.
2023-03-21 09:20 AM
All warning messages appear.
Are there any items that need to be included?
I would like to know the manual.
I can't find it no matter how much I look for it.
2023-03-24 01:23 PM
Those functions don't exist in the Archicad C++ API. @Ernest Atanasiu cited an answer from an AI which seems to have hallucinated the functions. The whole AI answer is incorrect in many different ways, I would completely disregard it in your case.
2023-03-25 01:53 AM
I also asked ChatGPT about GDL-related things for fun. It gave me incorrect answers almost every time, it is really not a reliable source of GDL and Archicad API knowledge.
2023-04-27 04:22 PM - last edited on 2023-04-27 04:37 PM by Laszlo Nagy
Sorry I didn't specify, I don't know GDL to correct ChatGPT but I wanted to see if it works.
I reposted the question again and I got a different answer. Is this any good?
Yes, it is possible to lock GDL using API C++. You can use the API to create a custom parameter or attribute for your GDL object, which can be set or retrieved programmatically.
To achieve your specific use case, you can follow the following steps:
1. Use the API to read the CPU ID of the computer where the ArchiCAD application is running.
2. Compare the CPU ID with the correct value, and if it matches, create a custom parameter or attribute in the GDL object with a specific name and value.
3. In the GDL object, read the value of the custom parameter or attribute created in step 2 and check if it matches the correct value.
4. If the value matches, you can allow the GDL object to perform the required action or change its behavior.
To create a custom parameter or attribute in the API C++ model view option, you can use the `API_Attribute` and `API_Property` structures provided by the API. Here's an example of how you can create a custom attribute:
API_Attribute attr;
BNZeroMemory(&attr, sizeof(API_Attribute));
attr.header.typeID = API_Attr_Types;
attr.header.version = API_VERSION;
attr.header.attrType = APIAttr_IntegerType;
BNZeroMemory(&attr.name, sizeof(API_String128));
BNstrcpy(attr.name, "CustomAttr");
attr.header.flags = APIAttr_Permanent;
attr.int32 = 123;
GSErrCode err = ACAPI_Attribute_Create(&attr, API_ANY);
if (err != NoError) {
// handle error
}
This code creates a custom attribute named "CustomAttr" with an integer value of 123.
In your GDL object, you can read the value of this attribute using the `Attribute` function, like this:
```
IF Attribute ("CustomAttr") = 123 THEN
! perform action
ENDIF
```
This code checks if the value of the "CustomAttr" attribute is 123 and performs the required action if it is true.
2023-04-27 05:38 PM
I couldn't find the attribute function.