Quantcast
Channel: ArchiCAD-Talk - Developer Forum
Viewing all 564 articles
Browse latest View live

Selecting a tool for object insertion

$
0
0
Author:gehairing
Posted: Tue Feb 09, 2016 9:06 am (GMT+1)


Thanks a lot Ralph Smile

The "APIEnv_SetToolBoxModeID" is what i didn't find.

For placing the object in the model, i have already the code.
It uses "ACAPI_Element_ChangeDefaults" and works perfectly.

Have a nice day.


Use gravity for Z position

$
0
0
Author:vuego
Posted: Tue Feb 09, 2016 1:53 pm (GMT+1)


Talking to myself a bit more...

I could use TDGetHeightAtPoint() which will "Calculate the height of a triangulated mesh at a given location."

Unfortunately one of the parameters is a list of triangles. Browsing through mesh type and its memo, I do not think I can extract them from specified existing mesh.

To go a bit further... there is also a TDTriangulate() function. Wouldn't be a bit overkill using it on already defined (and triangulated) mesh?
_________________
ARCHICAD 18, Dell Studio i7, 8Gb Ram, Win7 64bit

Use gravity for Z position

$
0
0
Author:Ralph Wessel
Posted: Wed Feb 10, 2016 5:24 pm (GMT+1)


vuego wrote:
My Addon creates API_Element (GDL object) on user specified coordinates acquired with APIIo_GetPointID. X and Y coordinates are ok, Z coordinate is always zero. I would like to use gravity when picking a point on eg Mesh so Z coordinate gets populated too.

I don't know if there is a shortcut to achieving this. You could get the 3D body of the mesh from ModelAccess or the older 3D Manager (ACAPI_Element_Get3DInfo etc). You could then determine which face lies directly under the point of interest and the z level on the plane at that point.
_________________
Ralph Wessel
Cadimage

Use gravity for Z position

$
0
0
Author:vuego
Posted: Thu Feb 11, 2016 9:28 am (GMT+1)


I've decided to change my object creation concept.

Switched from APIelement creation to new element event observer and let user use default gravity functionality of AC. API magic is fired afterwards.
_________________
ARCHICAD 18, Dell Studio i7, 8Gb Ram, Win7 64bit

Start Edition

$
0
0
Author:stefan
Posted: Thu Feb 11, 2016 2:20 pm (GMT+1)


Does the Devkit also support ArchiCAD Start Edition?

E.g. can an ArchiCAD 19 APX run on ArchiCAD Start Edition 2016 (based on 19)?

I assume that you have to take care not to use methods that call into non-supported functionality (e.g. Publisher, ...).
_________________
--- stefan boeykens --- architect-engineer-musician ---
ArchiCAD18-19/Revit2016/SketchUp2015/Cinema4D16/Rhino5/Unity5
rMBP15:i7Quad2.3Ghz+16GB+nVidia650M/ElCapitan+Win10

http://bit.ly/17u87df

Get the Type ID and Variation ID from API_LibPart

$
0
0
Author:gehairing
Posted: Fri Feb 12, 2016 9:08 am (GMT+1)


Hello the forum Smile

I download library parts and insert them in Archicad projects.
To do the job correctly i need to know what is exactly the library part.
(a stair, a window, a door, a wall...)

For the moment i have this info in xml side-car files so i know exactly the type of the library part. I can fill in the "element.header.typeID" and "element.header.variationID" based on the data i have in my XML side-car.

But...

For some of my library parts i don't have the XML data so i don't know the type of the libpart.

How can i find "element.header.typeID" and "element.header.variationID" from a API_LibPart ?

I have the "API_LibTypeID" but this is not enough. By example, i can't know that a libpart is a "stair" by example.

SaveAs .obj (or .treejs)

$
0
0
Author:gehairing
Posted: Wed Feb 17, 2016 10:10 am (GMT+1)


Hello all Smile

I try to build a 3D preview from current selected object.
I have seen the ACAPI_Automate (APIDo_SaveID, ...) call but it seem's limited to the API_FTypeID list.

Is there another way to do a SaveAs for exporting the current selected item (or even all the current 3D model) to a .obj format.

In the File->Save As... command we have the .obj export.

Thanks.

Start Edition

$
0
0
Author:Ralph Wessel
Posted: Thu Feb 18, 2016 11:15 pm (GMT+1)


stefan wrote:
Does the Devkit also support ArchiCAD Start Edition?

E.g. can an ArchiCAD 19 APX run on ArchiCAD Start Edition 2016 (based on 19)?

I assume that you have to take care not to use methods that call into non-supported functionality (e.g. Publisher, ...).

Yes, I believe they're fully compatible (with the limitations you noted).
_________________
Ralph Wessel
Cadimage


Get the Type ID and Variation ID from API_LibPart

