Strange View behaviour when created through API

Strange View behaviour when created through API

Raider_71
Collaborator Collaborator
916 Views
9 Replies
Message 1 of 10

Strange View behaviour when created through API

Raider_71
Collaborator
Collaborator

Hi,

 

Why would the Projected views created using the following code not have the option to set the Shaded Style or if it's linked from the Base view or not?

oView1 = oSheet.DrawingViews.AddProjectedView(oParentView, V1Point2D, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)

 

View Edit Issue.jpg

 

Thanks!

 

Pieter

0 Likes
Accepted solutions (1)
917 Views
9 Replies
Replies (9)
Message 2 of 10

JelteDeJong
Mentor
Mentor

you can set those option in your drawingview object.your code would look like this.

oView1 = oSheet.DrawingViews.AddProjectedView(oParentView, V1Point2D, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
oView1.ViewStyle = DrawingViewStyleEnum.kHiddenLineDrawingViewStyle

other options for DrawingViewStyleEnum are:

NameDescription
kFromBaseDrawingViewStyleDerive the style from the base drawing view.
kHiddenLineDrawingViewStyleHidden line style.
kHiddenLineRemovedDrawingViewStyleHidden lines removed style.
kShadedDrawingViewStyleShaded style (with hidden lines removed).
kShadedHiddenLineDrawingViewStyleShaded style with hidden lines.

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 10

HideoYamada
Advisor
Advisor

Hi,

 

Humm, it's strange...

 

I tested your view and found :

(1) Isometric view cannot inherit view style.

(2) But ViewStyle of the view that your code created was set as kFromBaseDrawingViewStyle.

  ViewStyle of the isometric view can be one of them :

    kHiddenLineDrawingViewStyle
    kHiddenLineRemovedDrawingViewStyle
    kShadedDrawingViewStyle
    kShadedHiddenLineDrawingViewStyle
(3) So if you set ViewStyle to one of the list in (2), the view style icons will be enabled again.

oView1 = oSheet.DrawingViews.AddProjectedView(oParentView, V1Point2D, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
oView1.ViewStyle = kHiddenLineDrawingViewStyle ' Change ViewStyle to something other than kFromBaseDrawingViewStyle.

 

=====

Freeradical

 Hideo Yamada

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes
Message 4 of 10

HideoYamada
Advisor
Advisor

(^_^;

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes
Message 5 of 10

Raider_71
Collaborator
Collaborator

Hi thank you for the quick response. 

 

The only problem I have is that I create all three views in one go and do not know if a view is not inline or not.

 

So my workflow is I create a sheet, calculate four points and a scale factor, Place a base view and then three projected views.

How would I know that a projected view is not aligned?

 

0 Likes
Message 6 of 10

Sergio.D.Suárez
Mentor
Mentor

Sorry, I can't open your file because I have an earlier version of inventor.
However, I have tried part of the code and it does not give me problems. Maybe there could be some error in the previous generation of oParentView.

 

Dim doc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = doc.ActiveSheet
Dim oParentView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select View")
If oParentView Is Nothing Then Exit Sub
Dim V1Point2D As Point2d= ThisApplication.TransientGeometry.CreatePoint2d( oParentView.Center.X+5,oParentView.Center.Y)

Dim oView1 As DrawingView = oSheet.DrawingViews.AddProjectedView(oParentView, V1Point2D, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)

 Cheers!


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 7 of 10

Raider_71
Collaborator
Collaborator

Hi as I said it only happens for Projected views that are not aligned vertically or horizontally. It is only for views that are projected to let's say the top right for instance.

 

0 Likes
Message 8 of 10

JelteDeJong
Mentor
Mentor

I cant check right now but i remember that if you create a not aligned view (also when you are using Projected views) that it becomes a base view it self.

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 9 of 10

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

You could align the projected views taking into account the position of the original parent view. Here is an example of how I could achieve it. The same results are achieved as performing the work manually.

 

Dim doc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = doc.ActiveSheet
Dim oSep As Double = 2
Dim oParentView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select View")
If oParentView Is Nothing Then Exit Sub

Dim V1Point2D As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oParentView.Center.X + 10, oParentView.Center.Y)
Dim V2Point2D As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oParentView.Center.X, oParentView.Center.Y - 10)
Dim V3Point2D As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oParentView.Center.X + 10, oParentView.Center.Y - 10)

Dim oView1 As DrawingView = oSheet.DrawingViews.AddProjectedView(oParentView, V1Point2D, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
Dim oView2 As DrawingView = oSheet.DrawingViews.AddProjectedView(oParentView, V2Point2D, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
Dim oView3 As DrawingView = oSheet.DrawingViews.AddProjectedView(oParentView, V3Point2D, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)

oView1.Position= ThisApplication.TransientGeometry.CreatePoint2d(oParentView.Center.X + oParentView.Width / 2 + oSep + oView1.Width / 2, oView1.Center.Y)
oView2.Position = ThisApplication.TransientGeometry.CreatePoint2d(oParentView.Center.X, oParentView.Center.Y - oParentView.Height / 2 - oSep - oView2.Height / 2)

oView3.Position = ThisApplication.TransientGeometry.CreatePoint2d(oParentView.Center.X + oParentView.Width / 2 + oSep + oView3.Width / 2, _
oParentView.Center.Y - oParentView.Height / 2 - oSep - oView3.Height / 2)
oView3.ViewStyle = oParentView.ViewStyle 

 I hope this can be useful. Cheers!


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 10 of 10

Raider_71
Collaborator
Collaborator

Hi @Sergio.D.Suárez 

 

Thanks that has solved the issue.

 

Purely setting this after the view has been created has re-enabled the options on a un-aligned projected view.

oView.ViewStyle = oParentView.ViewStyle 

Thanks again for the help.

 

Cheers

0 Likes