Set area load orientation to project ... How?

Set area load orientation to project ... How?

Sydra7
Contributor Contributor
781 Views
3 Replies
Message 1 of 4

Set area load orientation to project ... How?

Sydra7
Contributor
Contributor

Hi guys!

I have a big problem about area loads. I want to create new loads with my addin but every created area load is oriented the workplane. How can i change that? Is there an analog api function like "Orient to" option in the gui? (I don't find the solution since three days :()

Regards
David

0 Likes
Accepted solutions (2)
782 Views
3 Replies
Replies (3)
Message 2 of 4

gopinath.taget
Alumni
Alumni

Are you able to change the orientation using the UI. Typically, if you are not able to change it using the UI, you cannot change it using the API (sorry for the bad news).

 

Best Regards,

Gopinath

 

Message 3 of 4

andrzej.trelinski
Autodesk
Autodesk
Accepted solution

Hi Sydra7,

 

It is possible to change "Orient To" parameter through API in Revit 2014RTM.

I have attached "ChangingLineLoadOrientToViaAPI.rvt" file, with working solution for You:

1. Load    attached "ChangingLineLoadOrientToViaAPI.rvt" file. (File saved in 2014 RTM)
2. Choose "Enable Macros" on start up
3. Select LineLoad in 3D view
4. Run Manage tab -> Macro Manager -> Project tab
5. Expand "Loads" and select "ChangingLineLoadOrientToViaAPI" C# macro
6. Click run.
7. Popup should show and OrinetTo parameter for LineLoad should change

 

 

C# code from inside is:

        public void ChangingLineLoadOrientToViaAPI()
        {
            FilteredElementCollector collector = new FilteredElementCollector(this.Document);
            IList<Element> elements = collector.WherePasses(new ElementCategoryFilter(BuiltInCategory.OST_LineLoads)).WhereElementIsNotElementType().ToElements();
            using (Transaction transaction = new Transaction(this.Document))
            {
                transaction.Start("ChangingLineLoadOrientToViaAPI");
                foreach (LineLoad load in elements)
                {
                    Parameter param = load.get_Parameter(BuiltInParameter.LOAD_USE_LOCAL_COORDINATE_SYSTEM);
                    int orgVal = param.AsInteger();
                    int newVal = (orgVal == 0) ? 2 : 0;
                    param.Set(newVal);
                    
                    TaskDialog.Show("ChangingLineLoadOrientToViaAPI""LineLoad ID: " + load.Id + "; Original OrientTo value was: " + orgVal + "; New OrientTo value: " + newVal);
                }
            
                TransactionStatus ts = transaction.Commit();
            }
            
        }

 

Regards,

Andrzej Trelinski

0 Likes
Message 4 of 4

andrzej.trelinski
Autodesk
Autodesk
Accepted solution

Hi Sydra7,

Since Revit 2015RTM, "Orient to" parameter for Point, Line and Area loads can be get and set directly by parameter OrientTo in LoadBase class (which is base class for PointLoad, LineLoad and AreaLoad classes).
Ex: pointLoad.OrientTo = enum { Project, WorkPlane, HostLocalCoordinateSystem }

Best regards,
Andrzej Trelinski
Revit developer

0 Likes