Displaying Workset dialog on Open

Displaying Workset dialog on Open

62BJW
Advocate Advocate
1,281 Views
7 Replies
Message 1 of 8

Displaying Workset dialog on Open

62BJW
Advocate
Advocate

I've researched this but am unable to find a solution. My users often place objects on the wrong workset. I'd like to do one of two things when a user opens a file containing worksets.

 

Either / Or:

1. Display Revit's worksets dialog box.

2. Create my own form that lists all worksets in the current document and allow them to set the current one.

 

If I go with option 2 how do I get my dialog box to load if a file is opened that contains worksets? Option 1. would be preferred because I assume it requires less coding. Am I wrong?

 

Thanks!

0 Likes
1,282 Views
7 Replies
Replies (7)
Message 2 of 8

BenoitE&A
Collaborator
Collaborator

Hey Bernie,

I don't know much about worksets but from what I understand of the solutions you are looking for:

 

- both solutions require to be triggered by the event : the UI loads a document. 

- solution 1 requires you to find the command corresponding to your with (Revit's dialog box about Worksets, which I don't think can be accessed by the API but perhaps by a PostCommand)

- solution 2 just requires to make a FilteredElementCollector on your document once opened and put the informations found in a form, which is what ? 2 hours work max.

In the end the solution 2 seems far easier to me!!

But both solutions require to master the events in Revit, which is not the easiest part...

Have fun !

Benoit

 


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
Message 3 of 8

JimJia
Alumni
Alumni

Thanks for Benoit's reply!

Yes, Revit provides accordingly event API to trigger for document opened, e.g. DocumentOpened
Per my verify, Revit workset dialog can be opened via postcommand below:

			UIApplication uiApp = new UIApplication(this.Application);
			RevitCommandId cmdId = RevitCommandId.LookupPostableCommandId(PostableCommand.Worksets);
			if(uiApp.CanPostCommand(cmdId))
				uiApp.PostCommand(cmdId);

Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
0 Likes
Message 4 of 8

jeremytammik
Autodesk
Autodesk

Dear Bernie,

 

The automatically generated DAS ticket #14926114 [Displaying Workset dialog on Open] has been reopened, saying, Customer never received any workable solution... Will assign to queue.

 

Are you still in need of help in this issue? If so, then please say so and let us continue discussing it here in the public thread.

 

Thank you!

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 8

amir.aroesti
Advocate
Advocate

@JimJia it looks very simple!

is it external command? external app?

could you please share with us the "vsproject" file?

 

I have exactly the same issue as @62BJW .

0 Likes
Message 6 of 8

jeremy_tammik
Alumni
Alumni

PostCommand is a Revit API call that you can execute within an external command.

 

Here are some examples:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.3

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 7 of 8

amir.aroesti
Advocate
Advocate

thanks @jeremy_tammik 

 

I overview your appendix. 

it a little bit complicated for me and I try to find a simple source of implementing postcommand inside code.

I have a record of a few exteranrcommand apps I created and do now the statute of postcommand application.

 

hope I clear. sorry about being junior 😉

 

Amir

0 Likes
Message 8 of 8

jeremy_tammik
Alumni
Alumni

You can simply take any external command that you already have working, copy it and replace the contents of the Execute method with Jim Jia's code snippet above.

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes