New idea for addin version management : Open for thoughts

New idea for addin version management : Open for thoughts

IbrahimNaeem
Advocate Advocate
389 Views
1 Reply
Message 1 of 2

New idea for addin version management : Open for thoughts

IbrahimNaeem
Advocate
Advocate

Referring to this discussion:

https://forums.autodesk.com/t5/revit-api-forum/addin-version-management/m-p/7261164#M24280

I'd like to share with you more efficient way to keep only one installer for all Revit versions and same dll file as well.

I used dependency Inversion principle and worked nice for this purpose. 

here's the code sample: 

class PlaneFactory : IPlaneCreator
    {
        Application _app;
        IPlaneCreator creator16;
        IPlaneCreator creator17;
        public PlaneFactory(Application app)
        {
            _app = app;
            creator16 = new PlaneCreator16(_app);
            creator17 = new PlaneCreator17();
        }

        public Plane CreatePlaneByInputs(XYZ Origin, XYZ vx, XYZ vy)
        {
            if (Convert.ToInt32(_app.VersionNumber) > 2016.5)
            {
                return creator17.CreatePlaneByInputs(Origin, vx, vy);
            }
            else
            {
                return creator16.CreatePlaneByInputs(Origin, vx, vy);
            }
        }

        public Plane CreatPlane()
        {
            if (Convert.ToInt32(_app.VersionNumber) > 2016.5)
            {
                return creator17.CreatPlane();
            }
            else
            {
                return creator16.CreatPlane();

            }
        }
    }

 I would like to see if you have different thoughts or ideas.

 

Thanks, Ibrahim Naeem

 

0 Likes
390 Views
1 Reply
Reply (1)
Message 2 of 2

jeremytammik
Autodesk
Autodesk

Dear Ibrahim Naeem,

 

Thank you for sharing your nice idea.

 

Here are my thoughts and suggestions:

 

  • Great idea, well worth pursuing!
  • Spell check your variables, properties and methods (e.g., `CreatPlane`).
  • Implement a static variable to cache the result of 

 

  Convert.ToInt32(_app.VersionNumber) > 2016.5

 

Cf. some discussion by The Building Coder:

 

 

Cheers,

 

Jeremy

 

 



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