Modify properties by Excel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I try to create a macro to modify properties by Excel :
- from Inventor assembly, read parts properties
- send properties to Excel
- modify the by Excel
- send them back to the parts
I use the RefKeyManager to store the part in Excel and find it back in Inventor. The problem is for some parts, the key read in Excel cannot bind to an object. In bold the problem in the code, If you can find where is the problem ?
Thanks in advance !
The code I use :
Sub Props2XL ()
'Send properties to Excel
'Get the parts in the assembly
Set oDoc = ThisApplication.ActiveDocument
Set oOccs = oDoc.ComponentDefinition.Occurrences.AllLeafOccurrences
Set oRefKeyManager = oDoc.ReferenceKeyManager
For Each oOcc In oOccs
If oOcc.Suppressed = False Then
'Get refkey
oOcc.GetReferenceKey bRefKey
sKey = oRefKeyManager.KeyToString(bRefKey)
'Write refkey and properties to Excel...
next oOcc
End Sub
Sub GetPorpsFromXL()
'Read XL
For ligne = lignedepart + 3 To derli
'Read the key in Excel
sKey = WS.Cells(ligne, coldepart)
Call oRefKeyManager.StringToKey(sKey, bRefKey)
'Bind the key to the object
canbind = oRefKeyManager.CanBindKeyToObject(bRefKey)
If canbind Then
'Read Excel values and write in the right Inventor property
End If
Next ligne
end sub