2015-03-05 03:01 PM - last edited on 2023-08-01 01:34 PM by Doreena Deng
2015-03-06 12:23 AM
Traro wrote:Traro,
I would like to ChangeDefaults Door and Window(Change Object).
Ex.
- I have 2 door object [MyDoor1.gsm , MyDoor2.gsm].
- And "MyDoor1" is Defaults object then i would like change to "MyDoor2" object.
2015-03-06 12:00 PM
Traro wrote:I suggest first getting the object defaults with
I would like to ChangeDefaults Door and Window(Change Object).
Ex.
- I have 2 door object [MyDoor1.gsm , MyDoor2.gsm].
- And "MyDoor1" is Defaults object then i would like change to "MyDoor2" object.
2015-03-06 04:10 PM
Ralph wrote:I absolutely agree with Ralph Wessel using these methods to change the default object. I wrote a code sample based on these methods,Traro wrote:I suggest first getting the object defaults with
I would like to ChangeDefaults Door and Window(Change Object).
Ex.
- I have 2 door object [MyDoor1.gsm , MyDoor2.gsm].
- And "MyDoor1" is Defaults object then i would like change to "MyDoor2" object.ACAPI_Element_GetDefaults. The critical information required for setting the correct library part is the libIndvalue in the API_ObjectTypestructure. This is a temporary index to the object in the loaded libraries. You can find this using ACAPI_LibPart_Searchwith the name of the target object.
I can't recollect whether it's essential to get the default parameters for this object to set in the tool defaults, but you can get this information usingACAPI_LibPart_GetParams(parameters and default size).
API_LibPart libDoor; API_Element elementDoor; API_ElementMemo memo; GSErrCode err = NoError; // Get defaults for door element BNZeroMemory (&elementDoor, sizeof (API_Element)); elementDoor.header.typeID = API_DoorID; err = ACAPI_Element_GetDefaults (&elementDoor, &memo); if (err != NoError) { WriteReport_Alert ("Cannot get door defaults"); return; } // Get a door object from library using its name BNZeroMemory (&libDoor, sizeof (libDoor)); const GS::UniString uName ("Door with Sidelight on Side 1 19"); GS::ucscpy (libDoor.docu_UName, uName.ToUStr ()); err = ACAPI_LibPart_Search (&libDoor, false); if (err != NoError) { WriteReport_Alert ("No libpart found with that name"); return; } delete libDoor.location; // don't forget to free location // Change libInd of the default door to the new one { API_Element mask; ACAPI_ELEMENT_MASK_CLEAR (mask); ACAPI_ELEMENT_MASK_SET (mask, API_DoorType, openingBase.libInd); elementDoor.door.openingBase.libInd = libDoor.index; err = ACAPI_Element_ChangeDefaults (&elementDoor, &memo, &mask); if (err != NoError) { WriteReport_Alert ("Cannot change door defaults"); return; } } // Check whether defaults were updated { API_Element elementDoor2; elementDoor2.header.typeID = API_DoorID; err = ACAPI_Element_GetDefaults (&elementDoor2, NULL); if (err != NoError) { WriteReport_Alert ("Cannot get door defaults"); return; } if (elementDoor2.door.openingBase.libInd != libDoor.index) { WriteReport_Alert ("Door default settings were not updated"); return; } }This example changes only the default door object nothing more (e.g. not using default parameters of this door object).
2015-03-11 09:31 AM
2015-03-13 02:58 PM
... // Change libInd of the default door to the new one { API_Element mask; ACAPI_ELEMENT_MASK_CLEAR (mask); ACAPI_ELEMENT_MASK_SET (mask, API_DoorType, openingBase.libInd); elementDoor.door.openingBase.libInd = libDoor.index; + // Set default params of the new door object + { + double a, b; + Int32 addParNum; + API_AddParType **addPars; + + err = ACAPI_LibPart_GetParams (libDoor.index, &a, &b, &addParNum, &addPars); + if (err) { + WriteReport_Alert ("Cannot get libpart params"); + return; + } + memo.params = addPars; + } err = ACAPI_Element_ChangeDefaults (&elementDoor, &memo, &mask); if (err != NoError) { WriteReport_Alert ("Cannot change door defaults"); return; } + ACAPI_DisposeElemMemoHdls (&memo); } ...