- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I have an old code to control views positions. All was working as expected few months ago I guess.
It work for front or side views, with a little lack of precision.
It doesn't work for orthographic and perspective views.
It doesn't seem to work anymore ![]()
I'm using IV2021.2
Here some examples codes to center a view on a sheet. Each command are producing some random results :
'SetCenter command Dim oViewName As String oViewName = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a view :").Name ActiveSheet.View(oViewName).SetCenter(ActiveSheet.Width / 2, ActiveSheet.Height / 2) MessageBox.Show("ActiveSheet.View(oView).SetCenter()" _ & vbNewLine & "View center X : " & ActiveSheet.View(oViewName).Center.X _ & vbNewLine & "View center Y : " & ActiveSheet.View(oViewName).Center.Y _ & vbNewLine & "Sheet center X : " & ActiveSheet.Width/2 _ & vbNewLine & "Sheet center Y : " & ActiveSheet.Height/2 , "iLogic")
'SetSpacingToCorner Dim oViewName As String oViewName = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a view :").Name Dim CornerX, CornerY As Decimal CornerX = (ActiveSheet.Width - ActiveSheet.View(oViewName).Width)/2 CornerY = (ActiveSheet.Height - ActiveSheet.View(oViewName).Height)/2 ActiveSheet.View(oViewName).SetSpacingToCorner(CornerX, CornerY, SheetCorner.TopLeft) MessageBox.Show("ActiveSheet.View(oView).SetCenter()" _ & vbNewLine & "View center X : " & ActiveSheet.View(oViewName).Center.X _ & vbNewLine & "View center Y : " & ActiveSheet.View(oViewName).Center.Y _ & vbNewLine & "Sheet center X : " & ActiveSheet.Width/2 _ & vbNewLine & "Sheet center Y : " & ActiveSheet.Height/2 , "iLogic")
'oBaseView.Position Dim oDoc As DrawingDocument oDoc = ThisDrawing.Document Dim oSheet As Sheet oSheet = oDoc.ActiveSheet Dim oBaseView As DrawingView oBaseView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a view :") Dim oViewName As String oViewName = oBaseView.Name Dim oTG As TransientGeometry oTG = ThisApplication.TransientGeometry Dim oOriginPoint As Point2d oOriginPoint = oTG.CreatePoint2d(oSheet.Width/2, oSheet.Height/2) oBaseView.Position = oOriginPoint MessageBox.Show("oBaseView.Position" _ & vbNewLine & "View center X : " & oBaseView.Center.X*10 _ & vbNewLine & "View center Y : " & oBaseView.Center.Y*10 _ & vbNewLine & "Sheet center X : " & oSheet.Width/2*10 _ & vbNewLine & "Sheet center Y : " & oSheet.Height / 2*10, "iLogic")
'oBaseView.Center Dim oDoc As DrawingDocument oDoc = ThisDrawing.Document Dim oSheet As Sheet oSheet = oDoc.ActiveSheet Dim oBaseView As DrawingView oBaseView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a view :") Dim oViewName As String oViewName = oBaseView.Name Dim oTG As TransientGeometry oTG = ThisApplication.TransientGeometry Dim oOriginPoint As Point2d oOriginPoint = oTG.CreatePoint2d(oSheet.Width/2, oSheet.Height/2) oBaseView.Center = oOriginPoint MessageBox.Show("oBaseView.Center" _ & vbNewLine & "View center X : " & oBaseView.Center.X*10 _ & vbNewLine & "View center Y : " & oBaseView.Center.Y*10 _ & vbNewLine & "Sheet center X : " & oSheet.Width/2*10 _ & vbNewLine & "Sheet center Y : " & oSheet.Height / 2*10, "iLogic")
Can you reproduce this ?
Any ideas ?
Thomas
Mechanical Designer / Inventor Professionnal 2025
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@ThomasB44 , there does seem to be a problem. I'll look into it further.
Here's a way to work around it:
- set the center once
- read the new center value back from the view : the achieved center point might not be what we asked for.
- adjust our desired center point by the difference between the really desired and achieved
- set the view center to that new new adjusted point. The system will adjust it again, thus giving us what we asked for originally!
Here's code. This can replace your SetCenter rule.
Dim viewX As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a view :")
Dim sheetX = viewX.Parent
Dim sheetCenter = ThisApplication.TransientGeometry.CreatePoint2d(sheetX.Width / 2, sheetX.Height / 2)
Dim pointWanted = sheetCenter.Copy()
viewX.Center = pointWanted
Dim pointAchieved = viewX.Center
Dim diff = pointAchieved.VectorTo(sheetCenter)
Logger.Info("diff 1 = {0}, {1}", diff.X, diff.Y)
pointWanted.TranslateBy(diff)
viewX.Center = pointWanted
Dim pointAchieved2 = viewX.Center
Dim diff2 = pointAchieved2.VectorTo(sheetCenter)
Logger.Info("diff 2 = {0}, {1}", diff2.X, diff2.Y)
(This uses the iLogic Log window instead of a message box. This window (or rather pane) can be made visible on the View > Windows > User Interface dropdown.)

