How to set the view in a DWF file using Design Review API?

By Partha Sarkar

Setting the
View using Design Review API takes two different approach based on whether you
want to set View for a 2D DWF or 3D DWF.

Using
EPlotSection.SetView() function we can set a view for the current section
(page) of the DWF file based on the specified paper-based coordinates. Please
note, this API is available only for 2D sections i.e. 2D DWF files.

Here is a relevant C# code snippet:

CompositeViewer = (ECompositeViewer.IAdECompositeViewer) axCExpressViewerControl1.ECompositeViewer;
SectionChk = (ECompositeViewer.IAdSection) CompositeViewer.Section;
SectionTypeChk = (ECompositeViewer.IAdSectionType) SectionChk.SectionType;  
 
if (SectionTypeChk.Name == "com.autodesk.dwf.ePlot")
  { 
  PlotSection = (EPlotViewer.IAdEPlotSection) CompositeViewer.Section;
  View = (AdCommon.IAdPageView)PlotSection.View;  
  //Set View - interchange Left with Bottom and Top with Right 
  PlotSection.SetView (View.Bottom, View.Left, View.Top,  View.Right);
}

 

In 3D, using
EModelSection.Camera property, we can access the camera object of a specific 3D
section in the DWF that is currently loaded in the canvas. Then it can be
modified using the EModelCamera object, to access various properties of the
camera.

EModelCamera.Position
property -> Returns the current position of the camera. We can use [set]
method of this property to set the position of the camera to a known set of
coordinates (represented by IAdPoint object).


Comments

2 responses to “How to set the view in a DWF file using Design Review API?”

  1. Partha,
    Is it possible to view a DWF using Auotlisp/Visual Lisp and DCL?

  2. Partha,
    I can change the current view of a DWF but the changes are not saved when I call axCExpressViewerControl1.SaveAs(newDwfName);
    Is there a way to set the current view, and save the file so that when the file is opened again, my new view is used?

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading