Quantcast
Channel: All Revit API Forum posts
Viewing all 66705 articles
Browse latest View live

Re: Volume of Profile in model

$
0
0

I Checked, but have to change decimal of volume in setting.

 

-RK.


Re: Family Instance Filter

$
0
0

Dear Dale,

 

Thank you for your query.

 

Definitely not daft; however, this information is out there in numerous previous threads and dozens if not hundreds of blog posts.

 

You do not need to apply specific filters, ever, or apply them in any specific order.

 

You can apply any filters you like in any order you like.

 

Revit may perform some optimisation by reordering them.

 

It is probably useful to apply all quick filters first:

 

http://thebuildingcoder.typepad.com/blog/2015/12/quick-slow-and-linq-element-filtering.html

 

I have repeated more than a hundred times now:

 

Using ToList is normally not necessary and may cause a significant inefficiency.

 

http://thebuildingcoder.typepad.com/blog/2012/09/findelement-and-collector-optimisation.html

 

I your case, I would simply use:

 

  string targetName = "60\" x 30\" Student";

  FilteredElementCollector instances
    = new FilteredElementCollector( document )
      .OfClass( typeof( FamilyInstance ) )
      .Where( x => x.Name == familySymbolName );

 

As also mentioned numerous times in the past, you can make it more efficient by using a parameter filter to check the name instead of LINQ:

 

http://thebuildingcoder.typepad.com/blog/2010/06/element-name-parameter-filter-correction.html

 

Check out all the examples provided by The Building Coder samples in the module CmdCollectorPerformance.cs:

 

https://github.com/jeremytammik/the_building_coder_samples

 

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/CmdCollectorPerformance.cs

 

I hope this helps.

 

Cheers,

 

Jeremy

Re: Can't rotate element into this position

$
0
0

a generic model family has a (internal) XY workplane . Always Vertical doesn't apply to the whole family, but rather to the direction of the Z axis.

 

If always vertical the Z - axis == Z-axis of the project.

 

see http://help.autodesk.com/view/RVT/2016/ENU/?guid=GUID-70F24230-D596-4AA3-A425-91B1E560BC53

 

 

When dealing with generic models, I find it most easy to place an instance on its own special created reference plane and rotate that plane.

(workplane based - checked, and always vertical - not checked)

Re: Can't rotate element into this position

$
0
0

Thanks FAIR59,

I've read about this type of solution elsewhere. I think it may work.

How to implement?

 

I've defined the following plane which lies in the Center of the ring:

 

XYZ bubbleEnd = newXYZ(10, 0, 0);

XYZ freeEnd = newXYZ(-10, 0, 0);

XYZ cutVec = newXYZ(0, 0, 1);

doc.FamilyCreate.NewReferencePlane(bubbleEnd, freeEnd, cutVec, doc.ActiveView);

 

In the Family document I can see the plane, but how do I get a handle on this plane in the FamilyInstance in order to be able to rotate the FamilyInstance?

And why do I Keep getting the error message "Elements cannot be turned into this Position" when I set

 

(workplane based - checked, and always vertical - not checked), i.e.

 

doc.OwnerFamily.get_Parameter(BuiltInParameter.FAMILY_ALWAYS_VERTICAL).Set(0);

doc.OwnerFamily.get_Parameter(BuiltInParameter.FAMILY_WORK_PLANE_BASED).Set(1);

 

dirk

 

referenzebene.png

 

Re: Can't rotate element into this position

$
0
0

Hello FAIR59,

Could this be the solution?

 

1. I define a Referenceplane in the Family

2. I set (workplane based - checked, and always vertical - not checked)

3. In the project, I rotate/translate a plane instance into the desired final Location/Orientation along the tunnel axis for the ring

4. I instantiate a FamilyInstance on that transformed plane using the following overload,

public FamilyInstance NewFamilyInstance(
	Reference reference,
	XYZ location,
	XYZ referenceDirection,
	FamilySymbol symbol
)

dirk

 

Re: InstanceVoidCutUtils.AddInstanceVoidCut() is disabled to called from the Upd

$
0
0

Dear Rudi and Jeremy,

 

I implemented this solution some time ago, but it generates another issue when the user wants to undo the process. He must undo two times. One time, to roll back the native transaction executed by Revit e.g. Move, rotate, copy, etc. and second time, to roll back the transaction that is created in the idling.

 

The user is not accustomed to undoing two times for a process that seems to be one. If the user does only one time, it could cause a mess in the involved objects specially if you work with extensible storage.

 

Many Regards,

Marcelo

Re: Family Instance Filter

$
0
0

Hi Jeremy, Certainly there are many, many examples as you say, and I think I have read most of them. Regarding your suggested code:

Assume there are two title block families: TB1 and TB2, both of which has a type named 60" x 30" Student, then your collector will return instances of both TB1 and TB2 families. I thought it must be possible to write a single filter statement that would collect only TB2:60" x 30" Student instances. It seems counter intuitive to run a foreach over your results to check the family type. Again, am I missing something? Dale.

End of idling or start of activity

$
0
0

I am looking to determine when Revit has stopped Idling. I have an Idling event that I am subscribed to.  Is there any indication of the end of Idling? I didn't see a general event that indicates general activity in Revit.

Thanks


Re: Get selected elements from linked model

Find the inserts of walls that face a room

$
0
0

I need to find the inserts on walls that bound a room, but I don't know how to filter the ones that are inserted into the wall, but don't face the room.

This post explains the situation a bit better DynamoBIM forum post. I post this here because I plan to use the API from C# instead of using dynamo, so i'd like to know if I can filter these elements using the API directly and C#.

 

Thanks for reading.

Re: Can't rotate element into this position

$
0
0

Hello dirk,

 

no need for the extra reference plane in the family.

 

workflow:

1. in Family: set (workplane based - checked, and always vertical - not checked)

2. in Project: create referenceplane refPlane

3. in Project: host a new FamilyInstance on the refPlane using doc.Create.NewFamilyInstance(refPlane.reference, location, referenceDirection, symbol)

 

this is the code I used in the past:

 

        public FamilyInstance PlaceInstance(FamilySymbol symb, XYZ placementPoint, XYZ planeNormal, XYZ instHandDirection, bool OnReferencePlane = true)
        {
            if (symb == null) return null;
            Document doc = symb.Document;
            Family _family = symb.Family;
            if (_family.FamilyPlacementType != FamilyPlacementType.WorkPlaneBased) return null;
            if (planeNormal.IsAlmostEqualTo(XYZ.Zero)) planeNormal = new XYZ(0, 0, 1);
            if (instHandDirection.IsAlmostEqualTo(XYZ.Zero)) instHandDirection = new XYZ(1, 0, 0);
            if (planeNormal.DotProduct(instHandDirection).CompareTo(0) != 0) return null; // check instHandDirection perpendicular to planeNormal.
            ReferencePlane refPlane = null;
            FamilyInstance _instance1 = null;
            XYZ YVec = planeNormal.CrossProduct(instHandDirection).Normalize();
            using (SubTransaction trn = new SubTransaction(doc))
            {
                trn.Start();
                refPlane = doc.Create.NewReferencePlane(placementPoint.Add(instHandDirection), placementPoint, YVec, doc.ActiveView);
                refPlane.Name = "ref" + Guid.NewGuid().ToString();
                _instance1 = doc.Create.NewFamilyInstance(refPlane.GetReference(), placementPoint, instHandDirection, symb);
                trn.Commit();
            }
            if (!OnReferencePlane)
            {
                using (SubTransaction trn = new SubTransaction(doc))
                {
                    trn.Start();
                    doc.Delete(refPlane.Id);
                    trn.Commit();
                }
            }

            return _instance1;
        }

 if you call this method with OnReferencePlane = true, then you can rotate the familyInstance by rotating its host (the referenceplane).

 

Re: Can't rotate element into this position

$
0
0

Thanks FAIR59,

 

I will try this and give feedback.

dirk

Revit to NWC export 3D View

$
0
0

we need Revit 3D view (all)  export to navisworks files (NWC)

-  when we export NWC file from revit all 3D views are export in single file

- or when we export separate NWC file for each 3D view and append one by one in Navisworks it show all 3D views separately.

 

Re: Can't rotate element into this position

$
0
0

Hello FAIR59,

 

what does "instHandDirection" represent?

dirk

 

Revit Add In Help

$
0
0

I basically have no coding experience. I have been searching for months for an Revit Add in which allows the user to define the pipe flow calculation method/formula. I have finally found one online, however, I have no idea how to edit the actual calculation and also, how to install the add in. Can anybody help me with this?


Re: Can't rotate element into this position

$
0
0

that's the referenceDirection.

 

default placement

placementPoint XYZ(0,0,0)

planeNormal XYZ(0,0,1)

instHandDirection XYZ(1,0,0)

 

placing the ring vertical:

 

placementPoint XYZ(0,0,0)

planeNormal XYZ(1,0,0)

instHandDirection XYZ(0,0,-1)

 

or

 

placementPoint XYZ(0,0,0)

planeNormal XYZ(0,1,0)

instHandDirection XYZ(1,0,0)

 

Re: Find the inserts of walls that face a room

$
0
0

1. You can get all inserts of wall which belong to the room.

2. Check you insert for intersection with room:

var bb = insert.get_BoundingBox(null);   //Get bounding box of insert instance
Outline outline = new Outline(bb.Min, bb.Max);
BoundingBoxIntersectsFilter bbfilter = new BoundingBoxIntersectsFilter(outline);
ICollection<ElementId> idsExclude = new List<ElementId>();
idsExclude.Add(insert.Id);
collector.Excluding(idsExclude).WherePasses(bbfilter);
foreach (var el in collector)    //Get all elements which intersct with insert
  {
      Element el = doc.GetElement(el.Id);
      if (el is Room)
           {
             //DoSome
            }
   }

 

Re: Can't rotate element into this position

$
0
0

Does instHandDirection  need to be normal to planeNormal ?

dirk

Re: End of idling or start of activity

$
0
0
Hi,

In revit Idling event is not stopped . But we can stop it by adding condition in idling event with de register idling event.

Re: Drag and Drop between Revit and API

$
0
0
This is using the custom drag and drop interface, to get a dictionary of paths and their coordinates into the newfamilyinstance(xyz, familysymol) overload? It will still be loading the external family and its type I hope?
Viewing all 66705 articles
Browse latest View live