Modify properties by Excel

Modify properties by Excel

TONELLAL
Collaborator Collaborator
423 Views
2 Replies
Message 1 of 3

Modify properties by Excel

TONELLAL
Collaborator
Collaborator

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

 

0 Likes
424 Views
2 Replies
Replies (2)
Message 2 of 3

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @TONELLAL,

 

canbind = oRefKeyManager.CanBindKeyToObject(bRefKey) is not working for some parts?

 

Can you please provide sample file which are not working? Please make sure that files are non confidential.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 3

TONELLAL
Collaborator
Collaborator

Hi,

I sent a simplified version of the ivb I used on the Enterprise Support site, with comments to use it, can you see it ?

You can test it on the Inventor 2016 sample file : Suspension.iam.

 

Thanks !

0 Likes