PromptForFamilyInstancePlacement Keyboard Shortcut problem

PromptForFamilyInstancePlacement Keyboard Shortcut problem

Anonymous
Not applicable
481 Views
1 Reply
Message 1 of 2

PromptForFamilyInstancePlacement Keyboard Shortcut problem

Anonymous
Not applicable

 

I stumbled across a problem with using a Keyboard Shortcut.

 

Using the code basically from this orignal post:  http://thebuildingcoder.typepad.com/blog/2010/06/place-family-instance.html

In my case, I've changed one line to collector.OfCategory(BuiltInCategory.OST_LightingFixtures),  since I don't have any OST_Door family instances.

 

The code works fine if you are executing it from a menu button (Add-Ins), but if you assign a keyboard shortcut key to the new command, you get an error if you press the space bar to change the orientation of the family you are placing.  Pressing the spacebar when code is executed from a menu button works as expected.

 

The problem doesn't occur with BuiltInCategory.OST_GenericAnnotation, so it seems to be related to being a 3D model object.  I stumbled across the issue in my own code, and confirmed the issue isn't related to my code base by trying it out on the original 2010 place-family-instance code.

 

The placement doesn't totally die, it just pops up this error message.  If you press the space bar a 2nd time, it works as expected, and the error message goes away.  Just a pain to have the error message poping up all the time.

 

ErrorMessage.PNG

 

 

0 Likes
482 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

You can stop the error from popping up at least with a try/catch.

 

 

// Hack to suppress error when using Shortcut key to call command           
try { rvtUiDoc.PromptForFamilyInstancePlacement(familySymbol)
} catch (Autodesk.Revit.Exceptions.InvalidOperationException) { }

 

 

0 Likes