Selecting plan with FilteredElementCollector Revit Api - revit-api

enter image description here
I am developing an application with Revit api. I'm trying to open my 3D model using FilteredElementCollector. I couldn't catch it first, I want to ask how can I do it?
I also get this error when I select another 3D model of mine.
Error : Autodesk.Revit.Exceptions.InvalidOperationException: 'Setting active view is temporarily disabled.
Can you help with these issues?

By 3D model, do you mean a 3D view?
https://www.revitapidocs.com/2015/b6adb74b-39af-9213-c37b-f54db76b75a3.htm
You'll see here that changing the active view is only possible when there is no:
There is no open transaction.
IsModifiable is false.
IsReadOnly is false
ViewActivating, ViewActivated, and any pre-action of events (such as DocumentSaving or DocumentClosingevents) are not being handled.
Worth making sure you don't have an open transaction. If you do, and you need one you can use the RequestViewChange method:
https://www.revitapidocs.com/2015/a2e920d4-2849-282e-c25f-40a4d2cbef2d.htm

Related

Revit API - How to check for open Transactions, Sub-transactions, or Group Transactions

I'm working on a button where I have a project document open and a family document open. I'm trying to close the family document however I'm getting an error saying:
Autodesk.Revit.Exceptions.InvalidOperationException: 'Close is not allowed when there is any open sub-transaction, transaction, or transaction group.'
I've checked all of my transactions and they are all started and committed using transactionName.Start(document) and transactionName.Commit()
does anyone know of a way to check for any ongoing active transactions?
I have also tried using
'RevitCommandId closeDoc = RevitCommandId.LookupPostableCommandId(PostableCommand.Close);
uiapp.PostCommand(closeDoc);'
however that tends to only want to close my project document.
///////////////////////////////////UPDATE/////////////////////////////
soooo I just found out I didn't need to use uiapp.OpenAndActivateDocument(). I didn't know you could edit a family without opening the document. That solves my problem. I'm still curious if there's a way to check for open transactions though.
Yes there is a way to check for open Transactions and its quite helpful in making flexible helper-functions. The Document object has an IsModifiable property - essentially if a Transaction is open, then this will be True.
I use it like this:
autoTransaction = False
if not document.IsModifiable:
t = Transaction(document, 'New Transaction cause no transaction was open')
t.Start()
autoTransaction = True
# go ahead and modify the database
if autoTransaction:
t.Commit()
Its served me well so far, hope this helps!
Afaik, the Revit API does not enable you to check from outside whether a transaction is started. You need access to the Transaction object itself to check its status. If you did not create it yourself, you have no access to it.
How did you open the two documents?
What Revit commands did you execute in them?

RPA Blueprism input collection in process studio action stage

Trying to parameterize a hotel booking page where we need to enter check in, check out details etc. I created a page in object studio with various action/navigation stages for that web page. Now I need to call that object in process and loop it with input collection. When I am calling that object studio page in process studio action stage, I can select my object and action from dropdown, but under inputs tab not getting any row to drag and drop the input collection that I have created, how to do this ?
Seems you should go take Blue Prism tutorial on their homepage, as this very basic, it's how to call another process/Business object.
Short description:
Create a process which is your main.
Create your functionality in a Business object.
From your process you will pull in an 'Action' block and find your
business object in the drop down.
When it comes to input/output. Click on Start/End
to create the Input/Output you need.
Hope this was helpful.
I'm not sure if I understand your problem correctly, but shouldn't you input your data in START step in proces studio?
So, in START step in proces studio you input data and then(whit that input) you go into actions from your object.
Hope it helps.
make sure you place your data items/collections which ever is output in run time object in END stage, and make sure you uncheck hide from process box.
In process you will be able to find necessary output from object and will involve in your rest action
hope this helps :)
You need to provide input parameters in the Start properties of your Object. Inputs to a page in Object Studio provide the means for a Process to supply data to the Business Object.
Essentially, the Business Object is saying to the Process, “What check in, check out details etc do you want me to work with?”.
Hope this helps.
I had the same issue, it is resolved!
When you create an Object and go to Application Modeller, make sure you choose "Browser Based Application" instead of Windows Based Application. I had selected Windows based applocation and it was not showing up in the Process Studio. I hope this

How can I activate (display) a view using Revit API?

