Hello,
I need to change some Properties of a Steel Beam Element in Open Building Designer Update 8 using the C-Api "stfc-api"..
Until now I've been able to read the "LinearMember" out of the EditElementHandle and to change some Properties in it using
following Code:
virtual StatusInt _OnElementModify(EditElementHandleR eehSteelBeam) override { StatusInt statusInt; MSElementDescrP elmDescrP = eehSteelBeam .GetElementDescrP(); STFLinearMemberList* linearMemberListP=mdlSTFLinearMemberList_constructFromDescr(elmDescrP , false); //SUCCESS if (!linearMemberListP)return ERROR; STFLinearMember* linearMemberP=mdlSTFLinearMemberList_getLinearMember ( linearMemberListP ); //SUCCESS if (!linearMemberP)return ERROR; DPoint3d pP = { 0,0,0 }; DPoint3d pQ = { 0,0,0 }; mdlSTFLinearMember_getPQPoints(linearMemberP,&pP, &pQ); //SUCCESS pQ.z += 2000000; statusInt= mdlSTFLinearMember_setPQPoints(linearMemberP, &pP, &pQ); //SUCCESS statusInt=mdlSTFLinearMember_save(linearMemberP, false); //ERROR: 32768 //statusInt = mdlSTFLinearMember_replaceInDgn(linearMemberP); ////ERROR: 32768 mdlSTFLinearMemberList_free(&linearMemberListP); return SUCCESS;
But when I try to save it to the DGN It allways brings The ErrorSatus (StatusInt) = 32768 and nothing happens.
I tried "mdlSTFLinearMember_replaceInDgn" , "mdlSTFLinearMember_save" and "mdlSTFLinearMember_addToDgnExt" but nothing is working.
Hopefully there is sombody out there with some experience with the Open Building SDK.
Many thanks in advance for your efforts
Greetings
Manuel Höger
Softwareentwicklung | mhoeger@cadcom.de Tel: +49 30 - 53 63 62 – 44 | Mobil: +49 162 - 53 18 640
cadcom® Systemhaus GmbH Stralauer Platz 33 | Kontorhaus |10243 Berlin Tel: +49 30 - 53 63 62 – 0 | Fax: +49 30 - 53 63 62 - 30 www.cadcom.de
since Update 6, the default structural elements have been replaced with new generation structural elements. Most likely, the element handle eehSteelBeam contains this new generation structural element. The API for them is mdlSTFStructuralMember found in mdlstfstructuralmember.fdf and should be located next to mdlstflnrmem.fdf
The new functions to replace old ones are
mdlSTFStructuralMemberList_constructFromElementDescr
mdlSTFStructuralMemberList_getStructuralMember
mdlSTFStructuralMember_getPQPoints
mdlSTFStructuralMember_setPQPoints
mdlSTFStructuralMember_replaceInDgn
The old mdlSTFLinearMember API is still available for these new elements as read-only.
Please let me know if this solves the issue
Answer Verified By: Manuel Höger
Thanks for your suggestion.
I've looked 5 times now, but can't find the mdlstfstructuralmember.fdf in my Update 9 SDK. I'm quite sure that it is not existent in my ODSDK.
Regards
That's unfortunate. But the exports should still be there, can we try with forward declarations? Could you try to put this code before the _OnElementModify? If you're working with C, don't add the extern "C"
typedef void STFStructuralMember;typedef void STFStructuralMemberList;
extern "C" {STFStructuralMemberList* mdlSTFStructuralMemberList_constructFromElementDescr
(MSElementDescr* pDescr );
STFStructuralMember* mdlSTFStructuralMemberList_getStructuralMember(STFStructuralMemberList* pThis );
StatusInt mdlSTFStructuralMember_getPQPoints(STFStructuralMember* pThis, DPoint3d* pP, DPoint3d* pQ );
StatusInt mdlSTFStructuralMember_setPQPoints(STFStructuralMember* pThis, DPoint3d* pP, DPoint3d* pQ );
StatusInt mdlSTFStructuralMember_replaceInDgn(STFStructuralMember* pThis );}
I tried your proposal and it works fine until the replaceInDgn Function. It returns a Heavy Memory Error:
I used following Code:
Header:
#include <tfapi\tfdefines.h> typedef void STFStructuralMember; typedef void STFStructuralMemberList; extern "C" { TFAPI_EXPOSE STFStructuralMemberList* mdlSTFStructuralMemberList_constructFromElementDescr ( MSElementDescr* pDescr ); TFAPI_EXPOSE STFStructuralMember* mdlSTFStructuralMemberList_getStructuralMember ( STFStructuralMemberList* pThis ); TFAPI_EXPOSE StatusInt mdlSTFStructuralMember_getPQPoints ( STFStructuralMember* pThis, DPoint3d* pP, DPoint3d* pQ ); TFAPI_EXPOSE StatusInt mdlSTFStructuralMember_setPQPoints ( STFStructuralMember* pThis, DPoint3d* pP, DPoint3d* pQ ); TFAPI_EXPOSE StatusInt mdlSTFStructuralMember_replaceInDgn ( STFStructuralMember* pThis ); TFAPI_EXPOSE StatusInt mdlSTFStructuralMemberList_free ( STFStructuralMember* pThis ); }
Source
StatusInt ChangeStructuralLinearElementLength(EditElementHandleR eehSteelBeam) { StatusInt statusInt; MSElementDescrP elmDescrP = eehSteelBeam.GetElementDescrP(), elmDescrCopyP; auto elmDescrExtrP = eehSteelBeam.ExtractElementDescr(); STFStructuralMemberList* structuralMemberListP = mdlSTFStructuralMemberList_constructFromElementDescr(elmDescrP); //SUCCESS if (!structuralMemberListP)return ERROR; STFStructuralMember* structuralMemberP = mdlSTFStructuralMemberList_getStructuralMember(structuralMemberListP); //SUCCESS if (!structuralMemberP)return ERROR; DPoint3d pP = { 0,0,0 }; DPoint3d pQ = { 0,0,0 }; mdlSTFStructuralMember_getPQPoints(structuralMemberP, &pP, &pQ); //SUCCESS pQ.z += 2000000; statusInt = mdlSTFStructuralMember_setPQPoints(structuralMemberP, &pP, &pQ); //SUCCESS //statusInt = mdlSTFLinearMember_replaceInDgn(structuralMemberP); ////Memory Exception //Edit: statusInt = mdlSTFStructuralMember_replaceInDgn(structuralMemberP); //SUCCESS After Edit mdlSTFStructuralMemberList_free(&structuralMemberListP); return SUCCESS; }
Sorry my fault, Was too late yesterday... I missed to change this function. Now it works perfectly.
Wonderful! Thanks.
Maybe you have some more additional Function hints about placing Architectural (TriForma) Elements like a ladder or other parametric cell Elements (I try to place a Parametric (CEL) cell.? This would be so nice!
[OBD SDK C++ Update 9] Placing Triforma Element with "Loadables" - OpenBuildings | AECOsim | Speedikon | Forum - OpenBuildings | AECOsim | Speedikon - Bentley Communities
Wonderful, I will take a look at placing parametric cells with API