IV9: Moving a DrawingView in IDW files - my VBA doesn't work

IV9: Moving a DrawingView in IDW files - my VBA doesn't work

Anonymous
Not applicable
389 Views
2 Replies
Message 1 of 3

IV9: Moving a DrawingView in IDW files - my VBA doesn't work

Anonymous
Not applicable
Hi All,

I need to move the position of a drawing view (using VBA) before generating a DXF file from that IDW.

Inventor's help tells me that DrawingView.Center can both set and get the center position of my view. I have tried to use this to move my view, but nothing happens!

Dim oDwgView as DrawingView
set oDwgView = oDrawingFile.ActiveSheet.DrawingViews.Item(1)
'This sets DwgView to refer to my desired view.

Dim Cent() as Double
oDwgView.Center.GetPointData Cent()
'Loads existing center coordinates into Array.

Cent(0) = 0 'Sets X-Coord to 0
Cent(1) = 0 'Sets Y-Coord to 0
msgbox Cent(0) & " " & Cent(1)
' Shows me that Cent array is (0,0)

DwgView.Center.PutPointData Cent()
oDrawingFile.Update
'This SHOULD move the view by resetting the center position

msgbox DwgView.Centre.X & " " & DwgView.Center.Y
'This shows that the center of the view HAS NOT CHANGED

What am I doing wrong?

Andrew
0 Likes
390 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Try this... Sub MoveAllViewsToCenterIDW() Dim oDrawDoc As DrawingDocument Set oDrawDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet Set oSheet = oDrawDoc.ActiveSheet Dim oTG As TransientGeometry Set oTG = ThisApplication.TransientGeometry Dim oPoint As Point2d Set oPoint = oTG.CreatePoint2d(oSheet.Width / 2, oSheet.height / 2) Dim oView As DrawingView For Each oView In oSheet.DrawingViews oView.Center = oPoint Next oView MsgBox "Done...now try to move them back ;-)", vbInformation End Sub
Message 3 of 3

Anonymous
Not applicable

Yea this helped,

 

Dim View As Inventor.DrawingView
For Each View In m_Sheet.DrawingViews
    View.Center = m_inventorApplication.TransientGeometry.CreatePoint2d(m_Sheet.Width / 2, m_Sheet.Height / 2)
    m_Sheet.Update()
Next

 

 

0 Likes