Revit Addins that Run in the Background/Always - revit-api

Is there a way to create a Revit macro/add-in that will be running constantly. My employer is curious if I can write a program that makes a piece of equipment (for example a lighting fixture) a different color if it is not circuited/not connected to a circuit.
Let me know if there is a way or if there is a completely different method I could use to achieve this task.
Be straight with me, because I am willing to make an add-in that you still have to run every time to check the parts for circuitry. But obviously, the background running add-in would be nicer... Thanks!

Possible a couple different ways.
Best way is probably Updaters.
Fall back would be Idling/External Events.
But generally if you want to update something dynamically based on when things change, Updaters are the way to go. I believe that there are samples in the SDK.

There is a much simpler way to do this. You can use a filter in your view to change the color, or other properties, if the element isn't circuited.
In Visibility Graphics, Filter Tab, Create a new filter, for category select Light Fixtures, for the filter criteria, select Circuit Number, for the comparison, choose Less Than, use the value .
This will match fixtures that haven't been powered & fixtures that have been powered but not assigned to a panel.

Related

Is it possible to pin items to top with ObjectListView?

Is there any way with ObjectListView to pin items so they will stay at the top of the list regardless of sort order?
Pretty graphic pins would be great but just to get 2-3 items to stay at the top would be great.
As far as I know, there is no native support for pinning items like that.
You could probably implement a custom sorter to achieve that. However, your "Model Objects" would have to "know" that they are pinned. In other words, you would probably need a bool Pinned property on the object that you can access while sorting.

Millions of rows in GUI

I would like to implement a GUI handling a huge number of rows and I need to use GTK in Linux.
I started having a look at GTKTreeView with lists but I don't think that adding millions of lines directly to that widget will help in having a GUI that doesn't slow the application.
Do you know whether there is a GTK widget already in place for this problem or do I have to handle my self the window frame that that must display those lines? Eventually I would write the data directly using GtkDrawingArea (essentially writing a new widget).
Any suggestion about any GTK topic or project I can look as starting point for my research?
As suggested in the comments, you can use the Cell Data Func, and get the displayed data under contro. But I have another idea: Millions of lines are much much more than any amount of information a human user can see and understand. So maybe a better, more usable and user-friendly solution, is to diaplay the data in a way the users can more easily navigate in it.
Imagine opening a huge hierarchy, scrolling down, and forgetting what were the top-level items you opened.
Example for a possible solution: Have a combo box which allows to choose some filter or category, and this can reduce the amount of data to a reasonable amount the user can more easily navigate and make a mental model of it if necessary.
NOTE: As far as I know, GtkTreeView doesn't support sorting/filtering and drag-n-drop at the same time, so if you want to use both features, I suggest you use the existing drag-n-drop functionality (otherwise very complicated to implement by hand) and implement your own sorting/filtering.

Dynamics CRM 2011: custom entity fields that calculate something

I need certain custom entity fields to calculate and display values based on operations on the data in the system.
For example an a booking system implementation with contacts and custom entity: tickets. There is a one-many relationship between contact and tickets.I would like to create a field that calculates and displays in the contact form:
frequent flyers: more than 10 tickets bought.
a field that displays yes or no based on whether a first class ticket has ever been purchased. Ticket ref would start with say, FCxxx
If this isn't possible perhaps someone could suggest an alt method for displaying this info?
This is possible and you have some ways to do that: Workflow or Plug-in.
If you make a lot of calculations i think the best way is doing a plug-in. You can register in post create event of tickets entity and there you can make all this calculations and update the custom fields of contact entity.
You can check some tutorials about developing a plug-in:
http://mscrmshop.blogspot.pt/2010/10/crm-2011-plugin-tutorial.html
http://msdn.microsoft.com/en-us/library/gg695782.aspx
http://crmconsultancy.wordpress.com/2010/10/25/plugins-in-crm-2011/
Specific information about registering a plug-in:
http://msdn.microsoft.com/en-us/library/hh237515.aspx
In SDK you can find more examples.
As far I'm aware, it's not possible to achieve without coding. So, if you're looking for a way to customize it by mousing, you might be just out of luck.
If you wish to display that information upon retrieval of the a customer, it's probably fastest to get it using JavaScript. You can add a custom script to onload event. However, that means that you'll have to write JavaScript so if you're not into coding you'll have problems.
If you do know how to code, perhaps creating a plugin with C# is the most preferred way (that's what I'd do at least). The advantage of that lies in extensibility, should you realize that you wish to perform more operations.
Also, if you wish to store the computed values, you'll have to go with a plugin. Otherwise, only GUI operations will perform the computations. If a program will enter/retrieve data in the background, you can't rely that the values will be computed, unless you listen to the messages of Retrieve, Create etc.

Design consideration

In my current application, which is quite simple, I have a class responsible for keeping track of all the customers. It adds new customers, updates details, assigns managers etc. All in all, it performs some logic and keeps track of what is there.
Now, I need to display this database in a complicated way, with certain string formatting, column widths etc. Should this behaviour be part of an external class that would take a list of cusomers, or should it rather stay within the Database itself, as it is the "closest" to the customer objects? What are pros/cons of both approaches? What makes more sense semantically?
Thx in advance.
I would use an external class because the code will be reusable for other applications. If you tie the formatting to the database, then you'll end up with very specific code that will cost you time further on down the road.
That being said, the elegant solution is not always the fastest. If there's a looming deadline, and you find it easier and faster to hard code your formatting info, then it may be more prudent to brute force your way through it so you don't end up with an angry client, an unfinished project and an unpaid invoice.

Newb: WPF custom graphic control - where to start

Apologies if there is a thread for this already, I couldn't find one that I could get my teeth into.
Anyway, I'm new to WPF and want to create a custom control that will be a sort of graphic control. The graphic will always consist of a circle, containing a matrix of several squares (from several hundred to several thousand actually) The squares need to respond to mouse click and mouse over events (and ideally be possible to navigate/select via keyboard.) Each square will represent an object I've coded.
In the past I've used a grid control to display the coloured squares (with VCL in CBuilder) but I would like to make a graphical version. (Actually, another question I'd like to ask is, is there a WPF grid control where I can set the colours of individual cells?)
The question is, where to start? Do I start with a canvas and draw on it? Do I derive from an existing object? I'm just a little lacking on ideas on implementation so any pointers or advice you can offer will be greatly received.
BBz
First off I would suggest getting a decent handle on WPF and how it approaches the problem set. It is vastly different from previous .NET Desktop technologies such as WinForms. Once you have a decent understanding in regards to the separation of logic from UI and how WPF approaches the problem then you can dive in and begin making the right decisions based upon what you encounter.
The problem you mention can be solved in multiple ways. In regards to your question about making use of a Grid, that could be done as that is a layout type. It is vastly superior to the Canvas in terms of arranging your visual structure. The defined rows/columns are nothing more then containers which can hold varying UI objects. Therefore pushing a Rectangle into the Grid and coloring as desired would give you the effect you are looking for. This Rectangle could then become a custom control which would allow you to define varying properties on, as well as specific triggers for mouse overs, etc...
At a higher level you will want to encapsulate this logic as a UserControl which will also hold your custom control. Perhaps the UserControl contains the Grid which will make use of your custom control.
Hopefully this gives you some ideas around how to get started, however getting a better understanding of WPF will help you immensely in achieving your goal.

Resources