For the life of me i cannot understand why this ilogic rule is failing.
It is meant to add a base view to the active drawing at a certain position. The code is almost identical to the SDK samples
Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDrawingDoc.Sheets.Item(1)
Dim oPoint1 As Point2d
oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d (20, 20)
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.Documents.Open("c:\testpart.ipt",False)
Dim oBaseView As DrawingView
oBaseView= oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, 1/10, _
kFrontViewOrientation,kHiddenLineRemovedDrawingViewStyle,)
oPartDoc.Close(True)
It is failing at the highlighted line
Can anyone nudge me in the right direction to get this to work.............thanks
Solved! Go to Solution.
Solved by VdVeek. Go to Solution.
ok figured it out, i have to include the enums in that line
oBaseView= oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, 1, ViewOrientationTypeEnum.kFrontViewOrientation,DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle,"Default")
So what this appears to do is place the center of the base view on oPoint1
What i want to do is place the bottom left corner of the view at oPoint1...............any ideas how to achieve that?
thanks
Swordmaster, a way to do this is by subtract the half baseview width and height from the center position of the view.
I didn't test this code but i copied and modified it from a rule i use.
Dim oPoint1 As Point2d
oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d (20, 20)
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.Documents.Open("c:\testpart.ipt",False)
' first place the baseview at (20,20)
Dim oBaseView As DrawingView
oBaseView= oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, 1/10, _
kFrontViewOrientation,kHiddenLineRemovedDrawingViewStyle,)
'Create a new point to move the baseview to.
Dim oBasePosition As Point2d
oBasePosition = ThisApplication.TransientGeometry.CreatePoint2d()
oBasePosition.X = 20 - (oBaseView.Width/2)
oBasePosition.Y = 20 - (oBaseView.Height/2)
'Move the baseview to the new position
oBaseView.Position = oBasePosition
Rob.
Rob,
Thanks for the reply, it makes a lot of sense. I had been thinking somewhat along the same lines. However i was missing oBaseView.width/2 and .height/2
Regarding the first point (in the example its 20,20)
Been trying to understand what 20 actually is. Does not seem to be based on the view scale. Any ideas?
Swordmaster, 20 means 20 centimeters from the left-bottom corner of the drawing sheet in the X or Y direction. The Inventor API uses centimeters.
Rob.
Thanks,
I had completely forgotten that the API used centimetres
thanks