I am trying to activate a view using Revit API. What I want to do exactly is to prompt the user to select some walls, but when the user is asked that, he can't switch views to select more walls (everything is greyed out at that point).
So the view I want to activate (by that I mean, I want this view to be actually shown on screen) already exist, and I can access its Id.
I have seen threads about creating, browsing, filtering views, but nothing on activating it... It's a Floor Plan view.
So far I can access its associated ViewPlan object, and associated parameters (name, Id, ..).
Is it possible to do ?
Thanks a lot !
Arnaud.
I think the most preferred way is the UIDocument.RequestViewChange() method. The tricky part about this is that unless you've designed your application to be modeless with external events or idling, it may not actually happen until later when control returns back to Revit from your addin.
(There's also setting the UIDocument.ActiveView property - not positive if this has different constraints).
The other way that I have done it historically is through the use of the UIDocument.ShowElements() command. The trick here is that you don't have control of the exact view - but if you can figure out the elements that appear only in that view, you can generally make it happen (even if you have to do a separate query to get a bunch of elements that are only in the given floorplan view).
Good Luck!
I think the solution to your problem may be:
commandData.Application.ActiveUIDocument.ActiveView = View;
The ActiveView is a property and it has {get and set} options.
ActiveView has only a get accessor, what Mostafa suggests will not work.
I have used the RequestViewChange() method with a modal dialog and have not had problems so far.

Is there a best practice for enable (CanExecute) a button in an other userControl?

Is there a best practice for how to enable (CanExecute) a button in an other userControl?
A simple scenario is as follow.
When selecting one row in a datagrid in UserControl_1 a button should be enabled in UserControl_2 and also provide the selected row to UserControl_2's viewModel.
When the user then push the button in UserControl_2 it will be executed with the data from the selected row from UserControl_1.
Thanks from a Catel newbie.
If you are using WPF (assuming you are), the CanExecute will be triggered by the WPF system (CommandManager to be precise). Catel should automatically requery the commands when a property changes.
If the logic (or at least the data) for the CanExecute should be shared among several user controls (and I am talking about the view models for the several user controls), I recommend to create a service which is registered in the ServiceLocator. In the CanExecute of the commands you can query the same data (the service) and return true or false according to the logic you want to implement.
You may take a look at this post. And you 'll have a good idea about your problem. I don't post the code here since it is an answer of someone else. Please refer the link.
http://social.msdn.microsoft.com/Forums/vstudio/en-US/198c4a4b-b4c2-4dfc-b99b-afb2a11eb4c3/call-button-even-from-user-control-to-another-user-control

Orchard CMS: Invoking two actions leads to duplicate notifications

Our Orchard application displays two of all notifications that are added to the notification service. So far we have traced the problem and know what is causing it, but are looking for a solution other than the obvious, for reasons I shall now elaborate.
So we are using a number of themes to render our Orchard based application. Within our layout, we have a Razor call to draw a header bar that displays a set of information about the user that is logged in.
#Html.Action("OutOfGameHeader", "Options", new { area = "Area.area.Location.Common" })
This action calls the OnResultExecuting() method in Orchard.UI.Notify.NotifyFilter which (among other things) populates the Messages Zone with the current set of notifications. When we make the call the render the Messages Zone, this same method runs again and the notifications are added to the Zone's shape again resulting in duplicate notification being displayed when the Zone is actually drawn.
Can anyone think of a solution that meets the following criteria:
Drawing the header without calling #Html.Action() to avoid OnResultExecuting() being triggered the first time.
Without creating a new Widget in a new Zone as this would involve us changing the manifest for dozens of existing themes to include it.
We also found this just below the point in the code where the notifications are added to the Zone, so if anyone knows anything more about it, that would be helpful too.
//todo: (heskew) probably need to keep duplicate messages from being pushed into the zone like the previous behavior
//baseViewModel.Messages = baseViewModel.Messages == null ? messageEntries .Messages.Union(messageEntries).ToList();
//baseViewModel.Zones.AddRenderPartial("content:before", "Messages", baseViewModel.Messages);
Any thoughts greatly appreciated.
Avoid Html.Action. This runs through the whole lifecycle as if this was a new request. That you think you need it is often a sign that you need to refactor and extract that logic that you want to re-use out of your controller. In Orchard, it's also better to use dynamic shapes.

Resources