Placing views with Ilogic

Placing views with Ilogic

FeelGoodGirl
Advocate Advocate
1,793 Views
6 Replies
Message 1 of 7

Placing views with Ilogic

FeelGoodGirl
Advocate
Advocate

Hello,

 

I am building a model with Ilogic. This is my first project where I use Ilogic. Now I get stuck on the following.

 

I have a number of views. I want to put this in a fixed place in the drawing. I manage to move the views. But if I adjust the length of the product, it no longer works. I will explain my problem with 1 view.

 

I use the following code:

Dim oView As DrawingView = Nothing
Dim oBasePosition As Point2d = Nothing
Dim oDrawingViews As DrawingViews = ThisApplication.ActiveDocument.Sheets.Item(1).DrawingViews
Dim XPos As String
Dim YPos As String
Dim XBasepunt As Double
Dim YBasepunt As Double
Dim Schaal As Double

' Where to place the product (in mm)
XBasepunt = 0
YBasepunt = 0	

'--------placing view 1-----------------
' Define drawing view
oView = oDrawingViews.Item(1)

' Schaal van het base view
Schaal = oView.Scale

' Values for X and Y positions
XPos = XBasepunt * Schaal
YPos = YBasepunt * Schaal

' Correct units
XPos /= 10
YPos /= 10

' Create a new point to move the baseview to.
oBasePosition = ThisApplication.TransientGeometry.CreatePoint2d()
oBasePosition.X = XPos + (oView.Width/2)
oBasePosition.Y = YPos + (oView.Height/2)

'Move the baseview to the new position
oView.Position = oBasePosition
'---------------------------------------

The problem is only in the height. In the photo you can see what happens if i change the height and run the rule. I didn't change the scale:

different heights.png

 

 

 

 

 

 

I cannot explain why this is the result. The goal is that, regardless of the height, the product would stand in the corner. Does anyone know where it goes wrong?

 

I look forward to your responses. 🙂

0 Likes
Accepted solutions (1)
1,794 Views
6 Replies
Replies (6)
Message 2 of 7

JelteDeJong
Mentor
Mentor

Maby i dont understand you correct. but for placing/moving a DrawingView you dont need to know the scale of the view. You only need to know the size of the DrawinView. The following code works for me:

Dim oView As DrawingView = Nothing
Dim oBasePosition As Point2d = Nothing
Dim oDrawingViews As DrawingViews = ThisApplication.ActiveDocument.Sheets.Item(1).DrawingViews
Dim XBasepunt As Double
Dim YBasepunt As Double

' Where to place the product (in mm)
XBasepunt = 0
YBasepunt = 0

'--------placing view 1-----------------
' Define drawing view
oView = oDrawingViews.Item(1)

' Create a new point to move the baseview to.
oBasePosition = ThisApplication.TransientGeometry.CreatePoint2d()
oBasePosition.X = XBasepunt + (oView.Width / 2)
oBasePosition.Y = YBasepunt + (oView.Height / 2)

'Move the baseview to the new position
oView.Position = oBasePosition
'---------------------------------------

 

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 7

FeelGoodGirl
Advocate
Advocate

Thank you for your responds. Unfortunately this code has the same effect as the previous one. I will try to explain what I do.

 

What I do:
step 1, place a view
step 2, run the code
result of step 2, he puts it in the indicated place
step 3, adjust the length of the product
step 4, run the code again
result step 4, doesn't put it in the indicated place

 

This problem is only in the y-direction. If I adjust the width, the view is moved in the right direction in the x direction. 

 

Do you happen to have another idea that could be due to this?

0 Likes
Message 4 of 7

JelteDeJong
Mentor
Mentor

i expexted this to work. maby you can try to update the drawing before you start the code. Or update at the start of your code:

Dim doc As DrawingDocument = ThisApplication.ActiveDocument
doc.Update()

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 5 of 7

FeelGoodGirl
Advocate
Advocate

I tried both. Without success. 😞

 

I use Inventor 2017. I don't whether that makes a difference.

0 Likes
Message 6 of 7

FeelGoodGirl
Advocate
Advocate
Accepted solution

I have found part of the problem.

 

Since I no longer knew what to do, I tried the flowing. I opened a new drawing and added the part and the code to it again. Here it works completely as it should. That is already a solution.

 

But it is not clear to me yet where this problem came from....But we will probably never know that.

Message 7 of 7

Genicee
Advocate
Advocate

I have been having the same issue on a few of my views. The only thing that seems to be related is that they are iParts. Although some work and some don't. It is always in the 'Y' direction as you mentioned. I hope it is a bug that can be fixed. It is pretty annoying they views do not go where I tell them to go.

0 Likes