public void UpdateParameter(ParameterUpdater paramUpdater)
        {
            //the below does not work because ApplicationIds are stored within a stream
            //try to get element using ApplicationId
            //this will only work if the element has been successfully been received in Revit before
            //var element = GetExistingElementByApplicationId(paramUpdater.revitId);

            Element element = null;

            //try to get element using ElementId
            int intId;

            if (int.TryParse(paramUpdater.revitId, out intId))
            {
                var elemId = new ElementId(intId);
                element = Doc.GetElement(elemId);
            }

            //try to get element using UniqueId
            if (element == null)
            {
                element = Doc.GetElement(paramUpdater.revitId);
            }

            if (element == null)
            {
                ConversionErrors.Add(new System.Exception($"Could not find element to update: Element Id = {paramUpdater.revitId}"));
                return;
            }

            SetInstanceParameters(element, paramUpdater);
        }
Beispiel #2
0
 protected override void Context()
 {
     _formulaTypeMapper  = A.Fake <IParameterToFomulaTypeMapper>();
     _executionContext   = A.Fake <IExecutionContext>();
     _entityPathResolver = A.Fake <IEntityPathResolver>();
     _favoriteTask       = A.Fake <IFavoriteTask>();
     _parameterTask      = new ParameterTask(_entityPathResolver, _executionContext, _favoriteTask);
     sut = new ParameterUpdater(_formulaTypeMapper, _parameterTask);
     _sourceParameter = DomainHelperForSpecs.ConstantParameterWithValue(0);
     _sourceParameter.BuildingBlockType = PKSimBuildingBlockType.Individual;
     _targetParameter = DomainHelperForSpecs.ConstantParameterWithValue(1);
     _targetParameter.BuildingBlockType = PKSimBuildingBlockType.Individual;
     A.CallTo(() => _executionContext.BuildingBlockContaining(_targetParameter)).Returns(A.Fake <IPKSimBuildingBlock>());
 }