Framing section reorganization

Framing section reorganization

Sino.Pacific
Contributor Contributor
635 Views
8 Replies
Message 1 of 9

Framing section reorganization

Sino.Pacific
Contributor
Contributor

Hi everyone,

 

I am trying to create a code to recognize the structure framing section as the guideline from @Anonymous   https://thebuildingcoder.typepad.com/blog/2013/12/security-framing-cross-section-analyser-and-rex.html 

 

But when I run it, there was an error message as following: 

1.PNG

 

And following is the code I am using:

 

 

    public class MainCode : IExternalCommand
    {
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
    public class MainCode : IExternalCommand
    {
        void RexXsecAnalyis(
    ExternalCommandData commandData,
    Element e)
        {
            // Initialise converter

            RVTFamilyConverter rvt = new RVTFamilyConverter(
              commandData, true);

            // Retrieve family type

            REXFamilyType fam = rvt.GetFamily(e,
              ECategoryType.SECTION_PARAM);

            // Retrieve section data

            REXFamilyType_ParamSection paramSection = fam
              as REXFamilyType_ParamSection;

            REXSectionParamDescription parameters
              = paramSection.Parameters;

            // Extract dimensions, section type, tapered
            // predicate, etc.
            // If different start and end sections are 
            // required, use DimensionsEnd as well.

            REXSectionParamDimensions dimensions = parameters
              .Dimensions;

            ESectionType sectionType = parameters
              .SectionType;

            bool tapered = parameters.Tapered;

            bool start = true;

            Contour_Section contour = parameters.GetContour(
              start);

            List<ContourCont> shape = contour.Shape;
            TaskDialog.Show("info", sectionType.ToString()); 
          
        }

        static System.Reflection.Assembly OnAssemblyResolve(
        object sender,
        ResolveEventArgs args)
        {
            Assembly a = Assembly.GetExecutingAssembly();

            return Autodesk.REX.Framework.REXAssemblies
              .Resolve(sender, args, "2018", a);
        }

        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
 // Get control of the current document 
            UIDocument uIDocument = commandData.Application.ActiveUIDocument;
            DocumentSet alldocuments = uIDocument.Document.Application.Documents; 

            // Get document control
            Document document = uIDocument.Document;

            // Get current active view
            Autodesk.Revit.DB.View currentview = document.ActiveView;
            Selection selection = uIDocument.Selection;
            IList<Reference> SelectedElements = selection.PickObjects(ObjectType.Element);
      foreach (Reference refe in SelectedElements)
                {
                    Element selectedElement = document.GetElement(refe);
                        RexXsecAnalyis(commandData, selectedElement); 

}
            return Result.Succeeded;

}

}

 

 

So if you have experience about this, pleas help me to give a hint how was the problem and how to fix it.

Thank you and have a nice day.

 

Best Regards,

 

Sino

 

0 Likes
636 Views
8 Replies
Replies (8)
Message 2 of 9

RPTHOMAS108
Mentor
Mentor

I don't know how to fix that off hand but I'm wondering why you are not getting the section shape from Family.StructuralSectionShape? A library of families that implements this has standardised parameters and so is easier to identify dimensions of the section as well as the shape. 

 

Almost certain this feature of the REX framework is not covering all the section shapes that exist.

0 Likes
Message 3 of 9

Sino.Pacific
Contributor
Contributor

Dear Mr. @RPTHOMAS108 ,

 

Thank you for your comment. I have checked the Family.StruccturalSectionShape, but mostly all of the Structural framing family ( from default Library of Revit) is not defined: 

1.PNG

Do you have any other suggestion?

Thank you 🙂

 

Best Regards,

 

Sino

0 Likes
Message 4 of 9

jeremytammik
Autodesk
Autodesk

Regarding your first question on the null reference exception, the same answer as always: step through your code in the debugger line by line, look at the variable values, and you will see exactly what is causing the problem. That will help understand how to fix it.

 



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

0 Likes
Message 5 of 9

Sino.Pacific
Contributor
Contributor

Dear Mr. @jeremytammik ,

 

Thank you for your suggestion. I tried to find the bugs location and it had bug at the first line of RVTFamilyConverter as following image: 

 

 

1.PNG

Do you have any idea why this happen? 

Thank you 🙂

 

Best Regards,

 

Sino

0 Likes
Message 6 of 9

jeremytammik
Autodesk
Autodesk

Step into the family converter constructor with the debugger and step through that line by line.

 

That will show you exactly what error occurs, why and where.

 



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

0 Likes
Message 7 of 9

Sino.Pacific
Contributor
Contributor

Dear @jeremytammik ,

 

Thank you for your suggestion, but unfortunately I only know to use the Add in Manager to test the output DLL but don't know how to debug the constructor as you mentioned 😔

0 Likes
Message 8 of 9

RPTHOMAS108
Mentor
Mentor

Well the example section you highlighted (double angle) you wouldn't find a standard section shape for and it is also not listed in the REX section table (so would it even identify that?).

 

If you look at the 2020 content I-Section/C-Section... you'll likely find the section shape is set.

 

I think you have to decide for yourself between:

A) Trawling though code by others to complete the missing requirements which by description seem to relate to materials (something you are not interested in).

B) Use section shapes in your library, fill in data. This will also put you in good stead for other features that may use them e.g. steel connections.

C) Get end faces from symbol geometry those planar faces that have face normal matching direction in the family document. Analyse the curve loops to distinguish the profile types by traits such as: number of loops/line direction/profile symmetry/numbers of lines/number of arcs etc. (not sure how REX distinguishes between Round and Cable)? In planning use venn diagram or similar to separate out such traits and place each section type within the regions until each is uniquely distinguished.

 

As noted these are not the only section types that exist these days and if you go with option (C) then you can distinguish between those you know about but a further type may be introduced that is indistinguishable from an existing item (in relation to the traits you check with).

0 Likes
Message 9 of 9

mhannonQ65N2
Collaborator
Collaborator

What Revit version is this in? Your it looks like your 'OnAssemblyResolve' is returning the 2018 version of REX dlls.

 

This error is occurring in the REX SDK, I'd suggest looking at its documentation to see if anything there might help. I looked a bit and didn't find anything that could explain this. 

0 Likes