how to change cielling plan's view range , offset and associated level

how to change cielling plan's view range , offset and associated level

Or.levi
Contributor Contributor
2,097 Views
7 Replies
Message 1 of 8

how to change cielling plan's view range , offset and associated level

Or.levi
Contributor
Contributor

hey,

I have an active cielling plan, i would like to change it's view range.

to be more specific: i would like to change the Top associated level, and the view depth from unlimited to current level

and set new offset values:

Orlevi_0-1648244124896.png

 

by looking at my immediate window when debugging, it seems as though i can get the view range values, and set

new levelId to the view range ( integerValue: -1  == unlimited,  integerValue:-3==current, etc...)

also setting new offset values are looking good in the immediate window, but the nothing changes in the model.

 

is it possible to change view range using the api?  if so, can someone help me understand what is the problem and tell me what i'm doing wrong? 

 

 

public void viewRange(Document doc)
        {
            //setting the view plan to be active view
            ViewPlan viewPlan = doc.ActiveView as ViewPlan;

            //setting plan- view planes to the top clip, cut plane,bottom plane and view depth
            PlanViewPlane planView_topClip = PlanViewPlane.TopClipPlane;
            PlanViewPlane planView_bottomClip = PlanViewPlane.BottomClipPlane;
            PlanViewPlane planView_cutClip = PlanViewPlane.CutPlane;
            PlanViewPlane planView_vDepth = PlanViewPlane.ViewDepthPlane;

            //setting view range variable
            PlanViewRange viewRange = viewPlan.GetViewRange();
            
            //using transaction to execute changes in the model
            using (Transaction transaction = new Transaction(doc, "transactionName"))
            {
                  
                    transaction.Start();

                    //setting offser changes to the view range
                    viewRange.SetOffset(planView_topClip, 666 * 0.03280839);
                    viewRange.SetOffset(planView_cutClip, 222 * 0.03280839);
                    viewRange.SetOffset(planView_bottomClip, 322 * 0.03280839);
                    viewRange.SetOffset(planView_vDepth, 222 * 0.03280839);

                    //getting elementId for the current,unlimited, level below and above 
                    ElementId ele = PlanViewRange.Current;
                    ElementId ele_inf = PlanViewRange.Unlimited;
                    ElementId ele_lev_bel = PlanViewRange.LevelBelow;
                    ElementId ele_lev_abo = PlanViewRange.LevelAbove;
                   
                    // set changes to the view range top , bottom and depth and associate them to the current level.
                    viewRange.SetLevelId(planView_topClip, ele);
                    viewRange.SetLevelId(PlanViewPlane.BottomClipPlane, ele);
                    viewRange.SetLevelId(PlanViewPlane.ViewDepthPlane, ele);

                    transaction.Commit();
                
                


            }
        }

 

 

0 Likes
2,098 Views
7 Replies
Replies (7)
Message 2 of 8

jeremy_tammik
Alumni
Alumni

Nothing changes because you are modifying properties of your local variable `viewRange`.

 

To have an effect on the model, you need to modify whatever is hiding behind `viewPlan.GetViewRange`.

 

Maybe the SetViewRange method will help?

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 8

Or.levi
Contributor
Contributor

hey jeremy,

thank you for your reply. 

unfortunately i could not set the new Top associated level or view depth associated level.. 

so i just used Get method to see if the view range is not good, and promped the user to change it:

if(associatedTopPlane_Id != level.Id || associatedViewDepthPlane_Id != level.Id)
{

TaskDialog.Show("View range not valid", "Pleas adjust the view range to associate to the CURRENT level only.");
// stop the script untill the user changes the VR
Form1.stopScript=true;
}

 

thanks!

0 Likes
Message 4 of 8

jeremy_tammik
Alumni
Alumni

That looks like a good solution too. Thank you for sharing it!

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 8

RPTHOMAS108
Mentor
Mentor

Not clear on what levels you are using i.e. the same level for the primary view range and view depth or not? If using the same level then the offsets look wrong because the view depth needs to be higher than the primary top for a ceiling plan i.e. you are looking up so view depth is beyond top in that direction, above it not below it (as would be the case for floor plan). 

 

PlanViewPlane.ViewDepthPlane = 222 / 304.8
PlanViewPlane.TopClipPlane = 666 / 304.8

0 Likes
Message 6 of 8

Or.levi
Contributor
Contributor

hey @RPTHOMAS108 , thanks for your reply.

I am using the same level for the primary view range and view depth, and indeed tried to change the offset so the view depth to be "higher" then the primary top view range for the cielling plan.

I tried different variations and played with the setViewRange method, but it seems like it won't change the associated view depth plane/ Top plane. 

i could only Get the data, and not Set it.

 

0 Likes
Message 7 of 8

RPTHOMAS108
Mentor
Mentor

So when you call:

 

ViewPlan.SetViewRange(PlanViewRange)

 

You get no exception just no change? If it doesn't work and it is not governed by view template then it must be a bug.

Message 8 of 8

d6222300060
Contributor
Contributor

Once you did all the changes to viewRange you have to SetViewRange as well for your view plan. Which accepts your viewRange

viewPlan.SetViewRange(viewRange)

The changes will be affective once you add this