cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove ALL level lines (sublines) from an existing mesh element via C++ API?

I'm working on a Tapir command (open sourve addon) and need to enable the modify meshes command to be able to remove all level lines from an existing mesh element via ACAPI_Element_Change. Creating a mesh with no level lines works fine (null handles from BMAllocateHandle(0, ...) are correctly interpreted by ACAPI_Element_Create). But I cannot figure out how to clear them on an existing mesh.
Context:
My GetDetailsOfElements reads level lines like this (following the official pattern):
if (elem.mesh.levelLines.nSubLines > 0) { ACAPI_Element_GetMemo(guid, &memo, APIMemoMask_MeshLevel); const GSSize nSublines = BMhGetSize(reinterpret_cast<GSHandle>(memo.meshLevelEnds)) / sizeof(Int32); // iterate sublines... }
So to get 0 sublines reported, I need either:
elem.mesh.levelLines.nSubLines == 0 stored in the element, or
BMhGetSize(memo.meshLevelEnds) < sizeof(Int32) after a successful change
Approaches I have tried — all result in the original 2 sublines being preserved:
1/Null handles + APIMemoMask_MeshLevel: Kill both meshLevelEnds and meshLevelCoords handles (null), set elem.mesh.levelLines.nSubLines = 0, pass APIMemoMask_MeshLevel in memoChangeMask . ArchiCAD appears to ignore null handles and keeps existing data. Result: still 2 sublines.
2/1-byte handle + APIMemoMask_MeshLevel: BMAllocateHandle(1, ALLOCATE_CLEAR, 0) for meshLevelEnds - BMhGetSize returns 8 (minimum physical allocation on 64-bit Windows) - 8 / sizeof(Int32) = 2. Still 2 sublines.
3/BMhSetSize(h, 0) (= BMReallocHandle(h, 0, 0, 0)): Same minimum size problem  still 8 bytes 2 sublines.
4/Element mask only (no APIMemoMask_MeshLevel): Set ACAPI_ELEMENT_MASK_SET(mask, API_MeshType, levelLines) with nSubLines = 0 but do NOT include APIMemoMask_MeshLevel in memoChangeMask  ArchiCAD does not update the stored nSubLines. Still 2 sublines.
5/ACAPI_Element_ChangeMemo with null memo: After a successful ACAPI_Element_Change, call:
API_ElementMemo zeroMemo = {}; ACAPI_Element_ChangeMemo(elem.header.guid, APIMemoMask_MeshLevel, &zeroMemo); Also ignored, still 2 sublines.
Questions:
1-Is it even possible to remove all level lines from an existing mesh via the API?
2-If yes, what is the correct approach? Does ACAPI_Element_Change support clearing memo components via null handles, or is there another mechanism?
3-Is there a minimum valid state for meshLevelEnds that ArchiCAD will accept as "no level lines"?
4-Would ACAPI_Element_Delete + ACAPI_Element_Create (with the same geometry but no sublines) be the only workaround (losing the original GUID)?
Any guidance would be appreciated. Thank you

Archicad 27 - GDL - PYTHON
0 Replies 0

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!