BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

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

Add-on for rounding measurements

pedrocollares
Enthusiast

Hi all,

 

I wonder if there's an add-on ever made for the following purpose:

 

In a current project we're developing, there's a bunch of bad measurement values (for example, 25.03 cm instead of 25.00 cm). And they're always really close to the correct measurement value.

 

Logically, we don't need the ".03" amount, it is only a matter of design inaccuracy. It would be great if we could run an 'element rounding-off' plug-in, which snaps every selected element to the closest round measure (admitting 0.5 and maybe 0.25), considering the project origin as a major reference to those measurements.

 

Anyone ever heard of such?

Architect / BIM Manager at IDEIA1 - www.ideia1.com.br
Archicad 26 / Windows 10 64
14 REPLIES 14
fabioferrini
Enthusiast

that would be great... if it existed it would win the award for the best useful plug-in in the world, for our studio!

Hey! I developed such label to our architecture firm and it currently belongs to our own library. But I could develop a similar label suiting your needs. Being the case you may e-mail me 🙂 (pedrocollares@gmail.com)

Architect / BIM Manager at IDEIA1 - www.ideia1.com.br
Archicad 26 / Windows 10 64
julienK
Advocate

here's a quick  demo for an addon checking wall length:

It checks all selected walls  and change the cut fill to red if  its length is not a multiple of the 'step' variable. This gives a quick visual reference to find errors in the model.

 

 

 

    void lengthCheck()
    {
        API_GetPointType     pointInfo;
        GS::Array<API_Guid>  inds;
        GSErrCode            err;
        API_SelectionInfo    selectionInfo;
        API_Elem_Head        tElemHead = {};
        GS::Array<API_Neig>  selNeigs;
        double  startX, endX, startY, endY, theta, dx, dy, Lprev,step,rem,L,eps;
        Int32               index;
        GS::UniString       strType,dir;
        GS::UniString       name, strName;
        API_Element         element = {} , mask;

        err = ACAPI_Selection_Get(&selectionInfo, &selNeigs, true);
        BMKillHandle((GSHandle*)&selectionInfo.marquee.coords);
        if (err != NoError && err != APIERR_NOSEL) {
            ErrorBeep("ACAPI_Selection_GetInfo", err);
            return;
        }

        ACAPI_ELEMENT_MASK_CLEAR(mask);
        ACAPI_ELEMENT_MASK_SET(mask, API_WallType, penOverride.overrideCutFillBackgroundPen);
        ACAPI_ELEMENT_MASK_SET(mask, API_WallType, penOverride.cutFillBackgroundPen);
        ACAPI_ELEMENT_MASK_SET(mask, API_WallType, penOverride.cutFillPen);
            for (index = 0; index < selectionInfo.sel_nElemEdit; index++) {
                // Get selected element
                BNZeroMemory(&element, sizeof(element));

                element.header.guid = selNeigs[index].guid;
                if (ACAPI_Element_Get(&element) != NoError) 
                    continue;

                startX = element.wall.begC.x;
                startY = element.wall.begC.y;
                endX = element.wall.endC.x;
                endY = element.wall.endC.y;

                step = 0.002500;
                eps =  0.0000100;


                if (abs(endX) > abs(startX)) {
                    dx = abs(endX - startX);
                }
                else {
                    dx = abs(startX - endX);
                }

                if (abs(endY) > abs(startY)) {
                    dy = abs(endY - startY);
                }
                else {
                    dy = abs(startY - endY);
                }
                
                
                L = sqrt(dx * dx + dy * dy);

                theta = atan2(dx, dy) / (2 * PI) * 360;

                if (dx < eps && dy > eps)  //vertical wall
                {   
                    Lprev = dy ;
                }

                if (dx > eps && dy < eps)  //horizontal wall
                {
                    Lprev =  dx;
                }

                if (dx > eps && dy > eps)       //if not orthogonal wall
                {
                    Lprev = L ;
                }
                rem = fmod(Lprev, step);
       
                if (rem >= eps && rem <  step - eps) {
            
                    element.wall.penOverride.overrideCutFillBackgroundPen = true;
                    element.wall.penOverride.cutFillBackgroundPen = 181;
                    element.wall.penOverride.cutFillPen = 181;

                    ACAPI_CallUndoableCommand("Element Test API Function",
                        [&]() -> GSErrCode {

                            err = ACAPI_Element_Change(&element, &mask, nullptr, 0, true);
                            if (err != NoError) {
                                ErrorBeep("elem change err", err);
                            }
                            return err;
                        });  
                }
            }
            return ; 
    }

 

 

 

 

 

 
 

Dear juliencuadra,

thank you so much! ❤️

have a nice day

 

Fabio

vdentello
Advocate

I'm developing that but still wasn't able to finish it.

Archicad User Since 2013
GDL Developer
Experimenting with API
from Brazil
Learn and get certified!

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!