$
0
0
Author:Ralph Wessel
Posted: Fri Feb 19, 2016 10:54 am (GMT+1)


gehairing wrote:
i need to know what is exactly the library part.
(a stair, a window, a door, a wall...). [...] How can i find "element.header.typeID" and "element.header.variationID" from a API_LibPart ? I have the "API_LibTypeID" but this is not enough. By example, i can't know that a libpart is a "stair" by example.

You could deduce this from the library part subtype, API_LibPart::ownUnID. It's ancestry would determine what tool/type it's related to.
_________________
Ralph Wessel
Cadimage

SaveAs .obj (or .treejs)

$
0
0
Author:Ralph Wessel
Posted: Fri Feb 19, 2016 10:56 am (GMT+1)


gehairing wrote:
Is there another way to do a SaveAs for exporting the current selected item (or even all the current 3D model) to a .obj format.
In the File->Save As... command we have the .obj export.

Just to clarify – do you want to add your own export filter to the "Save As…" dialog from the 3D window? For saving as .obj?
_________________
Ralph Wessel
Cadimage

SaveAs .obj (or .treejs)

$
0
0
Author:gehairing
Posted: Mon Feb 22, 2016 9:41 am (GMT+1)


Hi Ralph,

No.

I'm uploading some LibraryParts on a distant server and i want to add a 3D preview of the library part.

Get the Type ID and Variation ID from API_LibPart

$
0
0
Author:gehairing
Posted: Mon Feb 22, 2016 11:00 am (GMT+1)


Thank you for the answer...but i don't understand what you mean.
Do you mean the ownUnID can give me an element from wich i can extract typeID and VariationID ?

I have tried playing around with something like this :

Code:
GS::UniString s = libPart.ownUnID;
   GS::Guid gs_guid(s);
   API_Element  element;
   BNZeroMemory (&element, sizeof (API_Element));
   element.header.guid  = GSGuid2APIGuid (gs_guid);
   GSErrCode err = ACAPI_Element_Get(&element);
   if(err == NoError)
   {
      typeID = element.header.typeID;
      variationID = element.header.variationID;
   }


But because i don't really know what it means i can't say why it doesn't work Laughing

Get the Type ID and Variation ID from API_LibPart

$
0
0
Author:Ralph Wessel
Posted: Mon Feb 22, 2016 1:02 pm (GMT+1)


gehairing wrote:
Do you mean the ownUnID can give me an element from wich i can extract typeID and VariationID ?

Library parts are organised in a hierarchical structure, so the 'subtype' of an object determines its parent and therefore its 'type'. If you refer to the attached image, you can see the ARCHICAD Subtype selection dialog with the Stairmaker subtype selected. This would make the object a type of 'Stair' (and also a type of 'Model Element').

You can use the subtype of your library parts to determine if they are descended from specific types, and therefore determine which tool they are associated with.
_________________
Ralph Wessel
Cadimage

SaveAs .obj (or .treejs)

$
0
0
Author:Ralph Wessel
Posted: Mon Feb 22, 2016 1:08 pm (GMT+1)


gehairing wrote:
I'm uploading some LibraryParts on a distant server and i want to add a 3D preview of the library part.

It depends on the required format for the data. You could temporarily place an instance of the library part in the project and extract its 3D geometry through ModelAccess or 3D Manager API. The temporary object can be deleted afterward. But then you would need to convert that data to the required output format.
_________________
Ralph Wessel
Cadimage

Library Part - array - GSHandle

$
0
0
Author:Xylios
Posted: Mon Feb 22, 2016 8:29 pm (GMT+1)


Hello there.

I have been trying to create library parts using the C++ API. However, I have encountered a problem when creating parameters for said library parts.

I can add parameters that are NOT arrays, using the different types (APIParT_Integer, etc...).

However, when I try to create parameters that are arrays, I do not seem to be handling the value.array correctly (GSHandle).

I'm trying to allocate memory for it, but my add-on keeps crashing.

Here is an excerpt of the code that is causing problems:

Code:
//...

(*addPars)[i].typeMod = 2;

(*addPars)[i].typeID = APIParT_Integer;
(*addPars)[i].dim1 = 5;
(*addPars)[i].dim2 = 1;

(*addPars)[i].value.array = BMAllocateHandle(sizeof(GSHandle), ALLOCATE_CLEAR, 0);
*(*addPars)[i].value.array = BMAllocatePtr(5 * sizeof(int), ALLOCATE_CLEAR, 0);

if ((*addPars)[i].value.array == NULL || *(*addPars)[i].value.array == NULL){
  ACAPI_WriteReport("NOPE!", true);
  return;
}

for (int j = 0; j < 5; j++){
  (int)((int *)*(*addPars)[i].value.array)[j] = msg.intarrays(intArrayCounter).lst(j);
}

//...


