Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

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

vfrontiers
Contributor
I know this is not what you're discussing, but is there some "developer" code that makes an object NOT respond to the hotspot that is EYEDROPPERED?

For example, I have an object in plan... I used to be able to EYEDROPPER the CENTER HOTSPOT and all subsequent placement would place by the center... This does not seem to happen anymore..
Duane
Visual Frontiers
AC22 6021:|: AC24 4007:|: Enscape3:|:TwinMotion
DellXPS 4.7ghz i7:|: 8gb GPU 1070ti

Karl Ottenstein
Moderator
vfrontiers wrote:
I know this is not what you're discussing, but is there some "developer" code that makes an object NOT respond to the hotspot that is EYEDROPPERED?

For example, I have an object in plan... I used to be able to EYEDROPPER the CENTER HOTSPOT and all subsequent placement would place by the center... This does not seem to happen anymore..
This has been reported - and I was about to report it again, as it has been a few years and still not fixed. Cannot remember if this "broke" in 12 or 13. But, it prevents using visual favorites properly, such as with the Detailer palettes.

But, yeah, wrong forum: this is a Working in ArchiCAD issue.

Cheers,
Karl
One of the forum moderators   •   AC 25 USA and earlier   •   MacOS 11.6.2, iMac Pro

Anonymous
Not applicable
I upload this source code to you

http://www.porrapat.com/ArchiCAD_Add-On1.zip

To help me find the problem.

It's place object with the same location.

But I don't want it

------------------------------------------------------------------------------
I use API Devkit 14.2550 on WindowsXP Service Pack 2
Running on ArchiCAD 14 Demo. Using visual studio 2005 to compile

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!