GDL
About building parametric objects with GDL.

Placing Object with desired Hotspot

Anonymous
Not applicable
At last, I can put my object on the floorplan and I can change some attribute of it

http://archicad-talk.graphisoft.com/viewtopic.php?p=182285#1

My object have many hotspot but now I can use only default hotspot to place it.

Are there any way the place object using another HOTSPOT. So I can rotate it correctly. And easy.

Thank you
12 REPLIES 12
Ralph Wessel
Mentor
Paodekcal wrote:
Are there any way the place object using another HOTSPOT. So I can rotate it correctly. And easy.
Yes, you can set the index of the hotspot to use. Refer to the fixPoint field of the API_ObjectType structure.
Ralph Wessel BArch
Anonymous
Not applicable
       element.object.libInd = part.index;
		element.object.level = level;
		element.object.pos.x = x;
		element.object.pos.y = y;
		element.object.xRatio = getParams.a;
		element.object.yRatio = getParams.b;
		memo.params = getParams.params;

		element.object.fixPoint = 3;

		API_Element mask;

		ACAPI_ELEMENT_MASK_CLEAR (mask);
		ACAPI_ELEMENT_MASK_SET (mask, API_ObjectType, fixPoint);

		ACAPI_Element_ChangeDefaults(&element,NULL,&mask);
		err = ACAPI_Element_Create(&element, &memo);
		
Like this?, But It's not work. It's only use default hotspot at the same.

Do you have any example?
Ralph Wessel
Mentor
Paodekcal wrote:
But It's not work. It's only use default hotspot at the same. Do you have any example?
It works for me - I think I'd need to see more of your source code to understand where it's going wrong. I write code through an object wrapper rather than plain C, so it isn't directly applicable to your case, e.g.
Object object("myObjectName");
object.setOriginIndex(3);
activeDrawing.put(object);
Ralph Wessel BArch
Anonymous
Not applicable
I will re-write code to show you.

Thank you.
Anonymous
Not applicable
OK.

1. You have to load my gsm file to your embedded library by yourself. (Not by code) The gsm file is in the zip file below.

2. Write Menu Code By This Function

	switch (menuParams->menuItemRef.menuResID) {
		case 32500:		/* Library Parts */
				switch (menuParams->menuItemRef.itemIndex) {
					case 1:		Do_CreateObjectOnFixHotspot();		break;
				}
				break;
	}
3. And placing object code that have to fix at comment line
static void Do_CreateObjectOnFixHotspot()
{
	ACAPI_OpenUndoableSession("Test Draw Object With Desired Hotspot");

	API_LibPart part;   
	GSErrCode err;   
	BNZeroMemory(&part, sizeof(API_LibPart));   

	CHANSI2Unicode("ไม้พื้นสมาร์ทวูด10x300x25.gsm", strlen("ไม้พื้นสมาร์ทวูด10x300x25.gsm"), part.file_UName, API_UniLongNameLen);  

	if((err = ACAPI_LibPart_Search(&part, false)) == NoError)   
	{ 
		API_Element element;
		API_ElementMemo memo;
		BNZeroMemory(&element, sizeof(API_Element));
		BNZeroMemory(&memo, sizeof(API_ElementMemo));
		double A = 0;
		double B = 0;
		Int32 parCount = 0;
		//----
		element.header.typeID = API_ObjectID;
		err = ACAPI_Element_GetDefaults(&element, NULL);
		err = ACAPI_LibPart_GetParams(part.index, &A, &B, &parCount, &memo.params);

		element.object.libInd = part.index;
		element.object.level  = 0;
		element.object.pos.x  = 0;
		element.object.pos.y  = 0;
		element.object.xRatio = A;
		element.object.yRatio = B;

		element.object.fixPoint = 0;		//0 is default value
		//element.object.fixPoint = 1;		//Change to this three line ...
		//element.object.fixPoint = 2;		//But location placing hotspot is the same
		//element.object.fixPoint = 3;

		err = ACAPI_Element_Create(&element, &memo);
		
		ACAPI_DisposeElemMemoHdls (&memo);
	}
	ACAPI_CloseUndoableSession();
}
Anonymous
Not applicable
The code above not work.

I'm waiting for your answer.

Thank you
Ralph Wessel
Mentor
Paodekcal wrote:
2. Write Menu Code By This Function
etc
I've tested this and it works, although I didn't try your object. If you open the settings of the placed object, does the placement hotspot in the 2D preview remain the same irrespective of the hotspot you pick in the code? If so, perhaps there is an issue with that object. Try a very simple object first (to make sure the code is correct) and work up from there.
Ralph Wessel BArch
Anonymous
Not applicable
I use API DevKit 14. And you?

I tested with simple object too. Use placing Hotspot not change too.

OK. I will continue check

Thank you
Ralph Wessel
Mentor
Paodekcal wrote:
I use API DevKit 14. And you?
Yes, I used the same.
Ralph Wessel BArch

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!