Steve, If you use a DockablePane as your UI, you (user) will only have access to it's content when Revit is idle.
Re: Failure Processing with UI
Beam create opening with family void
Why if I make opening with family void to a beam then make me error for ungroup this group?
I don't understand why?
also if i want exclude this beam there are in a group with whis doesnt work
IEnumerable<Element> Construction_beam = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_StructuralFraming).Where(e => e.GroupId.Equals(null));
Revit stucture element not recognized if points passed manully
I want to recognize the Element in Revit structure by passing the Points XYZ (6710.740595290, 20357.447286130, -16.197018374)
I got this points when I run the selection code where I select the point on element say wall and it identifies the wall.
Now instead of selection I passed the same coordinates manually
XYZ point = new XYZ (6710.740595290, 20357.447286130, -16.197018374);
but now it does not recognizes the structural wall. not sure what difference is in selecting manually and by passing the coordinates directly tower select the Structural Element.
Any step missing while passing coordinates for structural Element selection.
Re: Beam create opening with family void
I think the lookup tool is a bit misleading to indicate null for the GroupID property of a Element that is not part of a group.
Element.GroupID will either be set to a valid ElementID or set to ElementID.InvalidElementID (when it is not part of a group). The Equals method is inherited from object and I don't know that it has been specifically overridden to equate InvalidElementID to null.
Therefore if you change the 'e.GroupID.Equals(Null)' to 'e.GroupID = ElementId.InvalidElementID' then it'll probably work.
I'm guessing it wants to ungroup because the cutting family is not in the group of the instance it is being hosted on. Probably you want to first:
- Get IDs of elements within group and group name
- Ungroup all
- Place cut instance
- Group again elements from (1) with Document.Create.NewGroup(ICollection(of ElementID)).
- Rename group from (1)
RevitAPI.chm file states that if you are adding newly created elements to the group you should call Document.Regenerate to avoid a warning about group being edited outside of the group editing mode.
I don't know if you'll have to include cutting family separately when grouping I believe it may include it since it is now hosted.
Re: Beam create opening with family void
But I dont know I work if I have wall, floor or columns in a group. But if I have structural beam in a group it make problem.
Re: Failure Processing with UI
the API offers the ability to completely replace the standard failure processing user interface using the interface IFailuresProcessor.
This has a method that is allowed to return WaitForUserInput, which leaves the transaction pending.
see http://help.autodesk.com/view/RVT/2014/ENU/?guid=GUID-52A45CC1-3BB4-48B4-BFC7-F6F8666C2AA4
NewDimension between Grids - Invalid Number of references
Hi,
I tried to create a Dimension between two Grids and I always get the same error : Invalid number of references.
public static Dimension createGridDimension(View view, Grid grid1, Grid grid2) { Curve curve1 = grid1.Curve; Curve curve2 = grid2.Curve; if(curve1 == null || curve1.Reference == null || curve2 == null || curve2.Reference == null) { return null; } Line line = Line.CreateBound(curve1.GetEndPoint(0), curve2.GetEndPoint(0)); ReferenceArray references = new ReferenceArray(); references.Append(curve1.Reference); references.Append(curve2.Reference); return view.Document.Create.NewDimension(view, line, references); }
I found this post on the forum, which seems to be a similar issue, but it dates from 2016. I use Revit API 2018 and I hope it has been fixed now.
Best regards,
Jonathan
Re: NewDimension between Grids - Invalid Number of references
Re: Failure Processing with UI
Interesting FAIR59, I had missed that one... I saw IFailuresPreProcessor but that was transaction specific so doesn't work for my purposes, but IFailuresProcessor may... It would force handling of errors as well as warnings (I was looking for just warnings) but it still may work. Thanks for the tip, let me look into it but I'm marking as an answer.
Re: Failure Processing with UI
Thanks for the suggestion GoncaloFeio1321, however I'm already aware of that. The issue with Revit having to idle is what I'm trying to get around...
Re: How to display XYZ points in Revit doc
Hi I know this is an old thread but I was wondering if anything has changed since the last time this was posted? I'm in a similar boat where I'm going to have 3D points (XYZ) that I'd like to display to the user. Ideally I'd just like to display these temporarily as I do not want them showing up in other views or cluttering up the model.
I mainly ask if anything has changed because i know that Dynamo has a method for doing this but I'm not even sure where to begin looking through the Dynamo source code to find it. In Dynamo if you're in in a python node and you output Point.Create(XYZ).ToProtoType() it will display it in your plan views as well as within the dynamo interface. This behaviour of temporarily showing the point in any open Revit views is ideally what I'd like to emulate, I'm just wondering if anyone can point me in the right direction as to what API methods are used to accomplish this?
filter for group elements matching groupname
I want to filter for element IDs of groups matching groupname. Can anybody help me with this?
James LeVieux
Setting conditional parameters with formulas
Hello all,
I've been using Revit for a while but have been asked to dig deeper into learning to work with formulas, as the guy who used to do this recently left.
I currently have a symbol that has 6 parameters, but only the first 2 will be changeable by the user.
- Flip Left Right
- Flip Up Down
- Left Arrow Up
- Left Arrow Down
- Right Arrow Up
- Right Arrow Down
The last four parameters control the graphics and have been placed in the "Other" category. I want only one of the four arrows visible at a time. I already have the last four parameters set to control the visibility of the arrows.
What I want to do now is, if someone toggles Flip Left Right, the arrow will appear either on the left or the right of the symbol in the family. If someone toggles Flip Up Down, it will toggle the arrow pointing up or pointing down.
I've been toying around with using =if(or( statements, but I can't manage to wrap my head around it completely just yet. Any advice would be appreciated, thank you!
Re: NewDimension between Grids - Invalid Number of references
This behaviour is still the same in 2018 but I showed a solution for it yesterday
Basically you can't use the reference from the curve of the grid (since that is a surface), you have to create a new reference by using the grid element itself: New Reference(Grid). This reference you can then add to the reference array of the Create.NewDimension method. It's the same when dimensioning reference planes.
If you only have the curve information to start with (not as your case) then you need to get the grid element from the curve's reference and then create a new reference from that.
Create.NewDimension method expects the reference type of a grid or reference plane to be REFERENCE_TYPE_NONE (for element) not REFERENCE_TYPE_SURFACE.
Re: Fail to get reference for grid for dimension in 2017
Re: filter for group elements matching groupname
VB
Public Function Execute_GroupNameFilter(ByVal commandData As Autodesk.Revit.UI.ExternalCommandData, _ ByRef message As String, ByVal elements As Autodesk.Revit.DB.ElementSet) _ As Autodesk.Revit.UI.Result Dim UIDoc As Autodesk.Revit.UI.UIDocument = commandData.Application.ActiveUIDocument If UIDoc Is Nothing Then Return Result.Cancelled Else Dim Doc As Document = UIDoc.Document Dim FEC As New FilteredElementCollector(Doc) Dim ECF1 As New ElementCategoryFilter(BuiltInCategory.OST_IOSDetailGroups) Dim ECF2 As New ElementCategoryFilter(BuiltInCategory.OST_IOSModelGroups) Dim LorF As New LogicalOrFilter(ECF1, ECF2) Dim Els As List(Of ElementId) = FEC.WherePasses(LorF).WhereElementIsNotElementType.ToList. _ FindAll(Function(X) X.Name = "TheGroupIWant").Select(Function(v) v.Id).ToList UIDoc.Selection.SetElementIds(Els) Return Result.Succeeded End Function
C#
public Autodesk.Revit.UI.Result Execute_GroupNameFilter(Autodesk.Revit.UI.ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { Autodesk.Revit.UI.UIDocument UIDoc = commandData.Application.ActiveUIDocument; if (UIDoc == null) return Result.Cancelled; Document Doc = UIDoc.Document; FilteredElementCollector FEC = new FilteredElementCollector(Doc); ElementCategoryFilter ECF1 = new ElementCategoryFilter(BuiltInCategory.OST_IOSDetailGroups); ElementCategoryFilter ECF2 = new ElementCategoryFilter(BuiltInCategory.OST_IOSModelGroups); LogicalOrFilter LorF = new LogicalOrFilter(ECF1, ECF2); List<ElementId> Els = FEC.WherePasses(LorF).WhereElementIsNotElementType().ToList().FindAll(X => X.Name == "TheGroupIWant").Select(v => v.Id).ToList(); UIDoc.Selection.SetElementIds(Els); return Result.Succeeded; }
Re: Fail to get reference for grid for dimension in 2017
That is true yes.
It seems to expect references for ref planes and grids in particular to be REFERENCE_TYPE_NONE, not sure why.
Re: How to extract points of areas for pathfinding algorithm
Hi,
Boost Your BIM, a software consulting firm, did a project called "Pathfinder" for Stantec that might be of interest. We presented it a BIMForum a few years ago and you can learn more about it at these links:
http://www.globalpres.com/Mediasite/Play/084e3ac57c0848e5b3869db310db1afc1d
Regards
Harry Mattison
Owner, Boost Your BIM
Re: Setting conditional parameters with formulas
As of right now, I've gotten the arrows to appear either on the left or on the right by using the Flip Left Right toggle, but I keep coming to a road block. The current formula's I'm using are:
Left Arrow Up = not(Flip Left Right)
Left Arrow Down = Left Arrow Up
Right Arrow Up = and(Flip Left Right, not(and(Flip Up Down, Left Arrow Up)))
Right Arrow Down = not(or(Left Arrow Down, Left Arrow Up))
I attached the file I'm working with as well
Re: Failure Processing with UI
Here is a class I made some time ago that I never pushed forward (never really tested it).
But loved the idea of turning an external event into a Task!
My fear is what's next after a failed request on ExternalEvent.Raise(). For that I made a class to get the context from application events, but never really run it.
using System; using System.Threading.Tasks; using R = Autodesk.Revit.UI; namespace Cuttlefish.Revit
{ public class AsyncExternalEventHandler : R.IExternalEventHandler { private ExternalEventAdapter adapter; private readonly string name; public AsyncExternalEventHandler(string name = nameof(AsyncExternalEventHandler)) { if (string.IsNullOrWhiteSpace(this.name = name)) { throw new ArgumentNullException(nameof(name)); } SetAdapter(); } public Task ExecuteAsync(Action<R.UIApplication> callback) { return adapter.RaiseAsync(callback); } void R.IExternalEventHandler.Execute(R.UIApplication application) { adapter.Execute(application); SetAdapter(); } string R.IExternalEventHandler.GetName() => name; /// <remarks> /// Must be invoked in a valid Revit context /// </remarks> private ExternalEventAdapter SetAdapter() => adapter = new ExternalEventAdapter(R.ExternalEvent.Create(this)); private class ExternalEventAdapter { private readonly TaskCompletionSource<R.ExternalEventRequest> tcs; private Action<R.UIApplication> callback; private readonly R.ExternalEvent externalEvent; public ExternalEventAdapter(R.ExternalEvent externalEvent) { this.externalEvent = externalEvent ?? throw new ArgumentNullException(nameof(externalEvent)); tcs = new TaskCompletionSource<R.ExternalEventRequest>(); } public void Execute(R.UIApplication app) { try { callback(app); tcs.SetResult(R.ExternalEventRequest.Accepted); } catch (Exception ex) { tcs.SetException(ex); } } public Task<R.ExternalEventRequest> RaiseAsync(Action<R.UIApplication> callback) { this.callback = callback; var request = externalEvent.Raise(); if (request == R.ExternalEventRequest.Denied) { tcs.SetException(new UnauthorizedAccessException());// Now what?! } else if (request == R.ExternalEventRequest.TimedOut) { tcs.SetException(new TimeoutException());// Now what?! } return tcs.Task; } } } }