Mike Deck
Software Developer
Autodesk, Inc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@ThomasB44 , it looks like this problem only happens with perspective views. Do you see it happening with an orthographic view? If you do, can you post a sample drawing?

Mike Deck
Software Developer
Autodesk, Inc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks for your code, it works.
I've done a repair of Microsoft Visual C++, it seems to correct some things.
I can see the problem happening with an orthographic view, if I set view size bigger than the sheet. But only with the command :
ActiveSheet.View(oView).SetSpacingToCorner()
You will find an example here attached.
Thomas
Mechanical Designer / Inventor Professionnal 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@ThomasB44 , this is not the same defect. SetSpacingToCorner is designed to try to place the view within the sheet. It won't work with negative offsets.
If you need to center a view that's bigger than the sheet, it's best to set the center point directly.

Mike Deck
Software Developer
Autodesk, Inc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Are there any updates on this bug?
I can confirm that it's not only with perspective views.
During drawing automation, a view on my drawing keeps getting moved, while the Position property stays the same (but the Center property changes).
This happens even though the bounding box of the view doesn't change, and also the center of the view (according to the center point of the model) doesn't change.
So that's strange, but I accepted it and wanted to move it back, but then I ran into this bug and the workaround fixes it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Unfortunately I'm not able to send a sample drawing, it's quite a large model and confidential.
But I can explain the workflow.
The involved drawing (actually drawings, there are about 25 similar drawings with this issue) is sort of a template drawing. The model assembly used in the drawing consists of multiple components overlapping.
On the drawing, we set parameters defining a configuration.
Then we've created an iLogic rule, which turns the visibility on/off for the components in the assembly according to the parameters, and then updates the views on the drawing (no new annotations are made).
The bounding box of some of the views will change, because of the size of some components, but all views remain on their locations.
The one problematic view is a section view with a crop, the crop is fully constrained (also tried without the crop).
Due to the crop, the outer dimensions of the view don't change and also the part of the model shown is exactly the same, but the view moves a bit on the drawing for some reason.
I can't explain why, but I accepted the fact that it moves, so the easiest thing to do is reposition the view afterwards.
So before anything is changed, I store the Center property in a variable.
Then the visibility will get switched, causing the view to move.
Then I reposition the center of the view back to the stored location.
It does move, but not to the correct position.
Then I use the code above to translate it again, using the difference.
Now the view is in the same location again.
Here are the results from looking up the Center and Position property of the view, before moving (Start), after the visibility change, after the first reposition and the final position after the correction.
You can see that after the view has moved due to the visibility, then Position is still the same, but the center has changed.
| Center X | Center Y | Position X | Position Y | |
| Start | 16,73628161 | 4,544619298 | 17,05079469 | 4,566641091 |
| Before reposition | 17,22016003 | 4,541820581 | 17,05079469 | 4,566641091 |
| After first reposition | 16,90564695 | 4,519798788 | 16,73628161 | 4,544619298 |
| Final | 16,73628161 | 4,544619298 | 16,56691626 | 4,569439808 |
This is the view before and after, so exactly the same boundaries. The components didn't move in relation to the center point of the model:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
You said that:
"The one problematic view is a section view with a crop, the crop is fully constrained (also tried without the crop)."
Does the same problem occur when the view is uncropped?
Is the crop a drawing sketch, constrained to model geometry?

Mike Deck
Software Developer
Autodesk, Inc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It's in the line you've quoted between parentheses
.
I've also tried it without the crop, so uncropped.
The crop sketch is the default rectangle from a default crop, but it's constrained to the model geometry.
After the view is modified, all the model geometry is still available.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Does the same problem with the view position occur even without the crop? That is: it is not necessary to have a cropped view to reproduce the problem?

Mike Deck
Software Developer
Autodesk, Inc.