For programming using the COM interface, a nodal support has the properties "ReferenceSystem" and "UserDefinedReferenceSystem". "ReferenceSystem" allows you to define the type of the user-defined coordinate system (for example, "Rotated" or "Coordinate System"), and depending on which type has been selected, this type is then defined via "UserDefinedReferenceSystem".
In the following example, "Coordinate system" was set as the type and a user-defined coordinate system was also created for it:
// create user defined coordinate systemIGuideObjects iGuide = iModel.GetGuideObjects();
// delete cosy No 2UserCoordinateSystem[] csList = iGuide.GetCoordinateSystems();if (csList.Length > 1){ for (int i = 0; i < csList.Length; ++i) { if (csList[i].No == 2) { iGuide.PrepareModification(); iGuide.DeleteObjects(GuideObjectType.CoordinateSystemObject, "2"); iGuide.FinishModification(); } }}
// define new cosy No 2UserCoordinateSystem uCs = new UserCoordinateSystem();uCs.Name = "test";uCs.Comment = "test";uCs.No = 2;uCs.IsValid = true;
uCs.Origin.X = 1;uCs.Origin.Y = 0;uCs.Origin.Z = 1;
uCs.Point1.X = 2;uCs.Point1.Y = 0;uCs.Point1.Z = 1;
uCs.Point2.X = 1;uCs.Point2.Y = 1;uCs.Point2.Z = 2;
// set cosy No 2iGuide.PrepareModification();iGuide.SetCoordinateSystem(uCs);iGuide.FinishModification();
// create nodal support with user defined cosyNodalSupport ns = new NodalSupport();
ns.SupportConstantX = -1;ns.SupportConstantY = -1;ns.SupportConstantZ = -1;
ns.RestraintConstantX = -1;ns.RestraintConstantY = 0;ns.RestraintConstantZ = -1;
ns.Comment = "user defined cosy";ns.NodeList = "1";ns.ReferenceSystem = ReferenceSystemType.UserDefinedSystemType;
ns.UserDefinedReferenceSystem.ObjectNo = 2;ns.UserDefinedReferenceSystem.Type = UserDefinedAxisSystemType.DefinedCoordinateSystemType;
iModData.PrepareModification();iModData.SetNodalSupport(ns);iModData.FinishModification();
To be able to create the coordinate system, the interface for the guide objects is required: 'IGuideObjects'. With the "DeleteObjects()" function, an existing coordinate system of Number 2 is first deleted and a new one is created with "SetCoordinateSystem()." Please take note of the "Prepare/Finish-Modification" block in order to be able to transfer the new element.
The nodal support is transferred via the "IModelData" interface. Again, the "Prepare/Finish-Modification" block is required.