iProperty error "conversion from string "" to type "Double" is not valid

iProperty error "conversion from string "" to type "Double" is not valid

mcloughlin_b
Enthusiast Enthusiast
1,286 Views
6 Replies
Message 1 of 7

iProperty error "conversion from string "" to type "Double" is not valid

mcloughlin_b
Enthusiast
Enthusiast

HI Boffins

I am trying to copy the value (string) from an existing custom iProperty  across to a new custom property  but am stumbling over string to double conversion.

It appears that a few of the existing parts have the old property set to type "number" and i am needing to copy it into a new property of type text. I have tried using the CStr function but it seems to have no effect. Code is below

SyntaxEditor Code Snippet

If GetProperty(oCstPropSet, "SYBIZ PART No.").Value <> "" Then
			Dim VIZNO As String = CStr(GetProperty(oCstPropSet, "SYBIZ PART No.").Value)
			GetProperty(oCstPropSet, "SYBIZ PART NO").Value = VIZNO
			oCstPropSet.Item("SYBIZ PART No.").Delete
			Else If GetProperty(oCstPropSet, "SYBIZ PART No.").Value = "" Then
			oCstPropSet.Item("SYBIZ PART No.").Delete
			End If

 Any ideas / help appreciated as I'm sure this is really simple but .........

 

Thanks

Bryan

0 Likes
1,287 Views
6 Replies
Replies (6)
Message 2 of 7

bradeneuropeArthur
Mentor
Mentor

Hi,

you don't need the conversion I assume.

If GetProperty(oCstPropSet, "SYBIZ PART No.").Value <> "" Then
			Dim VIZNO As String = (GetProperty(oCstPropSet, "SYBIZ PART No.").Value)
			GetProperty(oCstPropSet, "SYBIZ PART NO").Value = VIZNO
			oCstPropSet.Item("SYBIZ PART No.").Delete
			Else If GetProperty(oCstPropSet, "SYBIZ PART No.").Value = "" Then
			oCstPropSet.Item("SYBIZ PART No.").Delete
			End If

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 7

mcloughlin_b
Enthusiast
Enthusiast

Nope I do. The code I posted is not working.

 

Cheers

0 Likes
Message 4 of 7

bradeneuropeArthur
Mentor
Mentor
can you post the complete code?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 7

bradeneuropeArthur
Mentor
Mentor

Are you programming VBA Vb.net or I-logic?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 6 of 7

mcloughlin_b
Enthusiast
Enthusiast

Hi Braden

Code is iLogic. Please see below

 

Thanks

 

SyntaxEditor Code Snippet

Sub Main
'debugger line, to see when rule runs
Trace.WriteLine("Tidy up iProperties: external rule", "iLogic") 
Dim oCurrentDoc As Inventor.Document
Dim oDoc As Inventor.Document 
Dim oPartDoc As PartDocument
Dim oRefDoc As DocumentsEnumerator

oCurrentDoc = ThisApplication.ActiveDocument
If oCurrentDoc.DocumentType = kAssemblyDocumentObject Then 
	For Each oDoc In oCurrentDoc.AllReferencedDocuments
	ErHa = "Start"
	Try
		If oDoc.DocumentType = kPartDocumentObject Then
			oPartDoc = oDoc
		'define custom property set
		Dim oCstPropSet As PropertySet
		oCstPropSet = oPartDoc.PropertySets.Item("Inventor User Defined Properties")

		ErHa = "Sybiz Part No."
		If GetProperty(oCstPropSet, "SYBIZ PART No.").Value <> "" Then
			Dim VIZNO As String = CStr(GetProperty(oCstPropSet, "SYBIZ PART No.").Value)
			GetProperty(oCstPropSet, "SYBIZ PART NO").Value = VIZNO
			oCstPropSet.Item("SYBIZ PART No.").Delete
			Else If GetProperty(oCstPropSet, "SYBIZ PART No.").Value = "" Then
			oCstPropSet.Item("SYBIZ PART No.").Delete
			End If
				
	    ErHa = "SUPPLY NO"
		If GetProperty(oCstPropSet, "SUPPLY NO").Value <> "" Then
			Dim sSUPPLYNO As String = GetProperty(oCstPropSet, "SUPPLY NO").Value
			GetProperty(oCstPropSet, "SUPPLYNO").Value = sSUPPLYNO
			oCstPropSet.Item("SUPPLY NO").Delete
			Else If GetProperty(oCstPropSet, "SUPPLY NO").Value = "" Then
			oCstPropSet.Item("SUPPLY NO").Delete
			End If
	    
		ErHa = "SUPPLY TYPE."
		If GetProperty(oCstPropSet, "SUPPLY TYPE").Value <> "" Then
			Dim sSUPPLYNO As String = GetProperty(oCstPropSet, "SUPPLY TYPE").Value
			GetProperty(oCstPropSet, "SUPPLYTYPE").Value = sSUPPLYNO
			oCstPropSet.Item("SUPPLY TYPE").Delete
			Else If GetProperty(oCstPropSet, "SUPPLY TYPE").Value = "" Then
			oCstPropSet.Item("SUPPLY TYPE").Delete
			End If
		
		ErHa = "Update the file"
		'iLogicVb.UpdateWhenDone = True
	End If
	Catch ex As Exception
		MsgBox("Part: " & oDoc.DisplayName & vbLf & "Code-Part: " & ErHa & vbLf & "Error: " & ex.Message)
	End Try	
	Next
		End If
	
