Hello,
I am using OpenBuildings CONNECT Update 5, I think the version is 10.00.14.18. 10.05.00.49 (Corrected). I am using the MicroStation Update 12 SDK.
I am trying to create a variation (parameter set) in a model but I want to associate the variables with an Item Type as shown in the attached dialog box rather than using local variables.
From what I can piece together from the SDK documentation and the parametric modelling examples provided in the SDK, the general steps are:
So I tried this code:
EditParameterDefinitions defs = EditParameterDefinitions.GetForModel(dgnModel); ItemTypeLibrary itemTypeLibrary = ItemTypeLibrary.FindByName(LIB_NAME, dgnModel.GetDgnFile()); ItemType itemType = itemTypeLibrary.GetItemTypeByName(ITEMTYPE_NAME); Bentley.ECObjects.Instance.IECInstance ecProperties = itemType.CreateTemplateInstance(); defs.SetDomainParameters(ecProperties); // **** stuck here **** // --> always returns ParameterStatus.InvalidParameterValues // in a separate method after the domain class has been attached to the model var handler = DgnComponentDefinitionHandler.GetForModel(dgnModel).DefinitionModelHandler; EditParameterDefinitions defs = EditParameterDefinitions.GetForModel(dgnModel); ParameterSet paramSet = handler.CreateParameterSet("variationName", null, null); IDgnECInstance propertyValues = paramSet.Properties as IDgnECInstance; // for each relevant parameter value (e.g. "SectionDepth") ParameterDefinition paramDef = defs.FindByLabel(parameterName); if (paramDef != null) { IECPropertyValue propertyValue = propertyValues.FindPropertyValue(paramDef.AccessString, false, false, false, true); propertyValue.NativeValue = itemValue; // }
When I run the debugger and test the variables in the immediate window, I obtain the following results:
defs {Bentley.DgnPlatformNET.EditParameterDefinitions} DependencyRoot: {Bentley.DgnPlatformNET.Elements.ExtendedNonGraphicsElement} DomainClass: null HostModel: {Bentley.DgnPlatformNET.DgnModel} LocalParameterCount: 0 Properties: {{DgnActiveParameters(:ECDA00000001:1595170100)}}
itemType {Bentley.DgnPlatformNET.ItemType} ECClass: ECClass: "Structure__x0020__Attachment", Schema="DgnCustomItemTypes_Railway__x0020__Overhead__x0020__Wiring.01.00", IsDomainClass=true, IsCustomAttribute=false, IsStruct=false, BaseClasses[0]={System.NullReferenceException: Object reference not set to an instance of an object. at <>x.<>m0(ECClass <>4__this)} Guid: 2 Id: 2 InternalName: "Structure__x0020__Attachment" IsCustomType: false IsIdentifyingItem: false LabelProperty: null Library: {Bentley.DgnPlatformNET.ItemTypeLibrary} Name: "Structure Attachment" PropertyCount: 6 Results View: Expanding the Results View will enumerate the IEnumerable
itemType.ToArray() {Bentley.DgnPlatformNET.CustomProperty[6]} [0]: {Bentley.DgnPlatformNET.CustomProperty} [1]: {Bentley.DgnPlatformNET.CustomProperty} [2]: {Bentley.DgnPlatformNET.CustomProperty} [3]: {Bentley.DgnPlatformNET.CustomProperty} [4]: {Bentley.DgnPlatformNET.CustomProperty} [5]: {Bentley.DgnPlatformNET.CustomProperty}
itemType.ToArray()[2] {Bentley.DgnPlatformNET.CustomProperty} Container: {Bentley.DgnPlatformNET.ItemType} CustomType: null DefaultValue: 0 DefaultValueExpression: "0.0" Guid: 3145730 Id: 3145728 InternalName: "SectionDepth" IsArray: false Library: {Bentley.DgnPlatformNET.ItemTypeLibrary} Name: "SectionDepth" PickListName: null Priority: 2147418107 SupportsCustomType: true SupportsUnits: true Type: Double TypeId: 2 Units: {Bentley.DgnPlatformNET.DgnECUnit}
ecProperties {{Structure__x0020__Attachment()}} ClassDefinition: ECClass: "Structure__x0020__Attachment", Schema="DgnCustomItemTypes_Railway__x0020__Overhead__x0020__Wiring.01.00", IsDomainClass=true, IsCustomAttribute=false, IsStruct=false, BaseClasses[0]={System.NullReferenceException: Object reference not set to an instance of an object. at <>x.<>m0(ECClass <>4__this)} ClassLayoutChecksum: 1243618337 ContainsValues: true ECDValueContainer: {Bentley.ECObjects.Instance.ECDMemoryBuffer} Enabler: null ExtendedData: {Bentley.Collections.EmptyReadOnlyDictionary<object>} ExtendedDataValueSetter: {Bentley.Collections.OptimizedDictionary<object>} Instance: {{Structure__x0020__Attachment()}} InstanceId: "" IsHiddenInstance: false IsPartiallyLoaded: false IsReadOnly: false MemoryBuffer: {Bentley.ECObjects.Instance.ECDMemoryBuffer} NumBitsPerProperty: 2 PerPropertyFlags: {Bentley.ECObjects.Instance.PerPropertyFlagsHolder} PerPropertyFlagsCount: 1 ReferenceObject: null UsageBitmask: 0 _ECArrayCountChanged: null _ECPropertyValueChanged: null _ECReferenceObjectChanged: null m_instanceId: "" Results View: Expanding the Results View will enumerate the IEnumerable
ecProperties.ToArray() {Bentley.ECObjects.Instance.IECPropertyValue[6]} [0]: {Bentley.ECObjects.Instance.ECDCalculatedDoubleValue} [1]: {Bentley.ECObjects.Instance.ECDCalculatedIntegerValue} [2]: {Bentley.ECObjects.Instance.ECDCalculatedDoubleValue} [3]: {Bentley.ECObjects.Instance.ECDCalculatedStringValue} [4]: {Bentley.ECObjects.Instance.ECDCalculatedStringValue} [5]: {Bentley.ECObjects.Instance.ECDCalculatedStringValue}
ecProperties.ToArray()[2] {Bentley.ECObjects.Instance.ECDCalculatedDoubleValue} AccessString: "SectionWidth" ArrayIndex: -1 BaseECDInstance: {{Structure__x0020__Attachment()}} ContainedValues: null Container: {{Structure__x0020__Attachment()}} DoubleValue: 0 ECDValueContainer: {Bentley.ECObjects.Instance.ECDMemoryBuffer} Evaluator: {Bentley.ECObjects.Schema.CalculatedECPropertyEvaluator} GeometryValue: null Instance: {{Structure__x0020__Attachment()}} IntValue: 0 InternalValue: 0 IsAlwaysNull: false IsArray: false IsNull: false IsPrimitive: true IsReadOnly: false IsStruct: false Layout: {SectionWidth double offset=16 nullflagsOffset=0, nullflagsBitmask=00000004} LongValue: 0 NativeAccessString: "SectionWidth" NativeValue: 0 ParentPropertyValue: null Property: ECProperty: "SectionWidth", Type="double", IsReadOnly=false State: Calculated StringValue: "0" Type: {Bentley.ECObjects.Schema.ECDoubleType} XmlStringValue: "0"
As I am not very familiar with the ECObjects namespace and parametric modelling objects, I am not sure if I have called the correct method or there is another step missing.
Can someone advise:
Any help would be greatly appreciated.
Regards,
Trevor
Trevor Watling said:I am using OpenBuildings CONNECT Update 5, I think the version is 10.00.14.18. I am using the MicroStation Update 12 SDK.
Hello Trevor.
I am wondering, that something works. Your version number is Update 0, and between SDK U12 and U5 are some really great major changes (i.e. different MicroSoft Visual Studio, SDK, etc.).
I would hardly recommended to use the same Update-Version for MucroStation AND SDK.
Else you may receive some really nasty effects, which could not nailed down.
Mit freundlichen Grüßen / Best regards Volker Hüfner
| AB_DATE Engineering Software | ab-date.de |
Ah I see.
I was under the impression that the latest OpenBuildings Update 5 (less than a month ago) and the MicroStation SDK Update 12 were compatible. I am generally using OpenBuildings in MicroStation mode most of the time and I thought they were equivalent.
Perhaps that is why this is not functioning for me.
I just checked again. My version of OpenBuildings is 10.05.00.49 I incorrectly quoted the version of the Connection Client
Trevor Watling said:My version of OpenBuildings is 10.05.00.49
Just to be clear, you're not attempting to use any features of OpenBuildings and you're not using the OpenBuildings SDK? That is, your code could be running on plain old MicroStation CONNECT?
Regards, Jon Summers LA Solutions
Yes that is correct. I am running it under pure MicroStation mode. I rarely use OpenBuildings and I am not using any OpenBuildings features.
Hi Trevor,
Trevor Watling said:I was under the impression that the latest OpenBuildings Update 5 (less than a month ago) and the MicroStation SDK Update 12 were compatible.
Yes, they are: OBD U5 is based on PowerPlatform CE Update 12, which is also base platform for MicroStation itself.
Trevor Watling said:I am generally using OpenBuildings in MicroStation mode most of the time and I thought they were equivalent.
That's question whether MicroStation mode is or is not equal to MicroStation.
In my opinion it usually is, especially when talking about general features. But e.g. in Bentley Map some MicroStation features have been switched off regardless BM XFM project is active or not. I am not sure whether such difference exist also in OBD.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point