Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Modify ReadOnly but UserModifiable parameter

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
1555 Views, 3 Replies

Modify ReadOnly but UserModifiable parameter

Hi,

 

I was trying to modify the "Scale Value    1:" parameter on a Viewport, when I realized it's ReadOnly so it is not possible to modify through the API, but it is also UserModifiable and I can easily change the scale of the Viewport in the GUI.

It's a bit confusing, I found some stuff about these parameters but found no solution.

Article1

Article2

But these articles only talk about how it's weird, and contain no solution.


I also tried using:

viewport.GetBoxOutline().Scale(x);

but with no luck, it just does not modify the scale.

 

So currently there is just no way to modify the scale and other ReadOnly-UserModifiable parameters or am I just missing something and did not look deep enough?

3 REPLIES 3
Message 2 of 4
stever66
in reply to: Anonymous

Here is an example of how to change the scale:

 

https://stackoverflow.com/questions/24977724/how-to-obtain-a-sheet-number-for-a-view-with-the-revit-...

 

And here is a macro I tried that works.  It assumes the current view is the one you want to change.

public void ChangeViewScale()
        {
            UIDocument uidoc = ActiveUIDocument;
            Document doc = ActiveUIDocument.Document;
            Autodesk.Revit.DB.View pView = ActiveUIDocument.Document.ActiveView;
            
             using (Transaction transView = new Transaction(doc, "Set Param"))
             {
                 transView.Start();
                 string message = null;
                int testScale = 100;
                pView.Scale = testScale;
                message += "\nView name: " + pView.ViewName;
                message += "\nScale after set: " + pView.Scale;
                TaskDialog.Show("Revit", message);
                 transView.Commit();

                 
             }
            
        }

 

Message 3 of 4
Anonymous
in reply to: stever66

You may find that you can't modify the scale of a ViewPort (though you can try setting the View Scale parameter as suggested above, that may work)

 

The reason I suggest this is that the ViewPort is really just showing you the scale of the DBView that it owns (or that it "expresses" depending on how you want to look at it).

 

You may find that getting the DBViewId (from the ViewId param on ViewPort) and then revitDoc.GetElement(myViewPort.ViewId) setting its "Scale" property is what you really want to do. 

 

Message 4 of 4
Anonymous
in reply to: Anonymous

Thanks guys, yep I was trying to set the scale on the ViewPort not the view itself, and also I was checking the wrong parameter...
Now I use the view to set the scale and it works just fine.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report