End Sub

Private ErHa As String = vbNullString


Function GetProperty(oCstPropset As PropertySet, iProName As String) As Inventor.Property
    ErHa = "GetProperty: " & iProName
    Dim iPro As Inventor.Property
    Try
        'Attempt to get the iProperty from the document
        iPro = oCstPropset.Item(iProName)
    Catch
        'Assume error means not found, so create it
        iPro = oCstPropset.Add("", iProName)
    End Try
    Return iPro
End Function

 

0 Likes
Message 7 of 7

bradeneuropeArthur
Mentor
Mentor
Sub Main
'debugger line, to see when rule runs
Trace.WriteLine("Tidy up iProperties: external rule", "iLogic") 
Dim oCurrentDoc As Inventor.Document
Dim oDoc As Inventor.Document 
Dim oPartDoc As PartDocument
Dim oRefDoc As DocumentsEnumerator

oCurrentDoc = ThisApplication.ActiveDocument
If oCurrentDoc.DocumentType = kAssemblyDocumentObject Then 
	For Each oDoc In oCurrentDoc.AllReferencedDocuments
		
	ErHa = "Start"
	
	Try
		If oDoc.DocumentType = kPartDocumentObject Then
			oPartDoc = oDoc
		'define custom property set
		Dim oCstPropSet As PropertySet
		oCstPropSet = oPartDoc.PropertySets.Item("Inventor User Defined Properties")

		ErHa = "Sybiz Part No."
		If GetProperty(oCstPropSet, "SYBIZ PART NO").Value <> "" Then
			Dim VIZNO As String = CStr(GetProperty(oCstPropSet, "SYBIZ PART NO").Value)
			GetProperty(oCstPropSet, "SYBIZ PART NO").Value = VIZNO
			oCstPropSet.Item("SYBIZ PART NO").Delete
			Else If GetProperty(oCstPropSet, "SYBIZ PART NO").Value = "" Then
			oCstPropSet.Item("SYBIZ PART NO").Delete
			End If
				
				
	    ErHa = "SUPPLY NO"
		If GetProperty(oCstPropSet, "SUPPLY NO").Value <> "" Then
			Dim sSUPPLYNO As String = GetProperty(oCstPropSet, "SUPPLY NO").Value
			GetProperty(oCstPropSet, "SUPPLYNO").Value = sSUPPLYNO
			oCstPropSet.Item("SUPPLY NO").Delete
			Else If GetProperty(oCstPropSet, "SUPPLY NO").Value = "" Then
			oCstPropSet.Item("SUPPLY NO").Delete
			End If
	    
		ErHa = "SUPPLY TYPE."
		If GetProperty(oCstPropSet, "SUPPLY TYPE").Value <> "" Then
			Dim sSUPPLYNO As String = GetProperty(oCstPropSet, "SUPPLY TYPE").Value
			GetProperty(oCstPropSet, "SUPPLYTYPE").Value = sSUPPLYNO
			oCstPropSet.Item("SUPPLY TYPE").Delete
			Else If GetProperty(oCstPropSet, "SUPPLY TYPE").Value = "" Then
			oCstPropSet.Item("SUPPLY TYPE").Delete
			End If
		
		ErHa = "Update the file"
		'iLogicVb.UpdateWhenDone = True
	End If
	Catch ex As Exception
		MsgBox("Part: " & oDoc.DisplayName & vbLf & "Code-Part: " & ErHa & vbLf & "Error: " & ex.Message)
	End Try	
	Next
		End If
	
End Sub

Private ErHa As String = vbNullString


Function GetProperty(oCstPropset As PropertySet, iProName As String) As Inventor.Property
    ErHa = "GetProperty: " & iProName
    Dim iPro As Inventor.Property
    Try
        'Attempt to get the iProperty from the document
        iPro = oCstPropset.Item(iProName)
		
    Catch
		
        'Assume error means not found, so create it
        iPro = oCstPropset.Add(" ", iProName)
    End Try
    Return iPro
End Function

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes