MOdify Structural Asset

MOdify Structural Asset

Anonymous
Not applicable
838 Views
4 Replies
Message 1 of 5

MOdify Structural Asset

Anonymous
Not applicable

I am getting a very not explanatory error : An internal error has occurred.(Screenshot attached), and would like to know what the error is or how to solve it. Thank you in advance.

 

 

 

Here is working version of my code :

 

ElementId matID = Material.Create(Data.uiDoc.Document, "Metal - Steel 43-275");
rMat = Data.uiDoc.Document.GetElement(matID) as Material;
StructuralAsset asset = new StructuralAsset("STEEL 43-275", StructuralAssetClass.Metal);
asset.SubClass = "Steel";
rMat.MaterialClass = "Metal";
asset.Name = "STEEL 43-275";
asset.Behavior = StructuralBehavior.Isotropic;
asset.Density = 77.0365930404257 / 0.346436881;
asset.SetYoungModulus(UnitUtils.ConvertToInternalUnits(205000000, DisplayUnitType.DUT_KILONEWTONS_PER_SQUARE_METER));
asset.SetShearModulus(UnitUtils.ConvertToInternalUnits(205000000 / (2 * (1 + 0.3)), DisplayUnitType.DUT_KILONEWTONS_PER_SQUARE_METER));
asset.SetPoissonRatio(0.3);
asset.SetThermalExpansionCoefficient(1.2E-05);

PropertySetElement pse = Data.uiDoc.Document.GetElement(pse.Id) as PropertySetElement;
pse.SetStructuralAsset(asset);
rMat.StructuralAssetId = pse.Id;


Kind regards,

0 Likes
839 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk

Dear Bennie,

 

Thank you for your report.

 

The Revit development team will want to take a look at this.

 

Will this code generate the internal exception in any model, e.g., in a new project?

 

Does it have any other dependencies at all?

 

If so, please provide a full minimal reproducible case:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Otherwise, I can just pass on your report as it is.

 

Thank you!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 5

Anonymous
Not applicable
Hi ,

This is the complete use case to create a material and structural asset,
the only difference is the place where I get the values from which I have
hard coded in. the code should show error as is.
0 Likes
Message 4 of 5

jeremytammik
Autodesk
Autodesk

Dear Bennie,

 

Thank you for your update and patience.

 

I logged the issue REVIT-129110 [SetStructuralAsset throws internal exception -- 14011992] 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.

 

Do you have a workaround for this issue, or can you live with the situation as is?

 

Thank you!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 5

jeremytammik
Autodesk
Autodesk

Dear Bennie,

 

Thank you for your patience.

 

The development team analysed the issue REVIT-129110 [SetStructuralAsset throws internal exception -- 14011992] and reply:

 

The posted code cannot be built.

 

Here is one version that would work.

 

  Document myDoc = this.Application.ActiveUIDocument.Document;
  Transaction myT = new Transaction(myDoc, "Test");
  myT.Start();
  ElementId matID = Material.Create(myDoc, "my Material");
  Material myMat = myDoc.GetElement(matID) as Material;
  StructuralAsset asset = new StructuralAsset("STEEL 43-275", StructuralAssetClass.Metal);
  asset.SubClass = "Steel";
  myMat.MaterialClass = "Metal";
  asset.Name = "STEEL 43-275";
  asset.Behavior = StructuralBehavior.Isotropic;
  asset.Density = 77.0365930404257 / 0.346436881;
  asset.SetYoungModulus(UnitUtils.ConvertToInternalUnits(205000000, DisplayUnitType.DUT_KILONEWTONS_PER_SQUARE_METER));
  asset.SetShearModulus(UnitUtils.ConvertToInternalUnits(205000000 / (2 * (1 + 0.3)), DisplayUnitType.DUT_KILONEWTONS_PER_SQUARE_METER));
  asset.SetPoissonRatio(0.3);
  asset.SetThermalExpansionCoefficient(1.2E-05);
  // Create a new Property Set Element
  PropertySetElement pse = PropertySetElement.Create(myDoc, asset);
  myMat.SetMaterialAspectByPropertySet(MaterialAspect.Structural, pse.Id);
  myT.Commit();

 

Notice that it creates a new PropertySetElement, while the original code was trying to get an element with an uninitialised element id.

 

Even if the user was able to twist the compiler error setting to build the project, it would still create a null object.

 

That could explain the exception at the next line where the null object is used.

 

Having said that, there is another potential problem in using StructuralAsset to create the PropertySetElement.

 

If the name "STEEL 43-275" is already used, the internal code would throw an exception for not-unique name.

 

The API documentation on the SetStructuralAsset and PropertySetElement.Create methods lists the exception and its conditions:

 

 

However, because the exception was not thrown directly at the method validation (embedded instead), the exception was not visible when the API user calls the method.

 

Given the previous problem, I doubt this is the issue here.

 

Can you please verify that the corrected code works for you?

 

The problem report REVIT-129110 has now been closed as 'data fixed'.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes