Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GlobalParameter Create Error SpecTypeId (Revit 22.0.2.392)

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
ricaun
726 Views, 6 Replies

GlobalParameter Create Error SpecTypeId (Revit 22.0.2.392)

Hello,

 

I was trying to create GlobalParameter using each SpecTypeId to validate my Extension and had some problems with some ForgeTypeId. Failed to create a new parameter's definition!

 

Error.PNG

 

Here is my sample code that shows 16 SpecTypeId has this problem.

using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System;

namespace RevitAddin
{
    [Transaction(TransactionMode.Manual)]
    public class CommandGlobalError2022 : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Document document = uidoc.Document;

            var name = $"Global {DateTime.Now.Ticks}";

            string text = "";

            using (Transaction transaction = new Transaction(document))
            {
                transaction.Start("GlobalParameter");
                foreach (var specTypeId in UnitUtils.GetAllSpecs())
                {
                    try
                    {
                        var globalParameter = GlobalParameter.Create(document, name, specTypeId);
                        document.Delete(globalParameter.Id);
                    }
                    catch (Exception ex)
                    {
                        text += $"{specTypeId.TypeId}\n";
                        Console.WriteLine(ex);
                    }
                }
                transaction.Commit();
            }

            System.Windows.Clipboard.SetText(text);
            System.Windows.MessageBox.Show(text, $"GlobalParameter.Create Error | RevitBuild {document.Application.VersionBuild}");

            return Result.Succeeded;
        }
    }
}

Specs Error.PNG

 

I'm using Revit BuildVersion 22.0.2.392, I didn't test on the last HotFix version for Revit 2022.

 

Here are the 16 Forge TypeId that throws the error.

autodesk.spec.aec.electrical:costRateEnergy-2.0.0
autodesk.spec.aec.electrical:costRatePower-2.0.0
autodesk.spec.aec.electrical:powerPerLength-2.0.0
autodesk.spec.aec.energy:heatCapacityPerArea-2.0.0
autodesk.spec.aec.energy:isothermalMoistureCapacity-2.0.0
autodesk.spec.aec.energy:thermalGradientCoefficientForMoistureCapacity-2.0.0
autodesk.spec.aec.hvac:angularSpeed-2.0.0
autodesk.spec.aec.hvac:diffusivity-2.0.0
autodesk.spec.aec.hvac:flowPerPower-2.0.0
autodesk.spec.aec.hvac:massPerTime-2.0.0
autodesk.spec.aec.hvac:powerPerFlow-2.0.0
autodesk.spec.aec.infrastructure:stationingInterval-2.0.0
autodesk.spec.aec.piping:massPerTime-2.0.0
autodesk.spec.aec:costPerArea-2.0.0
autodesk.spec.aec:distance-2.0.0
autodesk.spec.aec:rotationAngle-2.0.0

 

The strange part is that I tested a similar code for SharedParameter and didn't have any errors.

 

See yaa!

 

 

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

6 REPLIES 6
Message 2 of 7
jeremy_tammik
in reply to: ricaun

Thank you for the report. I'll pass it on to the powers that be.

 

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 3 of 7
jeremy_tammik
in reply to: ricaun

Dear Luiz Henrique,

 

Thank you for your report and clear description.

 

Sorry to hear about this.

 

I logged the issue REVIT-193493 [API Error creating global parameter with certain SpecTypeIds] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

This issue is important to me. What can I do to help?

 

This issue needs to be assessed by our engineering team and prioritised against all other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:

 

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact to Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

 

This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.

 

Best regards,

 

Jeremy

 

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 4 of 7
ricaun
in reply to: ricaun

Hello Jeremy

 

I tested basically the same code using Revit 2023 and looks like every ForgeTypeId in the UnitUtils.GetAllMeasurableSpecs() create the GlobalParameter normally, including the 16 SpecTypeIds.

 

Here is the code:

using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System;

namespace RevitAddin.Error.Revit.Commands
{
    [Transaction(TransactionMode.Manual)]
    public class CommandGlobalCreateTest2023 : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Document document = uidoc.Document;

            var name = $"Global {DateTime.Now.Ticks}";

            string text = "";
            int errorCount = 0;

            using (Transaction transaction = new Transaction(document))
            {
                transaction.Start("GlobalParameter");
                foreach (var specTypeId in UnitUtils.GetAllMeasurableSpecs())
                {
                    var created = true;
                    try
                    {
                        var globalParameter = GlobalParameter.Create(document, name, specTypeId);
                        document.Delete(globalParameter.Id);
                    }
                    catch (Exception ex)
                    {
                        errorCount++;
                        created = false;
                        Console.WriteLine(ex);
                    }
                    text += $"{created}\t {specTypeId.TypeId}\n";
                }
                transaction.Commit();
            }

            text = $"Created\t ForgeTypeId\t Error:{errorCount}\n{text}";

            System.Windows.Clipboard.SetText(text);
            System.Windows.MessageBox.Show(text, $"GlobalParameter.Create Error | RevitBuild {document.Application.VersionBuild}");

            return Result.Succeeded;
        }
    }
}

 And here is the result in RevitBuild 23.0.1.318:

Created	 ForgeTypeId	 Error:0
True	 autodesk.spec.aec.electrical:apparentPower-2.0.0
True	 autodesk.spec.aec.electrical:apparentPowerDensity-1.0.0
True	 autodesk.spec.aec.electrical:cableTraySize-2.0.0
True	 autodesk.spec.aec.electrical:colorTemperature-2.0.0
True	 autodesk.spec.aec.electrical:conduitSize-2.0.0
True	 autodesk.spec.aec.electrical:costRateEnergy-2.0.0
True	 autodesk.spec.aec.electrical:costRatePower-2.0.0
True	 autodesk.spec.aec.electrical:current-2.0.0
True	 autodesk.spec.aec.electrical:demandFactor-2.0.0
True	 autodesk.spec.aec.electrical:efficacy-2.0.0
True	 autodesk.spec.aec.electrical:frequency-2.0.0
True	 autodesk.spec.aec.electrical:illuminance-2.0.0
True	 autodesk.spec.aec.electrical:luminance-2.0.0
True	 autodesk.spec.aec.electrical:luminousFlux-2.0.0
True	 autodesk.spec.aec.electrical:luminousIntensity-2.0.0
True	 autodesk.spec.aec.electrical:potential-2.0.0
True	 autodesk.spec.aec.electrical:power-2.0.0
True	 autodesk.spec.aec.electrical:powerDensity-2.0.0
True	 autodesk.spec.aec.electrical:powerPerLength-2.0.0
True	 autodesk.spec.aec.electrical:resistivity-2.0.0
True	 autodesk.spec.aec.electrical:temperature-2.0.0
True	 autodesk.spec.aec.electrical:temperatureDifference-2.0.0
True	 autodesk.spec.aec.electrical:wattage-2.0.0
True	 autodesk.spec.aec.electrical:wireDiameter-2.0.0
True	 autodesk.spec.aec.energy:energy-2.0.0
True	 autodesk.spec.aec.energy:heatCapacityPerArea-2.0.0
True	 autodesk.spec.aec.energy:heatTransferCoefficient-2.0.0
True	 autodesk.spec.aec.energy:isothermalMoistureCapacity-2.0.0
True	 autodesk.spec.aec.energy:permeability-2.0.0
True	 autodesk.spec.aec.energy:specificHeat-2.0.0
True	 autodesk.spec.aec.energy:specificHeatOfVaporization-2.0.0
True	 autodesk.spec.aec.energy:thermalConductivity-2.0.0
True	 autodesk.spec.aec.energy:thermalGradientCoefficientForMoistureCapacity-2.0.0
True	 autodesk.spec.aec.energy:thermalMass-2.0.0
True	 autodesk.spec.aec.energy:thermalResistance-2.0.0
True	 autodesk.spec.aec.hvac:airFlow-2.0.0
True	 autodesk.spec.aec.hvac:airFlowDensity-2.0.0
True	 autodesk.spec.aec.hvac:airFlowDividedByCoolingLoad-2.0.0
True	 autodesk.spec.aec.hvac:airFlowDividedByVolume-2.0.0
True	 autodesk.spec.aec.hvac:angularSpeed-2.0.0
True	 autodesk.spec.aec.hvac:areaDividedByCoolingLoad-2.0.0
True	 autodesk.spec.aec.hvac:areaDividedByHeatingLoad-2.0.0
True	 autodesk.spec.aec.hvac:coolingLoad-2.0.0
True	 autodesk.spec.aec.hvac:coolingLoadDividedByArea-2.0.0
True	 autodesk.spec.aec.hvac:coolingLoadDividedByVolume-2.0.0
True	 autodesk.spec.aec.hvac:crossSection-2.0.0
True	 autodesk.spec.aec.hvac:density-2.0.0
True	 autodesk.spec.aec.hvac:diffusivity-2.0.0
True	 autodesk.spec.aec.hvac:ductInsulationThickness-2.0.0
True	 autodesk.spec.aec.hvac:ductLiningThickness-2.0.0
True	 autodesk.spec.aec.hvac:ductSize-2.0.0
True	 autodesk.spec.aec.hvac:factor-2.0.0
True	 autodesk.spec.aec.hvac:flowPerPower-2.0.0
True	 autodesk.spec.aec.hvac:friction-2.0.0
True	 autodesk.spec.aec.hvac:heatGain-2.0.0
True	 autodesk.spec.aec.hvac:heatingLoad-2.0.0
True	 autodesk.spec.aec.hvac:heatingLoadDividedByArea-2.0.0
True	 autodesk.spec.aec.hvac:heatingLoadDividedByVolume-2.0.0
True	 autodesk.spec.aec.hvac:massPerTime-2.0.0
True	 autodesk.spec.aec.hvac:power-2.0.0
True	 autodesk.spec.aec.hvac:powerDensity-2.0.0
True	 autodesk.spec.aec.hvac:powerPerFlow-2.0.0
True	 autodesk.spec.aec.hvac:pressure-2.0.0
True	 autodesk.spec.aec.hvac:roughness-2.0.0
True	 autodesk.spec.aec.hvac:slope-2.0.0
True	 autodesk.spec.aec.hvac:temperature-2.0.0
True	 autodesk.spec.aec.hvac:temperatureDifference-2.0.0
True	 autodesk.spec.aec.hvac:velocity-2.0.0
True	 autodesk.spec.aec.hvac:viscosity-2.0.0
True	 autodesk.spec.aec.infrastructure:stationing-2.0.0
True	 autodesk.spec.aec.infrastructure:stationingInterval-2.0.0
True	 autodesk.spec.aec.piping:density-2.0.0
True	 autodesk.spec.aec.piping:flow-2.0.0
True	 autodesk.spec.aec.piping:friction-2.0.0
True	 autodesk.spec.aec.piping:mass-2.0.0
True	 autodesk.spec.aec.piping:massPerTime-2.0.0
True	 autodesk.spec.aec.piping:pipeDimension-2.0.0
True	 autodesk.spec.aec.piping:pipeInsulationThickness-2.0.0
True	 autodesk.spec.aec.piping:pipeMassPerUnitLength-2.0.0
True	 autodesk.spec.aec.piping:pipeSize-2.0.0
True	 autodesk.spec.aec.piping:pressure-2.0.0
True	 autodesk.spec.aec.piping:roughness-2.0.0
True	 autodesk.spec.aec.piping:slope-2.0.0
True	 autodesk.spec.aec.piping:temperature-2.0.0
True	 autodesk.spec.aec.piping:temperatureDifference-2.0.0
True	 autodesk.spec.aec.piping:velocity-2.0.0
True	 autodesk.spec.aec.piping:viscosity-2.0.0
True	 autodesk.spec.aec.piping:volume-2.0.0
True	 autodesk.spec.aec.structural:acceleration-2.0.0
True	 autodesk.spec.aec.structural:areaForce-2.0.0
True	 autodesk.spec.aec.structural:areaForceScale-2.0.0
True	 autodesk.spec.aec.structural:areaSpringCoefficient-2.0.0
True	 autodesk.spec.aec.structural:barDiameter-2.0.0
True	 autodesk.spec.aec.structural:crackWidth-2.0.0
True	 autodesk.spec.aec.structural:displacement-2.0.0
True	 autodesk.spec.aec.structural:energy-2.0.0
True	 autodesk.spec.aec.structural:force-2.0.0
True	 autodesk.spec.aec.structural:forceScale-2.0.0
True	 autodesk.spec.aec.structural:frequency-2.0.0
True	 autodesk.spec.aec.structural:lineSpringCoefficient-2.0.0
True	 autodesk.spec.aec.structural:linearForce-2.0.0
True	 autodesk.spec.aec.structural:linearForceScale-2.0.0
True	 autodesk.spec.aec.structural:linearMoment-2.0.0
True	 autodesk.spec.aec.structural:linearMomentScale-2.0.0
True	 autodesk.spec.aec.structural:mass-2.0.0
True	 autodesk.spec.aec.structural:massPerUnitArea-2.0.0
True	 autodesk.spec.aec.structural:massPerUnitLength-2.0.0
True	 autodesk.spec.aec.structural:moment-2.0.0
True	 autodesk.spec.aec.structural:momentOfInertia-2.0.0
True	 autodesk.spec.aec.structural:momentScale-2.0.0
True	 autodesk.spec.aec.structural:period-2.0.0
True	 autodesk.spec.aec.structural:pointSpringCoefficient-2.0.0
True	 autodesk.spec.aec.structural:pulsation-2.0.0
True	 autodesk.spec.aec.structural:reinforcementArea-2.0.0
True	 autodesk.spec.aec.structural:reinforcementAreaPerUnitLength-2.0.0
True	 autodesk.spec.aec.structural:reinforcementCover-2.0.0
True	 autodesk.spec.aec.structural:reinforcementLength-2.0.0
True	 autodesk.spec.aec.structural:reinforcementSpacing-2.0.0
True	 autodesk.spec.aec.structural:reinforcementVolume-2.0.0
True	 autodesk.spec.aec.structural:rotation-2.0.0
True	 autodesk.spec.aec.structural:rotationalLineSpringCoefficient-2.0.0
True	 autodesk.spec.aec.structural:rotationalPointSpringCoefficient-2.0.0
True	 autodesk.spec.aec.structural:sectionArea-2.0.0
True	 autodesk.spec.aec.structural:sectionDimension-2.0.0
True	 autodesk.spec.aec.structural:sectionModulus-2.0.0
True	 autodesk.spec.aec.structural:sectionProperty-2.0.0
True	 autodesk.spec.aec.structural:stress-2.0.0
True	 autodesk.spec.aec.structural:surfaceAreaPerUnitLength-2.0.0
True	 autodesk.spec.aec.structural:thermalExpansionCoefficient-2.0.0
True	 autodesk.spec.aec.structural:unitWeight-2.0.0
True	 autodesk.spec.aec.structural:velocity-2.0.0
True	 autodesk.spec.aec.structural:warpingConstant-2.0.0
True	 autodesk.spec.aec.structural:weight-2.0.0
True	 autodesk.spec.aec.structural:weightPerUnitLength-2.0.0
True	 autodesk.spec.aec:angle-2.0.0
True	 autodesk.spec.aec:area-2.0.0
True	 autodesk.spec.aec:costPerArea-2.0.0
True	 autodesk.spec.aec:decimalSheetLength-2.0.0
True	 autodesk.spec.aec:distance-2.0.0
True	 autodesk.spec.aec:length-2.0.0
True	 autodesk.spec.aec:massDensity-2.0.0
True	 autodesk.spec.aec:number-2.0.0
True	 autodesk.spec.aec:rotationAngle-2.0.0
True	 autodesk.spec.aec:sheetLength-2.0.0
True	 autodesk.spec.aec:siteAngle-2.0.0
True	 autodesk.spec.aec:slope-2.0.0
True	 autodesk.spec.aec:speed-2.0.0
True	 autodesk.spec.aec:time-2.0.0
True	 autodesk.spec.aec:volume-2.0.0
True	 autodesk.spec.measurable:currency-2.0.0

 

The idea was to stop the problem to go to the next version, I don't know if this report influenced but looks like was fixed in Revit 2023.

 

My application does not use any of these SpecTypeIds in GlobalParameter, but I use some of the most common parameter types (Text, Integer, YesNo). If this was this type probably gonna annoying me.

 

Everything is fine so! Thanks for the response, Jeremy!

 

 

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

Message 5 of 7
jeremy_tammik
in reply to: ricaun

Thank you for the updated test and confirmation. Glad to hear that it works now.

  

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 6 of 7

Hi there.Thanks for this topic. Is there a ForgeID for the YesNo parameter?

Message 7 of 7
ricaun
in reply to: piotr.choromanski

Here are the four basic SpecTypeId (bool, int, string, double)

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community