2 Replies Latest reply on Jan 14, 2015 8:10 AM by Has Bal

    refresh Drawing view center position

    Has Bal

      I am trying to find outline and center position of a drawing view. I have managed thanks to your help.

      When i go further for my purpose to reach.I faced one problem.

      My aim is that; first draw a part and draw its drawing and save them.

      After, I will change part's outside dimension.

      Next, open its drawing and find outline of drawing view and its center position to evaluate and change its position.

      You can see in picture.

      pic 1 ; 50x50 mm square block

      pic 2; 50 x50mm square block drawing view and its position and outlines.


      pic 3; changing of square to  rectangular block which outside dimension is 200x50 mm.

      pic 4; new block drawing and its position and outline coordinates.


      As you can see, when I change dimension of parts its drawing view center position stay same.

      It is problem for me . Because when i try to move drawing view to another coordinate ,in picture 5, its center position still act like old position.So I cannot understand its center position. (I know and I can  calculate  from outline point its center coordinate but it produce heavy calculation for future)



      Finally , are there anything to refresh its center position?

      Pic 11.jpg


      pic 33.jpg


      pic 55.jpg

        • Re: refresh Drawing view center position
          Keith Rice



          In the future, please post a macro and file set that repeats the problem in the simplest way possible. Most people don't know what API calls you are using so it makes it hard for them to help you.


          My guess is that you are using IView::Position to find the center and IView::GetOutline to get the max and min coordinates of the view outline. There is a known bug in IView::Position concerning this:


          SPR 682112 - View position does not change after configuration changes. “IView::Position and IView::GetXform produce the same results even after a configuration change revises view extents”.


          I would recommend that you email API support and ask them to add you to the notification list for this bug.


          As you noted, you'll need to perform some math to get the center value using IView::GetOutline.



          SolidWorks API Tutorials

            • Re: refresh Drawing view center position
              Has Bal

              Keith you are right...

              So here my code...


              SldWorks swApp = new SldWorks();

              ModelDoc2 swDoc = null;

              DrawingDoc swDraw = default(DrawingDoc);

              SolidWorks.Interop.sldworks.View swView;


              swDoc = ((ModelDoc2)(swApp.ActiveDoc));


              swDraw = ((DrawingDoc)(swDoc));


                swView = swDraw.GetFirstView();// get sheet.


                swView = swView.GetNextView();// get drawign view1


              string drawingViewName = swView.GetName2();// get drawing view name


              object objPrevOutline = swView.GetOutline();// get drawign view1 outline


              // objPrevOutline[0]=xMin,objPrevOutline[1]=yMin,objPrevOutline[2]=xMax,objPrevOutline[3]=yMax        


              double[] vPos = swView.Position;// get drawign view1 center position vPos[0]=x, vPos[1]=y


              However you  answered my questions there are noway to  fix it...