Component occurrence cannot be renamed

<?xml encoding=”UTF-8″>By Adam Nagy

In case of some assemblies, e.g. the ones created by Design Accelerator, the name of the document or the occurrances in it cannot be changed: you get message “Request Rename Component cannot be run on document Synchronous Belts

Changename

Design Accelerator does set the Document.DisabledCommandTypes to kNonShapeEditCmdType + kShapeEditCmdType, which is 32 + 1 = 33, and that seems to be the thing that disables those types of changes.

If you test the effect of the various CommandTypesEnum values concerning the above changes then this is what you get:

Public Sub SetDisabledCommandTypes()
' Type / Can you rename occurrences? / Can you rename document?
<strong>' kEditMaskCmdType = 57 (&H39) / No / No</strong>
' - <strong>kNonShapeEditCmdType (32)</strong>
' - kUpdateWithReferencesCmdType (16)
' - kFilePropertyEditCmdType (8)
' - kShapeEditCmdType (1)
' kFileOperationsCmdType = 4 / Yes / Yes
' kFilePropertyEditCmdType = 8 / Yes / Yes
<strong>' kNonShapeEditCmdType = 32 (&H20) / No / No</strong>
' kQueryOnlyCmdType = 2 / Yes / Yes
' kReferencesChangeCmdType = 64 (&H40) / Yes / Yes
' kSchemaChangeCmdType = 128 (&H80) / Yes / Yes
' kShapeEditCmdType = 1 / Yes / Yes
' kUpdateWithReferencesCmdType = 16 (&H10) / Yes / Yes
' You can test the effect of the various enum values here
ThisApplication.ActiveDocument.DisabledCommandTypes = _
kNonShapeEditCmdType
End Sub

If you remove the kNonShapeEditCmdType flag from the DisabledCommandTypes property of an assembly document (e.g. by setting it to 0) then you could rename the document and its occurrences. I do not suggest that you do that though; it’s just to test that that is the only setting that prevents you from doing those changes in a Design Accelerator assembly.


Comments

2 responses to “Component occurrence cannot be renamed”

  1. Awesome!!! I was just battling with this issue today, trying to help a customer. I couldn’t figure out what was locking the file. Thought I might try some VBA hackery as a quick and dirty fix, but he hadn’t fixed the VBA install on his machine, so I couldn’t use it in a hurry.
    Probably won’t use this to fix it in a live system, but at least I know wat causes it now.
    The best part is, earlier today, I searched for this topic and only found 2 unsolved forum posts. Tonight I was reading one of Xiaodong’s new posts, and just happened to notice this post of yours in the “You might also like..” section. SWEET!
    Cheers

  2. Hehe, sometimes I cannot even find my ‘own’ blog posts! :-/
    Glad it was useful :)

Leave a Reply to Gavin BathCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading