Bug when searching for drawing standard type views

Bug when searching for drawing standard type views

ReneRepina
Collaborator Collaborator
1,189 Views
12 Replies
Message 1 of 13

Bug when searching for drawing standard type views

ReneRepina
Collaborator
Collaborator

Greetings,

 

I founded a bug while working view iLogic and drawing views.

In my iLogic I have a code "If oDrawingView.ViewType = DrawingViewTypeEnum.kStandardDrawingViewType Then", to find all standard (main) views on the drawing. It works great. But the problem comes when a person have projected views from standard (main) view and then deletes the main view and wants to keep projected one(s). So when this happens, Inventor should dedicate all non-dependable views as "Standard views". But since this does not happen, code just simply jumps over them, since they are still "projected views".

 

Maybe this is how it should be, but I think they should change view type if they do not have main view anymore, since they're their own main view now.

 

Hope I explained it good.

 

 

Best regards,

ReneR

0 Likes
Accepted solutions (3)
1,190 Views
12 Replies
Replies (12)
Message 2 of 13

johnsonshiue
Community Manager
Community Manager

Hi ReneR,

 

Indeed, the behavior does not sound right to me. It can be a limitation or a bug. I will need to work with the project team to understand it better.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 3 of 13

MjDeck
Autodesk
Autodesk
Accepted solution

While we investigate, here's a workaround. You can check the DrawingView.ParentView property. If the ViewType is projected but the ParentView is Nothing, then I think it's safe to treat it as a top-level view.


Mike Deck
Software Developer
Autodesk, Inc.

Message 4 of 13

YuhanZhang
Autodesk
Autodesk
Accepted solution

Hi Rene,

 

If your code is to find all the independent drawing views you should not rely on the standard view type, the standard view type just indicates it is a base view, your purpose is to find all the drawing views who have no parent view, so you just need to check the DrawingView.ParentView instead of the ViewType. You can find the Base view, Projected view and Auxiliary view all can be independent, so Mike's 'workaround' is the way you need to use in your code.

 

Hope this clears.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 5 of 13

ReneRepina
Collaborator
Collaborator

Greetings,

 

I read through the comments and I added suggestions into the code. I came up with this solution (I cutted the rest of the code, since it is not needed for this topic).

 

This code works great, thank you all for suggestion. But there is one problem left. When I run this code, it flags isometric views too, but I do not want them to be flagged. The thing is isometric view is a "top parent", but it is also a projected view, if you projected it when you are placing a base view.

 

The code is:

Dim oDrawingView As DrawingView

For Each oDrawingView In ThisApplication.ActiveDocument.ActiveSheet.DrawingViews
	
	'Check if a view has a parent, if not, do this.
	If oDrawingView.ParentView() Is Nothing Then
		oDrawingView.ShowLabel = True
		oDrawingView.Name = "Top parent view"
	Else
		'oDrawingView.ShowLabel = True
		'oDrawingView.Name = "Not top parent view"
	End If
	
Next

 

Best regards,

ReneR

0 Likes
Message 6 of 13

ReneRepina
Collaborator
Collaborator

Greetings Mike,

 

that works for the all top parent views, but it also flags isometric views. In my situation I do not want isometric views to be flagged. But if somebody does not mind isometric views to get flagged, this will work.ž

 

 

Best regards,

ReneR

0 Likes
Message 7 of 13

ReneRepina
Collaborator
Collaborator
Accepted solution

Greetings,

 

I found a solution to my case. Thank you all for help. Hope my code helps other with similiar cases.

 

Code:

Dim oDrawingView As DrawingView

For Each oDrawingView In ThisApplication.ActiveDocument.ActiveSheet.DrawingViews
	
	'Check if a view has a parent, if not, do this.
	If oDrawingView.ParentView() Is Nothing Then
		
		If oDrawingView.Camera.ViewOrientationType = 10762 Or _ 'Bottom Left ISO view
			oDrawingView.Camera.ViewOrientationType = 10761 Or _ 'Bottom Right ISO view
			oDrawingView.Camera.ViewOrientationType = 10760 Or _ 'Top Left ISO view
			oDrawingView.Camera.ViewOrientationType = 10759 Then 'Top Right ISO view

			oDrawingView.Name = "ISO VIEW"
		   
		Else
			oDrawingView.Name = "Top parent view"
		End If
		
		oDrawingView.ShowLabel = True

	Else
		'oDrawingView.ShowLabel = True
		'oDrawingView.Name = "Not top parent view"
	End If
	
Next

Best regards,

ReneR

0 Likes
Message 8 of 13

MjDeck
Autodesk
Autodesk

@ReneRepina , note that you don't have to use those numbers in the rule. If you add this line at the top of the rule:

Imports Inventor.ViewOrientationTypeEnum

Then iLogic will recognize the descriptive names kIsoTopRightViewOrientation, kIsoTopLeftViewOrientation, etc. in the code. You can use them in place of the numbers.

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 9 of 13

ReneRepina
Collaborator
Collaborator

@MjDeck Thank you for additional help. I know I can use this instead of numbers (in this code I used like that because I found these syntaxes).

 

I found one problem though. The ISO views in my code are defined by 4 sides and it works ok, but if I turn view for 180° (so I see the backside), it does not flag him as TopRight or TopLeft or BottomRight or BottomLeft. I will try to came up with something and see what happens.

0 Likes
Message 10 of 13

MjDeck
Autodesk
Autodesk

Maybe kArbitraryViewOrientation would work for that case.


Mike Deck
Software Developer
Autodesk, Inc.

Message 11 of 13

ReneRepina
Collaborator
Collaborator

I tried kArbitraryViewOrientation view. It works for other ISO views, but the new problem I am having currently using this, is that, if I for example put Base view in (as default like Inventors adds it), it works ok, but when I turn this base view for 90° (or anything else, even on others sides) it will flag it as kArbitraryViewOrientation and my code won't work as good as it should.

 

This code works for every manipulated view, but does not flag only iso views.

 

Dim oDrawingView As DrawingView

For Each oDrawingView In ThisApplication.ActiveDocument.ActiveSheet.DrawingViews
	
	'Check if a view has a parent, if not, do this.
	If oDrawingView.ParentView() Is Nothing Then
	
		'Check if view is an ArbitratyView
		If oDrawingView.Camera.ViewOrientationType = ViewOrientationTypeEnum.kArbitraryViewOrientation Then
			oDrawingView.Name = "Arbitraty VIEW"   
		Else
			oDrawingView.Name = "Top parent view"
		End If
		
		oDrawingView.ShowLabel = True

	Else
		'Code for non-top parent
	End If

Next
0 Likes
Message 12 of 13

MjDeck
Autodesk
Autodesk

You can look at the numbers in the view projection matrix. It requires some code, but it might be the only way.
If the view is aligned to the model axes, then all the axis vectors in the matrix should have these properties:
- only one of the values is not 0
- the non-zero value is either 1 or -1
A matrix is available from the DrawingView.ModelToSheetTransform. Its axis vectors are multiplied by the view scale. So instead of testing for an absolute value of one, you would be looking for an absolute value of the view scale. (Another option would be to divide all numbers by the view scale.)
The matrix is 4x4, but you just want the 3x3 part of it that holds the axis vectors. That would be cells 0 to 2, 4 to 6, and 8 to 10.

Because of round-off error, you can't compare for exact equality to zero or the view scale. You have to allow a small tolerance.


Mike Deck
Software Developer
Autodesk, Inc.

Message 13 of 13

ReneRepina
Collaborator
Collaborator

Hello @MjDeck .

 

After a really long time (5  years lol), I have manage to come to this reply.

 

Thank you for the suggestion. A good idea to check the matrix values. As time passed by, we went with the original solution we had and it is working 99,9% of the time and for the error cases, it is users fault for not placing the view in the right way.

0 Likes