Layout limits in .Net

Layout limits in .Net

mordend
Enthusiast Enthusiast
855 Views
1 Reply
Message 1 of 2

Layout limits in .Net

mordend
Enthusiast
Enthusiast

Hello,

 

I am wondering if there is a way to use the interop set the limits of a Layout?

 

My issue is that after creating a blank layout using the LayoutManager it defaults the limits to 0,0 & 12,9 which causes problems when generating the thumbnail for the tab.

 

Currently I can get it to generate a correct thumbnail by toggling display background in the options as this updates the limits of the layout object.

 

I am using doc.CapturePreviewImage and assigning it to the Layout.Thumbnail so I guess the other option is have another way to generate that Bitmap all together? It seems that the CapturePreviewImage  must use the limits as its bounding for the capture.

 

any suggestions?

 

thanks

0 Likes
Accepted solutions (1)
856 Views
1 Reply
Reply (1)
Message 2 of 2

mordend
Enthusiast
Enthusiast
Accepted solution

So I managed to get this sorted out myself.

 

After creating the layout and copying plot settings form an existing layout I then used a PlotSettingsValidator to set the SetZoomToPaperOnUpdate to true and im guessing that forces an update to the limits. Here is my code:

 

 using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    Layout layout = (Layout)tr.GetObject(toLayoutID, OpenMode.ForWrite);

                    PlotSettings ps = new PlotSettings(layout.ModelType);
                    ps.CopyFrom(fromLayout);

                    PlotSettingsValidator psv = PlotSettingsValidator.Current;

                    psv.SetZoomToPaperOnUpdate(ps, true);

                    layout.UpgradeOpen();
                    layout.CopyFrom(ps);

                    tr.Commit();
                }

 

Either way seems to work.

 

Hopefully this will help others

0 Likes