Hi
I have been banging my head against a brick wall on this one.
Has anyone managed to create Dockable Dialog that contains a control say a button that will then call
document.PromptForFamilyInstancePlacement(Symbol);
no matter what I try it always errors on this line of code. I have tried using idler handlers, raising events, Checking active view and even calling IExternalCommands, etc, etc, etc, but all of them error at the same place. I have it working with modeless winfoms ok but will no in a Dockable dialog
If anyone can point me in the correct direction or better still have code samples that work I would be in your dept forever
Dear Dsmith,
Sorry to hear about your poor head. Please take care.
The approach in a dockable panel should be pretty similar to the one from a modeless form.
I would recommend using an external event rather than the Idling event:
Have you accessed the current document successfully within the event handler?
Once you have done that, have you checked which is its active view?
Maybe you need to activate a graphical view?
Cheers,
Jeremy
Jeremy
Thanks for your reply, I have set the active view I think and it report the correct name, is there a difference with setting a graphical view if so how?? Please
I have thick skin anyway so no worries regarding my head, just the wall is suffering.
Regards
Dave
Dear Dave,
Oh dear, poor wall.
You could check the View.CanBePrinted property. That ought to be true for a normal graphical view.
You can check the UIDocument.ActiveGraphicalView property. If its value differs from the ActiveView, your active view is presumably not graphical and prompt for family instance placement will probably fail.
Cheers,
Jeremy
Jeremy
ActiveGraphicalView property would be nice but developing for 2014 not 2015.
Thanks anyway.
So almost have this working but have to click back into Revit graphics window for place family to work. how can I switch to correct window prior to placement from code??
Thanks in Advance
Dear dsmith,
you could activate your previous window by using plain Windows API:
http://www.pinvoke.net/default.aspx/user32.showwindow
Note that there is an MDI container in which all opened views reside (except project browser, property panel and all the user defined docks).
Thus, you would have to get the correct child window comparing its title etc.
Note: Bypassing Revit's own ActiveView setter may be considered as an unsupported hack.
Best regards,
Revitalizer
Thanks for the help but is a little over my head. Do you have any code samples from revit dockable pane.
Hi,
from Revit 2015 onwards, you can use PostRequestForElementTypePlacement instead of PromptForFamilyInstancePlacement.
Revitalizer