My question is how to correctly work with the array of the parameters.

Can someone help?

Thanks in advance,
Xylios


Library Part - array - GSHandle

$
0
0
Author:gehairing
Posted: Tue Feb 23, 2016 6:09 pm (GMT+1)


Hi,

Did you look at the \Examples\LibPart_Test\Src\LibPart_Test.cpp in the SDK samples folder ?

There is an example for creating lib parts.

In the method "Do_CreateLibraryPart" there is a code for creating simple parameters and also array parameters.

Here is a part of the code but the best is to look at the complete sample :

Code:
         pAddPar = &(*addPars)[3];
         pAddPar->typeID = APIParT_RealNum;
         pAddPar->typeMod = API_ParArray;
         pAddPar->dim1 = 3;
         pAddPar->dim2 = 4;
         CHTruncate ("matrix", pAddPar->name, sizeof (pAddPar->name));
         GS::ucscpy (pAddPar->uDescname, L("Array parameter with real numbers"));
         pAddPar->value.array = BMAllocateHandle (pAddPar->dim1 * pAddPar->dim2 * sizeof (double), ALLOCATE_CLEAR, 0);
         double** arrHdl = reinterpret_cast<double**>(pAddPar->value.array);
         for (Int32 k = 0; k < pAddPar->dim1; k++)
            for (Int32 j = 0; j < pAddPar->dim2; j++)
               (*arrHdl)[k * pAddPar->dim2 + j] = (k == j ? 1.1 : 0.0);

Library Part - array - GSHandle

$
0
0
Author:Xylios
Posted: Tue Feb 23, 2016 6:26 pm (GMT+1)


Hey.

Thank you for the reply. I have looked at the LibPart_Test, but it was from the ArchiCAD 18 DevKit (the one I'm currently using) and it did not had the array example. I assume that the one you are using is the one from the ArchiCAD 19 DevKit.

I will try to get the one from the most recent DevKit, thank you.

Get the Type ID and Variation ID from API_LibPart

$
0
0
Author:gehairing
Posted: Tue Feb 23, 2016 6:26 pm (GMT+1)


Thank you Ralph.

Sorry, I don't understand how can i access the subType you talk about ?

Get the Type ID and Variation ID from API_LibPart

$
0
0
Author:Ralph Wessel
Posted: Wed Feb 24, 2016 11:38 am (GMT+1)


gehairing wrote:
Sorry, I don't understand how can i access the subType you talk about ?

For background information, look at the Library Part Subtypes documentation with the API. There is a link to it from the API_LibPart page. The subtype identifier for a library part is API_LibPart::ownUnID. You will find functions like APIAny_CheckLibPartSubtypeOfbyMainID and APIAny_CheckLibPartSubtypeOfID to be useful.
_________________
Ralph Wessel
Cadimage

Library Part - array - GSHandle

$
0
0
Author:Xylios
Posted: Wed Feb 24, 2016 3:44 pm (GMT+1)


Hey.

I have successfully created arrays of various types (such as APIParT_RealNum, APIParT_Integer ...) using the example you mentioned.

However, I have found another obstacle, I cannot seem to be able to create arrays of type string (APIParT_CString).

Anyone can help me with that?

I have tried to allocate space for char or double, and do the respective cast, but had no luck.

Code:
(*addPars)[i].value.array = BMAllocateHandle(4 * sizeof(char), ALLOCATE_CLEAR, 0);
char** arrHdl = reinterpret_cast<char**>((*addPars)[i].value.array);

//(*addPars)[i].value.array = BMAllocateHandle(4 * sizeof(double), ALLOCATE_CLEAR, 0);
//double** arrHdl = reinterpret_cast<double**>((*addPars)[i].value.array);

(*arrHdl)[0] = 'a';
(*arrHdl)[1] = '\0';
(*arrHdl)[2] = 'b';
(*arrHdl)[3] = '\0';



UPDATE:

I have found the solution:

Code:
//actualSize is the number of characters of every strings you want added plus the number of said strings
//ex: you want two strings "abc" and "st", the value of actualSize will be 3 + 2 + 2 = 7
//to note that the dim1 will still be the number of strings you want, in this example, 2. But you will allocate space for every character plus every separator '\0'.
//the final value of the array will be "abc\0st\0"
int numberOfStrings = 2;
(*addPars)[i].dim1 = numberOfStrings;
(*addPars)[i].dim2 = 1
(*addPars)[i].value.array = BMAllocateHandle(actualSize * (*addPars)[i].dim2 * sizeof(GS::uchar_t), ALLOCATE_CLEAR, 0);
GS::uchar_t** arrHdl = reinterpret_cast<GS::uchar_t**>((*addPars)[i].value.array);


Hope that this can help anyone with the same problem.

Best regards,
Xylios

Viewing all 564 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>