2024-08-11 04:04 PM - last edited on 2024-09-09 11:27 AM by Doreena Deng
Hello everyone,
I'm encountering an issue while setting parameters for certain objects using the Archicad API.
I have an instance of the API_ChangeParamType class (let's refer to it as object). This object has some crucial attributes, specifically name and uStrValue.
I've correctly assigned object.name as "connectionType". However, I'm facing difficulties with object.uStrValue, which is being cast into an unsigned short pointer through this conversion: (GS::unchar_t*)connection_type_str.ToUStr().Get(). This conversion returns either 102 or 115.
I'm not entirely sure what these values represent, but I suspect there might be an internal mapping of connection type strings to these unsigned short values within the Graphisoft API. For example, how would the connection type "spigot-spigot" be mapped in this context?
The problem I'm encountering is that when I inspect the object's property in Archicad, the connection type consistently shows as "flat-flat" regardless of what I set.
Has anyone else experienced this issue? If so, how did you resolve it?
Operating system used: Windows 10
2024-08-22 08:34 AM - edited 2024-08-23 11:00 AM
Hi,
I wouldn't say that the conversion returns 102 or 115. Those are the values pointed to by the pointer (the first letter of the string). They are ascii/unicode codepoints. 102 = f and 115 = s. Which is consistent to the two entries you've mentioned (flat-flat and spigot-spigot). Just assigning that pointer to uStrValue won't work, because of ownership/memory issues (What happens to values in memory where the pointer points to if the connection_type_str goes out of context and is destroyed?)
You'll need GS::ucscpy to actually copy the content to uStrValue.
Something like this:
GS::ucscpy(object.uStrValue, "spigot-spigot");
Hope that helps,
Bernd
2024-08-23 01:26 PM
Thank you for the help! I have checked once again and implemented your solution which compiled well.
So I carefully checked and made sure that the variable, storing uchar_t * will not get out of the scope so it could be properly used in the changing the pipe property.
Yet, however, when I try to change the parameter of the structure using ACAPI_LibraryPart_ChangeAParameter() that accepts a data structure that basically looks like:
{
char[] name = "connectionType",
...
...
...
unsigned short * uStrValue = 0x00000044434f9724 {115}
...
}
Could it also be possible that after the change I need to execute some other form of the command so the change values are, kinda, emplaced fully into the graphisoft element?
2024-08-23 02:37 PM
Have you seen the example code using API_ChangeParamType here: ACAPI_LibraryPart_OpenParameters
This might help. If not, can you post some of your code so we can see what you've done so far?
2024-09-02 10:09 AM
Hello. Thank you for sharing the link. Yes, I have checked it. However, something still is wrong. Do you know by any chance is there exists kind of a list of properties that can be changed and to what are they mapped? For example, is "Connection type" mapped to "connectionType" or "connection_type" or else, and what about other properties?
2024-09-02 10:22 AM
I don't understand the question. I recommend that you post some code showing what you've done so far, pinpointing:
- where something appears to be wrong;
- what you expected to happen;
- what has actually happened.
I think it should be possible to solve the problem then.