cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
2024 Technology Preview Program

2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations

Archicad C++ API
About Archicad add-on development using the C++ API.

Problems, problems, problems

Anonymous
Not applicable
Hy. I've just run acroos a very ... interesting problem. I'm trying to create Text and Label objects from an API script. The Memo.textContent field of the object shoud contain something like 119.45, 280.14, etc. Instead of the expected result, the object contains something like 119ÌÌÌÌÌÌÌÌÌsÌÌÌ or 280ÌÌÌÌÌÌÌÌÌÌÌÌÌ. The really tricky part is that I don't always get these amazing results, because the script runs as expected in 50% of the situations. Could this be a database related issue that I haven't figured out yet or it's just me on a wrong way to init pointer string variables in VC++?
3 REPLIES 3
Ralph Wessel
Mentor
Marius wrote:
I'm trying to create Text and Label objects from an API script. The Memo.textContent field of the object shoud contain something like 119.45, 280.14, etc. Instead of the expected result, the object contains something like 119ÌÌÌÌÌÌÌÌÌsÌÌÌ or 280ÌÌÌÌÌÌÌÌÌÌÌÌÌ.
Are you allocating space for the handle to store your text when you construct the memo fields? What you are describing suggests your text has been overwritten, which is likely to occur if you haven't allocated space for it - you could easily cause a crash when writing the text to an unallocated handle too. If this is the case, take a look at BMAllocateHandle for a start.

Ralph.
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Well, it works. I was using memset function. From now on I'll try to search for an Archicad API function to use instead of the ordinary C++ functions each time I'm in trouble.

Thanks a lot! Again!
Ralph Wessel
Mentor
Marius wrote:
Well, it works. I was using memset function. From now on I'll try to search for an Archicad API function to use instead of the ordinary C++ functions each time I'm in trouble.
memset wouldn't be appropriate anyway because it doesn't allocate a block of memory either - that function simply replicates a char for a specified number of times starting at a specified location.
By all means get to know what the API offers and use it. In the context of ArchiCAD development it will save you time and headaches, and improve compatibility as ArchiCAD changes.
I recommend that you look closely at the ArchiCAD API String Manager too.
Ralph Wessel BArch
Software Engineer Speckle Systems