Error message The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E

Error message The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E

Anonymous
Not applicable
20,404 Views
5 Replies
Message 1 of 6

Error message The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E

Anonymous
Not applicable

I hava a client that requires our drawings to be supplied in autocad dwg format with the fields having specific names. I have been sucessfull in doing this for 99% by creating a title block with the prompted entries named to match the clients names.

We use an ilogic form to populate all of our title blocks. When I run the code to read the form entries and update the prompted I get an error message:

"The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"

I have identfied the line of code that causes the issue and highlighted it in the attached code.

 

Any help would be gratefully appreciated.

 

Dim oDrawDoc As DrawingDocument

Dim oSheet As Sheet

Dim tb As Inventor.TextBox

'Dim oBorder As Border

Dim borderDef As BorderDefinition

Dim oTB1'oTB1 references to Titleblocks

Dim sValue As String

Dim oDrwNo As String

Dim oShtRevNo As String

Dim oPromptEnt As String

 

oDrawDoc = ThisApplication.ActiveDocument

oSheet = oDrawDoc.ActiveSheet

'oBorder = oSheet.Border

'borderDef = oBorder.Definition

oTB1 = oSheet.TitleBlock

 

For Each tb In oDrawDoc.ActiveSheet.TitleBlock.Definition.Sketch.TextBoxes

If tb.Text = "TYPE" Then

                        sValue = oTB1.GetResultText(tb)

                        oDrwNo = TYPE

                        'MessageBox.Show("Property Field: " & tb.Text & vbCrLf & "Value: " & sValue & vbCrLf & "Prompted Entry: " & tb.FormattedText, "Prompted entry")       

                        'MessageBox.Show("Param drw no  " & oDrwNo, "Title")

            Call oDrawDoc.ActiveSheet.TitleBlock.SetPromptResultText(tb, oDrwNo)

                        oPromptEnt = oTB1.GetResultText(tb)

                        'MessageBox.Show("Prompted value " & oPromptEnt, "Title")

       

 

    End If

Next

 

For Each tb In oDrawDoc.ActiveSheet.TitleBlock.Definition.Sketch.TextBoxes

If tb.Text = "BMA_DRAWING_NUMBER" Then

                        sValue = oTB1.GetResultText(tb)

                        oDrwNo = BMA_DRAWING_NUMBER

                        'MessageBox.Show("Property Field: " & tb.Text & vbCrLf & "Value: " & sValue & vbCrLf & "Prompted Entry: " & tb.FormattedText, "Prompted entry")       

                        'MessageBox.Show("Param drw no  " & oDrwNo, "Title")

            Call oDrawDoc.ActiveSheet.TitleBlock.SetPromptResultText(tb, oDrwNo)

                        oPromptEnt = oTB1.GetResultText(tb)

                        'MessageBox.Show("Prompted value " & oPromptEnt, "Title")

       

 

    End If

Next

 

For Each tb In oDrawDoc.ActiveSheet.TitleBlock.Definition.Sketch.TextBoxes

If tb.Text = "REV" Then

                        sValue = oTB1.GetResultText(tb)

                        oShtRevNo = REV

                        'MessageBox.Show("Property Field: " & tb.Text & vbCrLf & "Value: " & sValue & vbCrLf & "Prompted Entry: " & tb.FormattedText, "Prompted entry")       

                        MessageBox.Show("Param drw no  " & oShtRevNo, "Title")

           

Spoiler
Spoiler
Call oDrawDoc.ActiveSheet.TitleBlock.SetPromptResultText(tb, oShtRevNo)

                    oPromptEnt = oTB1.GetResultText(tb)

                        'MessageBox.Show("Prompted value " & oPromptEnt, "Title")

 

 

    End If

Next

 

0 Likes
Accepted solutions (1)
20,405 Views
5 Replies
Replies (5)
Message 2 of 6

Owner2229
Advisor
Advisor

Hi, here is your updated code. It's also a bit shortened.

 

 

Dim oDrawDoc As DrawingDocument
Dim oSheet As Sheet
Dim tb As Inventor.TextBox
Dim oTB1 'oTB1 references to Titleblocks
Dim sValue As String
Dim oPromptEnt As String

oDrawDoc = ThisApplication.ActiveDocument
oSheet = oDrawDoc.ActiveSheet
oTB1 = oSheet.TitleBlock
For Each tb In oDrawDoc.ActiveSheet.TitleBlock.Definition.Sketch.TextBoxes If tb.Text = "TYPE" Or tb.Text = "BMA_DRAWING_NUMBER" Or tb.Text = "REV" Then sValue = oTB1.GetResultText(tb)
Call oDrawDoc.ActiveSheet.TitleBlock.SetPromptResultText(tb, tb.Text) oPromptEnt = oTB1.GetResultText(tb) End If Next

 

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi Mike, 

Thanks for the code and I appreciate the shortened version.

When running the code I get the same error message;

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) 

This seems to occure at the line:

 

Call oDrawDoc.ActiveSheet.TitleBlock.SetPromptResultText(tb, tb.Text)

 

 

In my origional code I could get around this message by commenting out the line of code that refered to "REV" all the other lines worked.

Note there are about 20 other prompted entries that my code that work correctly in my origional code, I excluded them for clarity.

0 Likes
Message 4 of 6

MechMachineMan
Advisor
Advisor
Accepted solution

It sounds like that's happening because you have a normal textbox and a prompted entry textbox with same info for the .Text property, which you inadvertently try to fetch/send information to.

 

For Each tb As Textbox In ThisApplication.ActiveDocument.ActiveSheet.TitleBlock.Definition.Sketch.Textboxes
    MsgBox(tb.text & vbLf & vbLf & "FORMATTEDTEXT: " & tb.FormattedText)
Next

 

The Textboxes.GetResultText will fail if used on a plain text textbox, thus, you can also check to make sure the formatted string contains the prompt tag, or just handling it within an error loop. 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 5 of 6

Anonymous
Not applicable
Of course that makes sense. Thank you for your assistance
0 Likes
Message 6 of 6

Anonymous
Not applicable

I am having the same issue.

Can someone help with my coding?

I'm a beginner when it comes to this stuff.

The rule runs, and executes fine, but upon completion, the same error pops up.

It doesn't change the effectiveness, but its annoying.

 

iLogicVb.UpdateWhenDone = True 

'Styles Editor, Parts List, to edit desired BOM

Dim sStyle As String
'set the parts list style names to use
If bStyle = True Then
	sStyle = "DetailPartsList(ANSI)"
Else
End If

' Set a reference to the drawing document.    
' This assumes a drawing document is active.    
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

'Set a reference to the active sheet.    
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet	

' Set a reference to the first drawing view on    
' the sheet. This assumes the first drawing    
' view on the sheet is not a draft view.    
Dim oDrawingView As DrawingView

Try
	oDrawingView = oSheet.DrawingViews(1)
Catch
	MessageBox.Show("No view found, can not continue. Please place base view.", "iLogic")
	Return
End Try

' Set a reference to th sheet's border    
Dim oBorder As Border
oBorder = oSheet.Border

Dim oPlacePoint As Point2d

If Not oBorder Is Nothing Then
    ' A border exists. The placement point        
	' is the top-right corner of the border. 
	oOffsetX = -1.778 'user defined offset
	oOffsetY = -0.34925 'user defined offset
	oX = oBorder.RangeBox.MaxPoint.X + oOffsetX
	oY = oBorder.RangeBox.MaxPoint.Y + oOffsetY
	oPlacePoint = ThisApplication.TransientGeometry.CreatePoint2d(oX,oY)
Else
    ' There is no border 
	 
	oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(20, 20)
     
     iLogicVb.UpdateWhenDone = True
End If

' Get the style.
Dim oStyle As Style
For Each aStyle As Style In oDrawDoc.StylesManager.PartsListStyles
    If aStyle.Name = sStyle Then
        oStyle = aStyle
        Exit For
    End If
Next

Dim oPartslist As PartsList

Try		
	'look for the first parts list found on the sheet 
	'if succesful finding it, 
	'tell the user,then Do Nothing
	oPartslist = oSheet.PartsLists(1)
	MessageBox.Show("There is an existing Parts List", "iLogic")
Catch
	' Create the parts list.  
	oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacePoint)
End Try

'set the style
oPartsList.Style = oStyle

 


 

0 Likes