Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I get this error: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) after one loop in the following code: It worked in releases prior to 2020. Appreciate any help. Thanks. Specific line that errors out is
If (ThisDrawing.Document.ActiveSheet.Balloons.Item(oIndex).Position.X = oBalloonXPos And ThisDrawing.Document.ActiveSheet.Balloons.Item(oIndex).Position.Y = oBalloonYPos) Then NewIndex = oIndex End If
Dim oIndex As Integer Dim NewIndex As Integer Dim oBalloonXPos As Double Dim oBalloonYPos As Double Dim oArrowHeadXPos As Double Dim oArrowHeadYPos As Double Dim bubs As ObjectCollection Dim bub As Object Dim bubcount As Integer Dim bubscount As Integer 'create collection of balloons bubs = ThisApplication.TransientObjects.CreateObjectCollection While True bub = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingBalloonFilter, "Select a balloon; press esc when done") ' If nothing gets selected then we're done If IsNothing(bub) Then Exit While bubs.Add(bub) End While bubcount = ThisApplication.ActiveDocument.ActiveSheet.Balloons.count MessageBox.Show(bubcount, "Total Balloon Qty") bubscount = bubs.Count MessageBox.Show(bubscount, "Balloon Qty Picked") ' If there are selected components we can do something ' bub is a member of bubs collection For Each bub In bubs 'get and display balloon and leader points get ArrowHeadType oArrowHeadType = bub.Leader.ArrowHeadType 'MessageBox.Show(oArrowHeadType, "Arrow Head Type") bub.Leader.ArrowHeadType=71948 oArrowHeadXPos = bub.Leader.AllNodes.Item(2).Position.X 'MessageBox.Show(oArrowHeadXPos, "ArrowHead X") oArrowHeadYPos = bub.Leader.AllNodes.Item(2).Position.Y 'MessageBox.Show(oArrowHeadYPos, "ArrowHead Y") oBalloonXPos = bub.Position.X 'MessageBox.Show(oBalloonXPos, "Balloon X") oBalloonYPos = bub.Position.y 'MessageBox.Show(oBalloonYPos, "Balloon y") oBalloonDia = bub.Style.BalloonDiameter 'MessageBox.Show(oBalloonDia, "Balloon Diameter") 'create new point for leader oBasePosition = ThisApplication.TransientGeometry.CreatePoint2d() oBasePosition.X = oBalloonXPos + (oBalloonDia/4) 'MessageBox.Show(oBasePosition.X, "New X") oBasePosition.Y = oBalloonYPos + (oBalloonDia/4) 'MessageBox.Show(oBasePosition.Y, "New y") 'move arrowhead end of leader to new point For oIndex = 1 To bubcount If (ThisDrawing.Document.ActiveSheet.Balloons.Item(oIndex).Position.X = oBalloonXPos And ThisDrawing.Document.ActiveSheet.Balloons.Item(oIndex).Position.Y = oBalloonYPos) Then NewIndex = oIndex End If Next ThisDrawing.Document.ActiveSheet.Balloons.Item(NewIndex).Leader.AllNodes.Item(2).Position = oBasePosition Next InventorVb.DocumentUpdate()
Thanks in advance
Solved! Go to Solution.