Select a Schedule (or other elements) by name instead of index number in Dynamo/Revit - revit-api

I have a dynamo script that exports schedules out of Revit. It uses a bit of Python also, (not relevant to this question, but I thought I would just include it all).
It all works great, but I notice if certain schedules get deleted from Revit, it could change the "Index" number of the schedules I need to export. I would like to use the schedule name instead of the dynamo index number, as this will help me maintain the connection without checking if it's exporting the correct schedule. Is this possible?

From the pure Revit API point of view I can only answer that yes, this is possible. You are calling the ViewSchedule.Export method. The ViewSchedule element can indeed be retrieved from the Revit database by name using a filtered element collection.

Here is the final solution that works well. Using the "==" node and "List.FilterByBoolMask" node I was able to filter down to just what's in the String. Now I can set the string node to be an input for the dynamo player and user just needs to input the exact name of their schedule. Thank you Michael Kilkelly from ArchSmarter for this helpful video.
How to Dynamo: Filter List by Element Name

Related

how do i correctly set up a parameterized information link in spotfire?

Also posted on super users:
I'm a spotfire novice trying to create a parameterized info link. Ultimate goal is to create a default template that may be customized to return specific rows in a very large table. I've not been able to cobble together enough information from online searches to get me from point A to Z.
Spotfire version is 7.11 on an Oracle 11.2 SE DB.
Currently I've got a date/time prompt in the info link that will be global to all users. What I need is to be able to further filter to 1 of 2 columns (one is real, the other a string) in order to minimize loading times. There are 17 other on-demand tables that are related to the main one. Limiting the initial query will greatly speed up performance.
In information designer for the information link, if I edit the SQL in the WHERE and explicitly define the value or string for the column, I get the rows I want. When I try to define it using an input parameter (?ParamName), I either get nothing when I reload or get asked to input a parameter "for testing".
Q1: In the document properties for the analysis, I've been adding in properties that I assume is supposed to get picked up by the query.
- What part do scripts play in passing this variable to the SQL?
- Do I just need to define a value for a property name or include a IronPython script? - If script is required, can I just define the parameter to pass?
Q2: In the info link SQL, what is the correct syntax for defining the parameter variable depending on the type (real v string)? If I use a string, I need to include LIKE in order to pick up the desired rows. If I use a real, is it possible to define it as a list of values?
Thanks in advance.
Though not exactly clear from your description, I think you should be able to accomplish your goals using the "Load on demand" dialog that is accessed either when you add your data table to your analysis, or subsequently using the Data Table Properties>Type of Data>Settings dialog.
Spotfire uses this dialog to dynamically modify your SQL. Thus, you do not need to explicitly include the LIKE statement in your SQL. Spotfire will add it in based on what you define in the On-Demand settings. For example, you could have an Input Field where you type a constraint that will be stored as a Document Property and then refer to that Document Property in your On-Demand settings to control the table loading.

How to make filters in queries optional

How to make a query filter bound to a request parameter inactive if the parameter is not present?
For example: I have a query MyQuery that can be accessed through the projection MyProjection. I add a filter to that query where I say that MyDate field should be equal to {Request.QueryString:MyDate}. I want URLs like ~/MyProjection?MyDate=2016-03-08 to filter content items by the given value, but the url ~/MyProjection to just not filter by that field. But this is not what happens: a condition gets added to the query anyway and it's of the form '[minimum DateTime value] < MyDate < [maximum DateTime value]'. This is not good because it will filter out fields with NULL values. If I try to do the same with a numeric field, it's even worse because it throws exceptions when the parameter is not present.
I know I can create a new query and projection to get different options, but that seems like an overkill - also, what if I wanted to create an advanced search form, it would have to target a single projection.
Is there an "official" way to do this? Or a workaround? Or is this simply not supported in Orchard?
I'm not aware of a way to do this out of the box. However, you could pretty easily create your own filter with the behavior you want by implementing IFilterProvider.
Take a look at the Orchard.Projections module. That's where you'll find many of the default query filters (including the date field filter you referenced). Your's will likely be even simpler if you only need to handle a specific case.
For a very simple example, checkout the Orchard.Tags module (look in the projections folder). The contents of this folder will give you pretty much all the boilerplate you'll need to get started creating your own. Just plug in your own logic.

ObjectID with conventions

I need to generate ids with a convention, for example:
Instead of getting: "538cd180e381f20d1c1cd2a2"
I would like to have an ID like this one: "p38cd180e381f20d1c1cd2a2"
So what I want is that my IDs start with a consonant letter.
Does anyone know how to accomplish that within the driver, I mean, getting that behaviour on "new mongo.ObjectId()"?
Thanks in advance.
You can use the following, to get the id starting with a consonant
db.collection.insert({"_id":"p"+new ObjectId()})
you can use any other string in place of "p" and the string will append to the start of the id generated by mongodb.
Short answer: Sorry, no standard way available to achieve this as of now.
Detailed answer and workaround: MongoDB or driver generated ids are a combination of Creation Time (as timestamp), Increment value for next id, Machine on which the id is generated and the process id of the process which generated this document id. All this info is available in the generated id and can be extracted back. For now, this is what you have been given and there is no support for generating your own custom id from the driver's algorithm.
If you want to customize your id generation and be able to make use of these properties, then you can embed all this info that MongoDB uses for id generation and add this information to your document itself. By doing that you will be able to reproduce the information that MongoDB generates from the id. And while inserting the document to MongoDB, you can give your docs a customized id which agrees with your requirements.
So if you later on want to make comparisons based on creation time or maybe the machine, you can do that from the information that was added to the docs themselves.
Use the code: db.collection.insert({"customId":"p"+new ObjectId()}). And let your code use this customId.

How to get last created document in couchdb?

How can I get last created document in couchdb? Maybe some how I can use _changes feature of couchdb? But documentation says, that I only can get list of document, ordered by first created document, ant there is no way to change order.
So how can I get last created document?
You can get the changes feed in descending order as it's also a view.
GET /dbname/_changes?descending=true
You can use limit= as well, so;
GET /dbname/_changes?descending=true&limit=1
will give the latest update.
Your only surefire way to get the last created document is to include a timestamp (created_at or something) with your document. From there, you just need a simple view to output all the docs by their creation date.
I was going to suggest using the last_seq information from the database, but the sequence number changes with every single write, and replication also complicates the matter further.

Why the OnWorkflowItemChanged is different between List and document library?

I am doing a workflow for a document library. I put a OnWorkflowItemChanged, and I want to get the value of the column which is changed. I use the workflowProperties.Item["name"] and use the afterProperties. But when I use the workflowProperties.Item["column name"], I still got the original value. When I use the afterProperties, it's NULL.
Then I make another workflow that is the same as above for a list. I can use the workflowProperties.Item["column name"] to get the new value in OnWorkflowItemChanged.
Has anyone come across this problem before? Can you give me some help?
The question seems to mix up Item with ExtendedProperties. As to why a difference is seen on a List/Document Lib, it might have something to do with versionining or perhaps the internal serialization is different. Anyway, some of my experience is outline below. I hope it may be of use:
Use the GUID (as a Guid object, not a string) to access the Before / After ExtendedProperties field. Using the Display Name in the ExtendedProperties will not work. The documentation on it is wrong. You can use SPList.Fields to go from Display Name to Column ID (Guid).
I bind all "Before" to MyWhatever_PreviousProperties and all "After" to MyWhatever_Properties, only accessing MyWhatever_[Previous]Properties after the appropriate event(s)).

Resources