Family Instance Already Exist

Family Instance Already Exist

Anonymous
Not applicable
1,695 Views
8 Replies
Message 1 of 9

Family Instance Already Exist

Anonymous
Not applicable

Hi All,

 

Greetings for the Day..

 

How to check a family instance is already present at a specific location (that is at XYZ location) in revit document.

 

Thanks

Kailash

0 Likes
Accepted solutions (1)
1,696 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable

Dear Kailash,

 

Use failure processing event to catch "family instance is already exist. You never get before placing.

0 Likes
Message 3 of 9

Anonymous
Not applicable

Thanks manish for the reply, but any other way is there rather than you mentioned.

0 Likes
Message 4 of 9

Anonymous
Not applicable
As i know there is no other way. Because warning message trigger only when such event occurs. We need to catch them and act properly as you want.

Another way tried but that way is not effective and it increase processing time to a great extent.

Tried trick......
Making list of already placed element and check there placement.

In this case only 5% to 30% chance to detect already placed instances before placement.

0 Likes
Message 5 of 9

MarryTookMyCoffe
Collaborator
Collaborator
Accepted solution

"In this case only 5% to 30% chance to detect already placed instances before placement."
I don't know from where you take this %.

 

You can use:

 

public bool InstanceExist(Document document, XYZ point)
{
FilteredElementCollector filteredElementCollector = new FilteredElementCollector(document).OfClass(typeof(Instance));

      foreach (Instance instance in filteredElementCollector)
      {
       Element element = instance as Element;
       Location loc = instance.Location;
       LocationPoint locpoint = loc as LocationPoint;
           if (locpoint.Point.IsAlmostEqualTo(point, 0.001))
           {
            return true;
           }
      }
return false;
}

 

it is importent to use IsAlmostEqualTo() in Revit for points.

 

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
Message 6 of 9

Anonymous
Not applicable

Dear Marry,

This % is based on observation that i did of course this may vary to various scenario. But the best way to do this is catching warning.

Before placement if you want to check instance is available or not for that Making list of location is not a best way.

Due to following reason.

1. Whenever you created a list while placing element. If Some modification is done the location will change so you need to modify the used list.
Hard to maintain (For big files).

2. Your calculation of Location(XYZ) is based on decimal point that need tolerance.
3. You do not decide how much tolerance is good. You get exception for every assumed tolerance for some element.
4. Some time you also get some element have Z-location reported as zero.But actually it not zero. It depend on family.

Yes i accept % is not good to tell. It may different in various scenario.

0 Likes
Message 7 of 9

MarryTookMyCoffe
Collaborator
Collaborator
I feel like you miss the point. What he what to know if he can put instance in this place(he will be fine as long as he will no try to put the same thing over and over in one transaction). What I gave him was example to try.
I chose what tolerance is fine with me, as he can he. No one need perfect tolerance.
four sounds like a bug

BTW: if you don't what to use the entire nickname, than don't use it at all.
-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes
Message 8 of 9

Anonymous
Not applicable

Thanks Marry,

 

The solution which you provided is suitable for my scenario and its working like charm...

 

 thanks once again.. Smiley Happy

0 Likes
Message 9 of 9

MarryTookMyCoffe
Collaborator
Collaborator
np, glad I could help
-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes