Graphisoft®

API Development KitVersion: 15

Frequently Asked Questions

This collection answers to the most frequently asked API related questions.

  1. I receive this error message: "This add-on cannot be validated. Please contact the distributor." What is the problem?
  2. How do I create a template library part to be used in my add-on?
  3. How do I create an associative dimension in ArchiCAD 8?
  4. (Win only) My add-on runs perfectly on my development machine, but when I install it on a demo machine it refuses to load.
  5. Can I compile a GDL add-on, which uses the services of the General API DevKit?
  6. How can I catch notifications immediately?
  7. We defined an icon in the GRC file in the 3.1 DevKit, but they doesn't seem to appear with 6.1, and I also receive a resource conversion error. Also, what do those three numbers mean in the resource?
  8. I'm creating a library part from my add-on, and I also put in a preview picture, but it doesn't appear.
  9. Is there a default callback for the simple popup menu-like custom control?
  10. (Win only) When I link my add-on, I receive the following warning: "LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library"
  11. How can I open a progress window when I have a long process running?
  12. I have a function which adjusts the additional parameter values of a placed object/window/door. It works fine in ArchiCAD 7, but not in ArchiCAD 8 or 9.
  13. When I read 3D data for an element I don't get the correct 3D-vertex world-coordinates. They are local coordinates for that element. So how can I retrieve the correct vertex information in world coordinates of an element?
  14. How can I make the standard DXF/DWG add-on export elements into DWG file?
  15. What's the required format of User Controls in the .grc file?

  1. I receive this error message: "This add-on cannot be validated. Please contact the distributor." What is the problem?

  2. Several problems may lead to this message:

     

  3. How do I create a template library part to be used in my add-on?

  4. You can find the answer here.

     

  5. How do I create an associative dimension in ArchiCAD?

    An example from the Automatic Dimensioning add-on shows how you can convert the old neig IDs to the new bool fields in API_Base:

    bool    NeigID2Line (API_NeigID neigID)
    {
        return (neigID == APINeig_WallOn          ||
                neigID == APINeig_WallPlOn        ||
                neigID == APINeig_WallPlOnClOff   ||
                neigID == APINeig_BeamOn          ||
                neigID == APINeig_CeilOn          ||
                neigID == APINeig_RoofOn          ||
                neigID == APINeig_MeshOn          ||
                neigID == APINeig_HatchOn         ||
                neigID == APINeig_LineOn          ||
                neigID == APINeig_ArcOn           ||
                neigID == APINeig_SplineOn);
    }
    
    bool    NeigID2Special (API_NeigID neigID)
    {
        return   (neigID == APINeig_WallPl    || neigID == APINeig_WallPlOn ||
                  neigID == APINeig_WallPlClOff || neigID == APINeig_WallPlOnClOff ||
                  neigID == APINeig_BeamHole  ||
                  neigID == APINeig_WindHole  ||
                  neigID == APINeig_DoorHole  ||
                  neigID == APINeig_MeshRidge || neigID == APINeig_MeshRidgeOn);
    }
    
    static void MakeDimelemForWD (API_DimElem* dimelem, const MyCoord& mc)
    {
        WallRef     wr;
        Int32       i;
    
        for (i = 1; i <= mc.wrs.Count (); i++) {
            wr = mc.wrs[i];
    
            if (wr.openingpt != NOOPENINGPT) {
                dimelem->base.base.typeID  = (wr.iswindow ? API_WindowID : API_DoorID);
                dimelem->base.base.special = NeigID2Special (wr.neigID);
                dimelem->base.base.line    = NeigID2Line (wr.neigID);
                dimelem->base.base.index   = wr.wdindex;
                dimelem->base.base.guid    = wr.guid;
                switch (wr.openingpt) {
                    case OPENINGPT0:
                        dimelem->base.base.inIndex = wr.inIndex;
                        break;
                    case OPENINGPT1:
                        dimelem->base.base.inIndex = wr.inIndex;
                        break;
                    default:
                        dimelem->base.base.inIndex = 4;   // center
                        break;
                }
                return;
            }
        }
    
        // Error if it comes here...
        return;
    }
    
  6. (Win only) My add-on runs perfectly on my development machine, but when I install it on a demo machine it refuses to load.

  7. This usually happens from one of the following reasons:

     

  8. Can I compile a GDL add-on, which uses the services of the General API DevKit?

  9. No. GDL add-ons use their own API environment, and that mixes quite badly with the General API running environment.

     

  10. How can I catch notifications immediately?

  11. Return APIAddon_Preload from your CheckEnvironment () function. This will ensure that your Initialize () function will be called immediately after the call to Registerface (), without requiring the user to perform any action. You can then safely install the notification callback function(s) from Initialize ().

     

  12. We defined an icon in the GRC file in the 3.1 DevKit, but they doesn't seem to appear with the newer devkits, and I also receive a resource conversion error. Also, what do those three numbers mean in the resource?

  13. 'GICN' 32501 "General Settings" {
       0  128  128
    }
    

    The '0 128 128' is the R/G/B color (respectively) of the transparent area in the icon; each component is in the range 0-255. The reason why is doesn't compile with DevKit 6.1 is because some of the colors (black and white) should be in fixed places within the icon's color table: black should be the first color, and white should be the last. Note that the icons are converted to 32-bit depth, so you cannot use arbitrary big sizes.

     

  14. I'm creating a library part from my add-on, and I also put in a preview picture, but it doesn't appear.

  15. From ArchiCAD 8 you should add the MIME type of the preview picture as a C string (with the terminating 0) to the beginning of the data handle containing the preview picture. (e.g. "image/png\0" for a PNG image)

     

  16. Is there a default callback for the simple popup menu-like custom control?

  17. No. You'll have to write your own callback to load the data from your resource file, and pass it to the user control with UC257SetData. You'll also have to call UC257SetType, and possibly UC257SetStyle. The DG_Test example now shows how you can work with these functions.

     

  18. (Win only) When I link my add-on, I receive the following warning:
    LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library

  19. This only means that you are compiling the debug version of your add-on (thus linking to the debug version of the runtime DLLs), whereas the libraries shipped with the DevKit are release versions (which are linked to the release version of the runtime DLLs). This doesn't cause any problem.

     

  20. How can I open a progress window when I have a long process running?

  21. In several ways:

    1. use the set of ACAPI_Interface functions (APIIo_InitProcessWindowID, etc.) provided by the API. This has a small problem: other processes within ArchiCAD are using the same progress window, and they can interfere with the information displayed by your add-on.
    2. use your own modeless palette as a process window.
    3. open a modal dialog, and drive the process from there. Since DevKit v4.1 you can switch databases even if a modal dialog is visible on the screen. See the Do_ProgressWindow function in the DG_Test example. This is the recommended solution at the moment.

  22. I have a function which adjusts the additional parameter values of a placed object/window/door. It works fine in ArchiCAD 7, but not in ArchiCAD 8 or 9.

  23. This problem usually occurs when you refer to the additional parameters by indices:

    (*memo.params)[27].value.real = 7.25;
    

    The problem is coming from the subtype hierarchy: an object/window/door in the hierarchy inherits the parameters of all of its ancestors. So, you should refer to a parameter by name instead of its index. This also means you'll have to look up the parameter by name before modify its value:

    static void SetParValue (API_AddParType *** addPars, const char * name, const double &val)
    
    {
        if (addPars == NULL || *addPars == NULL)
            return;
    
        Int32 ii, addParNum = BMGetHandleSize (reinterpret_cast<GSHandle> (*addPars)) / sizeof (API_AddParType);
        for (ii = 0; ii < addParNum; ii++) {
            if (CHCompareCStrings ((**addPars)[ii].name, name, CS_CaseInsensitive) == 0) {
                (**addPars)[ii].value.real = val;
                break;
            }
        }
    
        return;
    }   // SetParValue
    

     

  24. When I read 3D data for an element I don't get the correct 3D-vertex world-coordinates. They are local coordinates for that element. So how can I retrieve the correct vertex information in world coordinates of an element?

  25. Each 3D body contains a transformation matrix (see API_BodyType), which should be applied to the coordinates of the vertices. This allows us to store a body which has several instances very compactly (i.e. store the vertices just once, and have a different transformation matrix for every instance).

     

  26. How can I make the standard DXF/DWG add-on export elements into DWG file?

  27. You can find a simple example at the description of the ACAPI_Command_Call function.

     

  28. What's the required format of User Controls in the .grc file?

  29. The detailed description is here.