Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dockable Dialog and PromptForFamilyInstancePlacement

8 REPLIES 8
Reply
Message 1 of 9
dsmith
1066 Views, 8 Replies

Dockable Dialog and PromptForFamilyInstancePlacement

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

 

8 REPLIES 8
Message 2 of 9
jeremytammik
in reply to: dsmith

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:

 

http://thebuildingcoder.typepad.com/blog/2013/12/replacing-an-idling-event-handler-by-an-external-ev...

 

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 Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 9
dsmith
in reply to: jeremytammik

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

Message 4 of 9
jeremytammik
in reply to: dsmith

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 Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 9
dsmith
in reply to: jeremytammik

Jeremy

 

ActiveGraphicalView property would be nice but developing for 2014 not 2015.

 

Thanks anyway.

 

 

Message 6 of 9
dsmith
in reply to: dsmith

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

Message 7 of 9
Revitalizer
in reply to: dsmith

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




Rudolf Honke
Software Developer
Mensch und Maschine





Message 8 of 9
dsmith
in reply to: Revitalizer

Thanks for the help but is a little over my head. Do you have any code samples from revit dockable pane.

 

 

Message 9 of 9
Revitalizer
in reply to: dsmith

Hi,

 

from Revit 2015 onwards, you can use PostRequestForElementTypePlacement instead of PromptForFamilyInstancePlacement.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community