[OBD SDK Connect Update 8] - modifying Structural Elements with Open Building SDK (STFC-Api)

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

Parents
  • Hello,

    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 

  • Hi Mykolas,

    Is it possible that you send me the rest of the mdlstfstructuralmember_ header signatures? I want to create a structural member as well and at the moment I'm doing this with a dotnet workaround. This is not very satisfying.

    Greetings

    Manu

  • There is also additional helper class

    STFPSSectionList and STFPSSection

    here's header for them

    TFAPI_EXPOSE StatusInt mdlSTFPSSectionList_append
    (
    STFPSSectionList** ppThis,     
    STFPSSectionList*  pAppendList 
    );
    
    TFAPI_EXPOSE STFPSSectionList* mdlSTFPSSectionList_construct
    (
    void 
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSectionList_construct2
    (
    STFPSSectionList** ppThis,    
    STFPSSection*      pPsSection 
    );
    
    TFAPI_EXPOSE STFPSSectionList* mdlSTFPSSectionList_duplicate
    (
    STFPSSectionList* pThis 
    );
    
    TFAPI_EXPOSE void mdlSTFPSSectionList_free
    (
    STFPSSectionList** ppThis 
    );
    
    TFAPI_EXPOSE int mdlSTFPSSectionList_getCount
    (
    STFPSSectionList const* pThis 
    );
    
    TFAPI_EXPOSE int mdlSTFPSSectionList_getIndex
    (
    STFPSSectionList const* pThis,  
    STFPSSectionList const* pSearch 
    );
    
    TFAPI_EXPOSE STFPSSectionList* mdlSTFPSSectionList_getLast
    (
    STFPSSectionList* pThis 
    );
    
    TFAPI_EXPOSE STFPSSectionList* mdlSTFPSSectionList_getNext
    (
    STFPSSectionList* pThis 
    );
    
    TFAPI_EXPOSE STFPSSectionList* mdlSTFPSSectionList_getNode
    (
    STFPSSectionList* pThis, 
    int               index  
    );
    
    TFAPI_EXPOSE STFPSSection* mdlSTFPSSectionList_getPSSection
    (
    STFPSSectionList* pThis 
    );
    
    TFAPI_EXPOSE void mdlSTFPSSectionList_insertList
    (
    STFPSSectionList* pThis,  
    STFPSSectionList* pInsert 
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSectionList_prepend
    (
    STFPSSectionList** ppThis, 
    STFPSSectionList*  pAdd    
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSectionList_reverse
    (
    STFPSSectionList** ppThis 
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSectionList_setNext
    (
    STFPSSectionList* pThis, 
    STFPSSectionList* pNext  
    );
    
    TFAPI_EXPOSE STFPSSectionList* mdlSTFPSSectionList_unlinkNode
    (
    STFPSSectionList** ppThis, 
    STFPSSectionList*  pRemove 
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSection_duplicate
    (
    STFPSSection*      pThis, 
    STFPSSectionList** ppCopy 
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSection_initialize
    (
    STFPSSection* pThis 
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSection_setFullCrossSection
    (
    STFPSSection* pThis,          
    WChar const*  fullSectionName 
    );
    
    TFAPI_EXPOSE TFWStringList* mdlSTFPSSection_getFullSectionName
    (
    STFPSSection const* pThis 
    );
    
    TFAPI_EXPOSE bool mdlSTFPSSection_taperingIsPossible
    (
    STFPSSection const* pThis 
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSection_setCrossSection
    (
    STFPSSection* pThis,        
    int           sectionType,  
    WChar const*  sectionClass, 
    WChar const*  sectionName   
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSection_swap
    (
    STFPSSection* pThis, 
    STFPSSection* pThat  
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSection_init
    (
    STFPSSection* pThis,      
    WChar const*  sectionName 
    );
    
    TFAPI_EXPOSE bool mdlSTFPSSection_isValid
    (
    STFPSSection const* pThis 
    );
    
    TFAPI_EXPOSE bool mdlSTFPSSection_hasCentroid
    (
    STFPSSection* pThis 
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSection_getCentroid
    (
    STFPSSection* pThis,     
    DPoint2d*     pCentroid, 
    bool          reflected  
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSection_getInsertPointOffset
    (
    STFPSSection const* pThis,            
    DPoint2d*           pOffset,          
    int                 insertPointIndex, 
    bool                reflected         
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSection_setModelRef
    (
    STFPSSection* pThis,    
    DgnModelRefP  pModelRef 
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSection_getWidth
    (
    STFPSSection const* pThis, 
    double*             pWidth 
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSection_getHeight
    (
    STFPSSection const* pThis,  
    double*             pHeight 
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSection_getWeight
    (
    STFPSSection const* pThis,  
    double*             pWeight 
    );
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSection_getFlangeThickness
    (
    STFPSSection const* pThis,           
    double*             pFlangeThickness 
    );
    
    
    TFAPI_EXPOSE StatusInt mdlSTFPSSection_initByRectangularProps
    (
    STFPSSection* pThis, 
    double        width, 
    double        height 
    );

  • Great!

    I think, now I have the tools I need.

    Thanks a lot! Maybe you- could give me a small example for a concrete shape and a steel beam. But only if it's not too time intensive. I could find out by myself but probably it would cost me a lot of time. 

  • Here are some simple examples to place concrete and steel beams for US dataset

    template <typename T, typename DeleteF> static [[nodiscard]] std::unique_ptr<T, DeleteF> tfmake_unique(T* myObject, DeleteF deleteF) noexcept
        {
        return std::unique_ptr<T, DeleteF>(myObject, deleteF);
        }
    
    static void placeMember(WChar const* catalogType, WChar const* catalogName, int sectionType, WChar const* sectionClass, WChar const* sectionName)
        {
        if (auto pStructuralList = tfmake_unique(mdlSTFStructuralMemberList_construct(), [](auto* p) { mdlSTFStructuralMemberList_free(&p); }))
            {
            STFStructuralMember* pMember = mdlSTFStructuralMemberList_getStructuralMember(pStructuralList.get());
    
            // hardcode the member's end points
            DPoint3d startPt{ 0, 0, 0 };
            DPoint3d endPt{ 0, 0, 0 };
            double lengthMU{ 10 };
    
            mdlSTFStructuralMember_setCatalogItem2(pMember, catalogType, catalogName, true);
            mdlSTFStructuralMember_setCrossSection(pMember, sectionType, sectionClass, sectionName);
    
            mdlCnv_masterToUOR(&endPt.y, lengthMU, mdlModelRef_getActive());
            mdlSTFStructuralMember_setPQPoints(pMember, &startPt, &endPt);
    
            // hardcode the member's placement point
            mdlSTFStructuralMember_setPlacementPoint(pMember, 8);
    
            //write and get the ElementDescriptor
            auto pED = tfmake_unique(mdlSTFStructuralMember_createElementWritten(pMember, mdlModelRef_getActive()), [](auto* p) { mdlElmdscr_freeAll(&p); });
            }
        }
    
    //1 standard shape
    //2 user shape
    //4 combined shape
    //5 weld shape
    //6 parametric shape RECTANGLE or CIRCLE class
    static void placeConcreteMember()
        {
        placeMember(L"Concrete Beam", L"Beams", 6, L"RECTANGLE", L"1x1"); //same for all datasets
        placeMember(L"Concrete Beam", L"Beams", 6, L"CIRCLE", L"1"); //same for all datasets
        placeMember(L"Concrete Beam", L"Beams", 2, L"HEXAGON", L"H10.0DIA"); //class & section name unique for US dataset
        }
    
    static void placeSteelMember()
        {
        placeMember(L"Steel Beam", L"Beams", 1, L"AISC_I_W", L"W10X12"); //class & section name unique for US dataset
        placeMember(L"Steel Beam", L"Beams", 2, L"HEXAGON HOLLOW", L"H18.0DIAX0.5"); //class & section name unique for US dataset
        placeMember(L"Steel Beam", L"Beams", 4, L"DOUBLE_ANGLES (AISC_I_C)", L"2L2-1_2X2-1_2X5_16X3_8"); //class & section name unique for US dataset
        placeMember(L"Steel Beam", L"Beams", 5, L"IMPERIAL", L"W10X15"); //class & section name unique for US dataset
        }

  • Thanks again. 

    But I'm a little bit surprised that you use C++17 Features. Is this possible with the MS-SDK? If I switch to c++17 I got a lot of Errors.

    What is your magic?

Reply Children
No Data