Jump to content

How to receive camera target on the model viewport


IvanShubin
 Share

Recommended Posts

I create my app on the C# with using Autodesk.AutoCAD.Interop to interact with AutoCad. I try to receive camera direction:

 

var _app = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application");
var viewport = _app.ActiveDocument.ActiveViewport;
var dir = viewport.Direction;

 

but after rotaion of the model, I always receive same values of direction. If I use following code:

 

var _app = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application");
var viewport = _app.ActiveDocument.ActiveViewport;
var dir = viewport.Direction;

 

and activate viewport on the layout - after rotation of the model I receive difference correct direction.

 

How to receive correct camera direction on the model viewport?

Link to comment
Share on other sites

. . . .

 

but after rotaion of the model, I always receive same values of direction. . . . .

 

I found this in the AutoCAD ActiveX (the API in use via Interop) documentation:

 

No editing or view changes can be performed unless the viewport is active. To make a viewport active, use the ActiveViewport property on the Document object.

 

Once changes have been completed, the viewport must be reset as the active viewport for the changes to appear. To reset the active viewport, simply call the ActiveViewport property again with the updated Viewport object.

Link to comment
Share on other sites

Thank you SEANT,

 

But I do not want to update of the ViewPort, I want receive actual value of the Direction. Every time, I create new instance of the ViewPort. But after namual change of the ViewPort Direction in the AutoCad, I alway receive same value of the Direction. If I restart the AutoCad - I receive the updated value of the Direction.

 

Any more ideas?

 

Can somebody check the following code:

var _app = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application");
var viewport = _app.ActiveDocument.ActiveViewport;
var dir = viewport.Direction;

 

Maybe I have problems with my AutoCAD.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...