Hello,
I'm having trouble getting the IProperty.GetValueAsString method to return the value set using the IProperty.SetValueAsString method for a custom property created using the IPropertyDefinitions.AddPropString method. I'm wondering if someone might be able to point out where I'm going wrong. Sample code for a C# console app below.
Much appreciated.
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.IO;using RAMDATAACCESSLib;
namespace RAMDA_Tests{ class Program { static void Main(string[] args) { string filename = "C:\\Users\\xxxxx\\Desktop\\Test.rss"; //Open model
//Initialize interfaces
RamDataAccess1 ramDataAccess = new RAMDATAACCESSLib.RamDataAccess1(); RAMDATAACCESSLib.IDBIO1 IDBI = (RAMDATAACCESSLib.IDBIO1) ramDataAccess.GetDispInterfacePointerByEnum(EINTERFACES.IDBIO1_INT); RAMDATAACCESSLib.IModel IModel = (RAMDATAACCESSLib.IModel) ramDataAccess.GetInterfacePointerByEnum(EINTERFACES.IModel_INT); RAMDATAACCESSLib.IForces1 forces1 = (RAMDATAACCESSLib.IForces1) ramDataAccess.GetDispInterfacePointerByEnum(EINTERFACES.IForces_INT); RAMDATAACCESSLib.ILoading1 loading1 = (RAMDATAACCESSLib.ILoading1) ramDataAccess.GetDispInterfacePointerByEnum(EINTERFACES.ILoading_INT); //Load database file
IDBI.LoadDataBase2(filename, "1"); //set start/end parameters for a single beam. double x1 = -47.8; double y1 = -3.86; double z1 = 0; double x2 = -17.8; double y2 = -3.86; double z2 = 0;
//get model stories IStories stories = IModel.GetStories(); int storyCount = stories.GetCount();
//get a single story and get the associated floor type IStory story = stories.GetAt(2); IFloorType floorType = story.GetFloorType();
//Get the layout beams for the floor type and add one. ILayoutBeams layoutBeams = floorType.GetLayoutBeams(); ILayoutBeam layoutBeam = layoutBeams.Add(EMATERIALTYPES.ESteelMat, x1, y1, z1, x2, y2, z2);
//get the Ibeams assocaiated with layout beam and grab property definitions. Add the prop def to the beam. IBeams Ibeams = layoutBeam.GetAssociatedStoryBeams(); IPropertyDefinitions propDefs = Ibeams.GetPropertyDefinitions(""); IPropertyDefinition index = propDefs.AddPropString("indexValue","Index Value of Member","default"); //interface for individual beam. IBeam Ibeam = Ibeams.GetAt(0);
//set the value of the property for the beam. IProperty property = Ibeam.GetProperty("indexValue"); property.SetValueAsString("Not Default");
//set up some test cases. string valueToReport = "String to Override"; string methodResult = "Method didn't fail."; try { property.GetValueAsString(out valueToReport); } catch { valueToReport=valueToReport; methodResult = "method failed"; } Console.WriteLine(valueToReport + methodResult); Console.ReadLine();
IDBI.SaveDatabase(); IDBI.CloseDatabase();
} }}
I think the issue here was that property definitions with the same name were being added. Once a check for duplicate names was used, the GetValueAsString method worked as expected.