I've been working on a plugin with a feature to modify an element in a group based on the guide from the Building Coder (http://thebuildingcoder.typepad.com/blog/2010/08/editing-elements-inside-groups.html). It gets some data from the group, explodes the group, makes the modifications to one of the group elements (no movement, just updating some parameters) then finds the other instances and replaces them. The trouble is that the replaced groups don't end up in the same spot as they were before & they lose their mirroring. See attached pictures. Is there any way to store the location differently or save the transformations applied to a group so it doesn'y do this? Using Revit 2013. Any help would be appreciated! Code:
public void updateUnitProperties(Group unit) { Document doc = unit.Document; ICollection<ElementId> grpElements = unit.UngroupMembers(); GroupSet unitInstances = getOtherInstancesOfUnit(doc, unit); GroupType oldGroupType = unit.GroupType; String oldGroupName = unit.GroupType.Name; Group newUnit = doc.Create.NewGroup(grpElements); GroupType newGroupType = newUnit.GroupType; if (unitInstances.Size > 0) { foreach (Group unitInstance in unitInstances) { LocationPoint locPt = unitInstance.Location as LocationPoint; Group newGroupInstance = doc.Create.PlaceGroup(locPt.Point, newGroupType); doc.Delete(unitInstance); } doc.Delete(oldGroupType); newGroupType.Name = oldGroupName; } }
Solved! Go to Solution.
Solved by leslief. Go to Solution.
After wrestling with this a bit longer, I've found that the ungrouped and regrouped group was changing it's location point during that process, I got this translation and applied it to the replaced group. This seems to put the group in the right spot, but I can't yet figure a way to check if a group was mirrored.
So in continuation of this monologue... I eventually realised that even though groups don't have a 'Mirrored' property in the API, elements within the group do, so by pulling an element from the group and calling something like:
FamilyInstance mirrorCheckElem = Elem as FamilyInstance;
bool isMirrored = mirrorCheckElem;
I can get a boolean and use it to decide if the replacement group should be mirrored or not. Hope this saves someone else the hours I spent trying random boundingBox geomtry and unit vector stuff to try and figure it out. <:-)
I found this work:
No need to mess around with where the groups are located at all. I'm using Revit2016 but I can't see any API changes in Revit 2014 through 2016 so it should be accessible in Revit 2013 as well.
Hi pkhlineworks
like you explained when ungroup and regroup, all the element id's and unique id's are refreshed with new values. my assumption is that these id's are for life of that element inside project.
Yes, that is a correct assumption. Unique Ids of elements never change, and Element Ids may change during synchronizing with a central file (when two elements of the same Id get created in two locals and one of them must change it's Id upon merge).
The fact that some elements seems to change their Ids during group manipulation is an indication that the elements that exist after the group manipulations aren't the same elements which where there before the manipulation. For example, if - during a group modification - one element is deleted and later another element (albeit geometrically the same or close to same) created, it is not the same element - elements never assume Ids of other elements even in situations when a latter element replaces its previous version.
This is not unique to group operations. There are other processes in Revit that replace elements along the way, for example the Mirror command. Even though the geometry looks the same after mirroring (except for the mirroring effect, of course), all the mirrored elements are new with their new Ids.
Thank you
Hi Arnošt Löbel
Thanks for your reply.
my requirement is i need unique identifier on an element like door which should not changes unless user deletes and recreates same door again. Here is the reason we export elements from Revit and modify certain attributes values and bring back those elements to revit to apply those changes. so unless we have unique identifier, we cannot apply changes in Revit.
Any thoughts?
Thanks
Giridhar
please take a look a this video
i have tried this flow where you can see element id are changing.
https://onedrive.live.com/redir?resid=7CA9F8979B6AB3CE!15690&authkey=!AOaVkBg6oq2tX2k&ithint=video%2...
hi, You have the pseudocode to achieve this? or even the code or a link. I must do this not care about Ids, they can change like wind.