Today, we look at a request for new ideas for enhancing RevitLookup, implementing a pickpoint rubber band and opening BIMs on ACC Docs:
- Request for RevitLookup ideas
- Transient elements for jig
- Transient
DirectShape
jig - Opening a model in ACC Docs
- Stop using JPEG
- Stop using voice id
Request for RevitLookup Ideas
Do you have any ideas for RevitLookup enhancements?
A lot of exciting functionality has already been worked on in the dev and dev_winui branches. We expect to see that coming out quite soon.
Meanwhile, Roman Nice3point opened a discussion for collecting RevitLookup Ideas. Your contributions there are welcome. Thank you!
Transient Elements for Jig
A couple of ideas on creating transient elements graphics similar to the AutoCAD jig functionality using
the IDirectContext3DServer
functionality or the temporary InCanvas graphics API were recapitulated in
the Revit API discussion forum thread
on drawing line visible on screen:
- Onbox, DirectContext Jig and No CDN
- Transient Graphics, Humane AI, BI and Lockdown
- Flip, Mirror, Transform and Transient Graphics
Lorenzo Virone shared a different approach, creating and deleting database-resident Revit elements on the fly in a loop:
I faced a similar UI problem to create a rubber band between two points.
I used two functions, Line.CreateBound
and NewDetailCurve
, inside a loop to create a line at the cursor position, refresh, and delete the line every 0.1 seconds, until the user chooses the second point.
A little tricky, but it works fine for me, and Revit seems to execute these 2 functions very fast.
This trick will technically work with anything: create new elements on each mouse movement, refresh, delete the created elements and replace them with new ones. You can use either model or detail elements. It's easy to implement, because you just need to call the two methods, e.g., like this:
- bool done = false;
- List<ElementId> temp = new List<ElementId>();
- while (!done)
- {
- doc.Delete(temp);
- // Create temp elements
- // Save their IDs in `temp`
- // Set `done` to `true` when finished
- doc.regenerate();
- uidoc.RefreshActiveView();
- Thread.Sleep(500); // milliseconds
- }
- // Your final elements are in `temp`
Many thanks to Lorenzo for sharing this nice solution.
Transient DirectShape Jig
Chuong Ho adds: This technique can also be used with a DirectShape
element:
- using Autodesk.Revit.DB;
- using Autodesk.Revit.UI.Selection;
- using System.Collections.Generic;
- using Line = Autodesk.Revit.DB.Line;
- using Point = Autodesk.Revit.DB.Point;
- var Doc = commandData.Application.ActiveUIDocument.Document;
- using TransactionGroup trang = new TransactionGroup(Doc, "test");
- trang.Start();
- XYZ a = UIDoc.Selection.PickPoint(ObjectSnapTypes.None);
- SetPoint(a);
- XYZ b = UIDoc.Selection.PickPoint(ObjectSnapTypes.None);
- SetPoint(b);
- SetLine(a, b);
- XYZ p1 = UIDoc.Selection.PickPoint(ObjectSnapTypes.None);
- SetPoint(p1);
- XYZ p2 = UIDoc.Selection.PickPoint(ObjectSnapTypes.None);
- SetPoint(p2);
- bool isSamSide = IsSamSide(p1, p2, a, b);
- MessageBox.Show(isSamSide.ToString());
- trang.Assimilate();
- // visualize a point
- void SetPoint(XYZ xyz)
- {
- using (Transaction tran = new Transaction(Doc, "Add point"))
- {
- tran.Start();
- Point point1 = Point.Create(xyz);
- DirectShape ds =
- DirectShape.CreateElement(Doc, new ElementId(BuiltInCategory.OST_GenericModel));
- ds.SetShape(new List<GeometryObject>() { point1 });
- tran.Commit();
- }
- }
- // visualize a line
- void SetLine(XYZ x1, XYZ x2)
- {
- using (Transaction tran = new Transaction(Doc, "Add line"))
- {
- tran.Start();
- Line line = Line.CreateBound(x1, x2);
- DirectShape ds = DirectShape.CreateElement(
- Doc, new ElementId(BuiltInCategory.OST_GenericModel));
- ds.SetShape(new List<GeometryObject>() { line });
- tran.Commit();
- }
- }
Many thanks to Chuong Ho for this addition!
Opening a Model in ACC Docs
We started out discussing opening a cloud model with Revit API in the Revit API discussion forum, but then moved it over to StackOverflow, the better place for such a cloud-related topic, where my colleague Eason Kang explains how to open files located in ACC Docs:
Question: My Visual Studio Revit API add-in open Revit files to export data in a batch. I can add many files which are on the networks and the plugin automatically opens them all. Is it possible to also open files that are in the ACC Docs cloud?
I know I can open AccDocs which were be already downloaded locally by searching for them in the collaboration cache folder, but how to open files which have not yet been downloaded?
Answer: Since you mention the collaboration cache folder, I assume you are using
the Revit Cloud Worksharing model,
a.k.a. C4R
, the model for Autodesk Collaboration for Revit.
If so, you can make use of
the APS Data Management API to
obtain the projectGuid
and modelGuid
in the model version tip like this:
{ "type":"versions", "id":"urn:adsk.wipprod:fs.file:vf.abcd1234?version=1", "attributes":{ "name":"fileName.rvt", "displayName":"fileName.rvt", ... "mimeType":"application/vnd.autodesk.r360", "storageSize":123456, "fileType":"rvt", "extension":{ "type":"versions:autodesk.bim360:C4RModel", .... "data":{ ... "projectGuid":"48da72af-3aa6-4b76-866b-c11bb3d53883", .... "modelGuid":"e666fa30-9808-42f4-a05b-8cb8da576fe9", .... } } }, .... }
With those in hand, you can open the C4R model using Revit API like this:
// where is your BIM360/ACC account based, US or EU? var region = ModelPathUtils.CloudRegionUS; var projectGuid = new Guid("48da72af-3aa6-4b76-866b-c11bb3d53883"); var modelGuid = new Guid("e666fa30-9808-42f4-a05b-8cb8da576fe9"); // For Revit 2023 and newer: var modelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath( region, projectGuid, modelGuid ); // For Revit 2019 - 2022: //var modelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath( // projectGuid, modelGuid ); var openOptions = new OpenOptions(); app.OpenAndActivateDocument( modelPath, openOptions ); // on desktop // on Design Automation for Revit or // to not activate the model on Revit desktop: // app.OpenDocumentFile( modelPath, openOptions );
You can also make use the Visual Studio APS Data Management package on NuGet for this. The Hubs Browser tutorial demonstrates its use.
References:
- Accessing BIM 360 design models on Revit
- How to open a cloud model
- Developer's guide online help on cloud models
Many thanks to Eason for this comprehensive answer!
Stop Using JPEG
Moving away from Revit and its API to other interesting current news, Daniel Immke suggests that it’s the future – you can stop using JPEGs and presents an overview and rationale for some compelling alternatives, e.g., AVIF and WebP.
Stop Using Voice Id
Joseph Cox describes how he broke into a bank account with an AI-generated voice – some banks tout voice ID as a secure way to log into your account. He proves it's possible to trick such systems with free or cheap AI-generated voices.