I have 3 entities in a Core Data application:
Projeto <-->> Servico <-->> Sessao
(the relationships are named as usual).
Projeto.servico (to many Projeto --> Servico)
Servico.projeto (inverse to one Servico --> Projeto)
Servico.sessaoDoServico (to many Servico --> Sessao)
Sessao.servicoDaSessao (inverse to one Sessao --> Servico)
Each entity is connected to an array controller, like "Department and employees" in Apple Docs. It's Working fine in a typical Master - details configuration.
Now I want to have all Sessions from a selected Project. (I don't have a relationship between Sessao and Projeto)
I'm trying to bind the SessionArrayController Content Set to filter the sessions without success.
How could I have all sessions for a selected project?
I created a property for the Session Class, returning a NSSet and I can print the desired sessions, but I have no idea, how I could do it with binding.
-(NSSet *)sessoesDoProjeto{
NSSet *allSessions = [self.projeto.servico valueForKey:#"sessaoDoServico"];
NSLog(#"allSessions %#",allSessions);
return allSessions;
}
Could I create a NSArrayController with the above NSSet?
Any help would be appreciated
I found the solution, so I'm posting for others with the same problem.
I bound the Content Array (not content set) of the SessionArrayController to:
ServicoArrayController_by_Project.arrangedObjects.#unionOfSets.sessaoDoServico
It works like a charm!
Related
I am trying to list the view template’s properties so we can compare them with another old template.
For example what model elements are hidden or have overrides in a given template or which Revit links have been hidden or overridden in a given template.
View Template
(https://www.google.com/search?q=view+template+revit&rlz=1C1GGRV_enUS770US770&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjLndrd2cTbAhVESq0KHX1cAPwQ_AUICygC&biw=1536&bih=824#imgrc=Q0v-pV7Nxl4kfM:)
I’m looking to devise a View Template Compare tool and access to the owner and creator of them.
public void ApplyViewTemplateToActiveView()
{
Document doc = this.ActiveUIDocument.Document;
View viewTemplate = (from v in new FilteredElementCollector(doc)
.OfClass(typeof(View))
.Cast<View>()
where v.IsTemplate == true && v.Name == "MyViewTemplate"
select v)
.First();
using (Transaction t = new Transaction(doc,"Set View Template"))
{
t.Start();
doc.ActiveView.ViewTemplateId = viewTemplate.Id;
t.Commit();
}
}
With Revit API you can access with:
GetTemplateParameterIds Method / ViewTemplateId Property
The Revit API exposes almost all the ViewTemplate properties.
For instance this method returns all the Visibility/Graphic Overrides for a specific category:
https://apidocs.co/apps/revit/2019/ed267b82-56be-6e3b-0c6d-4de7df1ed312.htm
The only thing I couldn't get for a ViewTemplate are the "includes", but all the rest seems to be there.
Update:
The list or properties "not included" can be retrieved with GetNonControlledTemplateParameterIds().
Yes, and no.
Yes, I guess you can use Forge Model Derivative API to export RVT file and then build a dashboard around the View Templates data. That's assuming that View Templates data actually gets exported when the model is translated. That data is not attached to any geometry so I would not be surprised if it was skipped. The question here is why? This is like renting a 16-wheel truck to move a duffel bag across the street.
No, if your intention is to directly interact with the RVT model. Forge can view it, but to push anything back or request changes to the model, is not available yet. Then again, I am not even sure that the view template data is available via model derivative exports.
This brings me another alternative. Why not just collect the data using Revit API, the standard way and then push it out to a Database and build on top of that? There is no reason to employ Forge for any of that.
Thanks Jeremy, I had dig into your amazing website and also some solution that Konrad post in the Dynamo Forum about this. In Revit seems pretty achievable, you filter the View that is View Template and then extracts these properties, is it correct?.
I am wondering if someone can point me in the right direction with Forge.
Some amazing guys are developing a BQL https://www.retriever.works/.
BQL(Building Query Language) is a query language for buildings, similar to how SQL is a query language for databases. It is fast and flexible. BQL helps improve efficiency for QA/QC (quality assurance and quality control), and building data extraction without leaving Revit. I am also trying these and I would like to understand if there are some works where I could start with Forge next week about this.
I just ran into a problem: Why does Magento load all entity-type attributes in the Model
Magento\Eav\Model\Config.php?
I am facing a situation with many product-attributes (round about 20,000) and sets (almost 10,000) and the shop became very slow. Some debugging made clear, that in the named class (Magento\Eav\Model\Config.php) all entity-type attributes are loaded and stored in an array, the set is ignored. This makes the site really slow.
Why is magento loading all attributes here and not just the ones needed via attribute set? Hard-Coding the attribute set works on the product page. Wondering, if some registry solution could be made.
Thank in advance for your ideas and opinions.
Edit
Thank you for your replies. Here is the problem in more detail: On a product page, the function getEntityAttributes of the Config model is called twice. Once with the product object, which leads into loading the correct attribute set. The second time it is loaded just for the product entity type. That makes Magento load all product attributes and saves it into an array, which is very slow. The function getAttributes - for example - calls the function getEntityAttributes just by entitytype.
I have simple cocoa app with 2 entities. They have one to one relationship between them.
In my only window, I have 2 NSTableViews, one display the customer and in another his address. If I change the relationship between the 2 entities in one to many, then everything in my app works (add, edit, delete).
However, if I change the relationship between the 2 entities in one to one, I can insert the customer, but when I attempt to insert record in the second NSTableView (address) app crashes with following error:
2015-10-09 03:50:28.357 TwoEntitiesRecord[1793:56879] -[__NSSetM managedObjectContext]: unrecognized selector sent to instance 0x608000040f90
2015-10-09 03:50:28.357 TwoEntitiesRecord[1793:56879] -[__NSSetM managedObjectContext]: unrecognized selector sent to instance 0x608000040f90
2015-10-09 03:50:28.361 TwoEntitiesRecord[1793:56879] (
I am not posting any code for the app, since I didn't write one. It is all done trough binding.
Any help will be deeply appreciated.
You have an incorrect binding. As you can tell from the error message, you are asking an NSSet for its managedObjectContext. An NSSet does not have a managed object context.
So, look at your bindings. One of them is probably bound to the property that represents a relationship, as that would be an instance of NSSet. Your binding is probably asking it for the MOC.
Just in case that someone has same issue: In one of my array controllers, the one for the address, in array controller attribute inspector I had unchecked auto rearrange content checkbox.
Honestly I have no idea why after I checked this checkbox app suddenly stop crashing on insert, but that was the solution for my problem.
I want to be able to support copy and paste for a tableview row showing a core data entity. This entity has one attribute and two relationships. When I use the dictionary archiving technique recommended by Apple (from 'NSPersistentDocument Core Data Tutorial') I find that the relationships throw an error. Here's the essential piece of code where the problem occurs:
for (id sectionObject in selectedSectionsArray){
NSDictionary *thisDictionary = [sectionObject dictionaryRepresentation]; // 'sectionObject' has 1 attribute and 2 relationships (one-to-many)
[copyObjectsArray addObject:[sectionObject dictionaryRepresentation]];
}
NSPasteboard *generalPasteboard = [NSPasteboard generalPasteboard];
[generalPasteboard declareTypes:[NSArray arrayWithObjects:MSSectionsPBoardType, NSStringPboardType, nil] owner:self];
NSData *copyData = [NSKeyedArchiver archivedDataWithRootObject:copyObjectsArray]; // Here's where it crashes. ERROR MESSAGE: "-[NSManagedObject encodeWithCoder:] unrecognized selector sent to instance 0x22fd410"
Therefore, it seems the only way to copy a relationship to the pasteboard must be to archive its URI. In that case, I have to deal with the headache of referencing temporary ID's. Could someone please confirm that this is the case? Does it have to be so hard?
You haven't read that document closely enough. In the section Custom Employee Logic, it explains that relationships will not be copied for several reasons described there. It then explains how the code handles copying only specific attributes. It seems like you followed the document as far as choosing specific attributes to copy but not about leaving out relationships.
As for the error you're seeing,
-[NSManagedObject encodeWithCoder:] unrecognized selector sent to instance 0x22fd410
This happens because you're calling archivedDataWithRootObject: on a dictionary that contains objects that don't conform to NSCoding, specifically, your managed objects. Archiving like this only works automatically for property list types-- for everything else, you have to implement NSCoding, or you get this error.
Copying a managed object ID's URI is probably reasonable if you want to copy the relationships. If you're having problems with temporary object IDs, do one of the following:
Save changes
Call obtainPermanentIDsForObjects:error: for the objects to get permanent IDs without saving.
I'm trying to follow Marcus Zarra in his book 'Core Data'. In the book, he makes a small sample application, but it doesn't give much help when things don't work out...
He starts out by visually designing three entities, and then adding array controllers for each entity to the main nib.
Second, he adds a tableview and some other visual components to show data from the array controllers.
So far, I have managed to follow, but now he adds a search field to the gui, and binds it to the same array controller as one of the tableviews. Expected behavior would be for the tableview to get filtered when typing in the search field, but nothing happens.
How do I find out what's wrong?
The relevant parts from the nib is as follow:
NSArrayController Recipes
- Mode = Entity
- Enitity Name = Recipe
TableView w/TableColumn
- Value Bind To Recipes
-- Controller Key = arrangedObjects
-- Model Key Path = name
Search Field
- Predicate Bind To Recipes
-- Controller Key = filterPredicate
-- Model Key Path = name
-- Display name = predicate
-- Predicate Format = keyPath contains $value
There are no relevant messages in the console.
regards,
-Vegar
The book example is wrong and will be fixed in the next printing. You can remove the Model Key Path entirely as it is never read and change the predicate format to:
name contains[c] $value