So, I'm in the process of converting my most used VBA macros to a C# add-in. I'm generating CS0266 error when trying to set View.Height. For some reason, Visual Studio thinks View.Height should be an int., but the documentation shows it as being a long (which would make more sense).
Here's the error:
Here's my code - am I doing something wrong?
DrawingDocument oDrawDoc = (DrawingDocument)Globals.InvApp.ActiveDocument;
string sBaseFName = oDrawDoc.DisplayName;
sBaseFName = System.IO.Path.GetFileNameWithoutExtension(sBaseFName);
try
{
// Set the active sheet and view
DrawingDocument oDoc =
(DrawingDocument)Globals.InvApp.ActiveDocument;
Sheet oSheet = oDoc.ActiveSheet;
Inventor.View oView = Globals.InvApp.ActiveView;
double dAspectRatio = oSheet.Height / oSheet.Width;
// Adjust the aspect ratio of the view to match that of the sheet
oView.Height = oView.Width * dAspectRatio;
Camera oCamera = oView.Camera;
This is Inventor2023 and Visual Studio 2022 if any of that matters.
Thanks for any suggestions.
Solved! Go to Solution.
Link copied