Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
i am actually writing VBA Code to VB.Net and have a problem with a Point2D object.
The macro shall align text, views and titles in an idw using the first selected object.
In VBA the macro works fine. In VB.NET i get a failure with the COM Object.
Any idea?
This is the example in VBA for the X Axis:
Sub AlignX() Dim oDoc As DrawingDocument Set oDoc = ThisApplication.ActiveDocument Dim oSelect As SelectSet Set oSelect = oDoc.SelectSet Dim newPoint As Point2d Set newPoint = oSelect.Item(1).Position For Each obj In oSelect newPoint.Y = obj.Position.Y obj.Position = newPoint Next End Sub
VB.Net Code:
Sub AlignX()
Dim oDoc As DrawingDocument = InventorApp.ActiveDocument
Dim oSelect As SelectSet = oDoc.SelectSet
Dim tg As TransientGeometry = InventorApp.TransientGeometry
Dim newPointX As Point2d = Nothing
Dim obj As Object
newPointX = tg.CreatePoint2d(oSelect.Item(1).Position.X, oSelect.Item(1).Position.Y)
For Each obj In oSelect
newPoint.Y = obj.Position.Y
obj.Position = newPointX
Next
End Sub
In the For Each loop at obj.Position = newPointX .Net creates the failure.
Best Regards Martin
Martin Winkler
CAD Developer
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.
Solved! Go to Solution.
