I have a Revit Add-In and I would like to disable some actions if Revit is running in Viewer Mode. I am looking for a method or property to check in the Revit API and I can't find one. Do you know if one exists?
Revit viewer mode check in a plugin using the API
Re: Revit 2019 API, element.CanBeHidden returning false for 2019, true for 2018
Dear Gary,
Thank you for your clear description and reproducible case.
Ooops, though...
I just took a look, and it is rather a lot of stuff.
Do you really need Ionic.Zip.dll?
What is the meaning of '2014 Extrusion Issue.txt'?
Could you please remove everything unneeded, so that it is really minimal?
All extraneous content causes infinite confusion.
I would also suggest setting all the .NET assembly DLL 'Copy Local' compilation flags to false.
Currently, you are including all these DLLs, most if not all of which are probably not needed:
$ find . | grep -i dll ./bin/Debug/ImportToRevit.dll ./bin/Debug/RevitAPI.DLL ./bin/Debug/RevitAPIUI.DLL ./bin/Release/ImportToRevit.dll ./bin/Release/RevitAddInUtility.dll ./bin/Release/RevitAPI.DLL ./bin/Release/RevitAPIUI.DLL ./Ionic.Zip.dll ./obj/Debug/ImportToRevit.dll ./obj/Release/ImportToRevit.dll
The Revit API assemblies should always have their copy local flags set to false:
http://thebuildingcoder.typepad.com/blog/2011/08/set-copy-local-to-false.html
Did you possibly zip up the wrong directory?
Thank you!
Cheers,
Jeremy
Re: Get all room names from one plan view and change the parameter of a room
This same question is also discussed o StackOverflow:
Cheers,
Jeremy
Re: room boundaries from room.ClosedShell() or room.GetBoundarySegments
for instance, seating above and under (_room 1, storage), pic at right is 3D room created based on interior finish face
Re: Revit viewer mode check in a plugin using the API
Hi,
This is maybe what you're looking for.
The ControlledApplication class has some Events where you can subscribe to an event.
http://www.revitapidocs.com/2018.1/fa23dcb9-fd52-b8ac-eec4-7ce03eac4b7d.htm
Re: Revit viewer mode check in a plugin using the API
I don't see an event that would tell me if Revit is running in "Viewer Mode". Is there one?
Re: Revit viewer mode check in a plugin using the API
No, i don't think there is one.
I only find this link with some search, not sure if this helps.
Re: Revit API Reference with yellow triangle Visual Studio 2015.
Do this:
Then, as mentioned above, in the properties for each of these two references, set the Copy Local to false.
you should also try working through the "my first revit plugin" when you can. See the first few posts pinned to the top of this message board.
Transfer data to external database
This may have been asked before but I could not find anything about it. My main question is what would be a good implementation for the following:
A Revit Add-In tracks the document changes by subscribing to DocumentChanged event. Then, it does some analysis and if needed, saves some info about that change in a Queue collection. At the same time, it is supposed to transfer that info to an external database.
One approach is to use an IExternalEventHandler and raise the event whenever an entry is loaded into the Queue. Although, this is not very promising when several entries are added in a relatively short time. And I believe there is no way to make the data transfer to the external database async. (Sometimes my external database is not accessible because the previous entry in being transferred)
My other idea is to start a different thread and in an infinite loop try to dequeue the collection and transfer data to external database asynchronously. Something like this:
Task.Run(async () => { while (true) { //Dequeue and transfer data asynchronously await DataTransfer(); } });
But I'm not sure about the complications of this approach. I am wondering if someone has tried it in Revit context or has some experience to share. Thanks in advance.
Note: All the Revit API calls are in the main thread.
Re: Why couldn't code rotate model lines on elevation?
continuing the previous response, I would assume you need to rotate the reference plane, and the line should rotate with it.
Maybe someone else can provide more detail?
Edit:
Try looking here for some details:
http://thebuildingcoder.typepad.com/blog/2009/05/model-line-sketch-plane.html
And this is very interesting: Using delete to find the line and the sketch plane ID:
http://adndevblog.typepad.com/aec/2012/07/get-the-sketch-and-sketch-plane.html
Re: Transfer data to external database
Very interesting question.
I have explored various aspects in some depth in the past.
Here is a starting point that branches out to several samples connecting desktop and cloud and includes hundreds of detailed blog post discussions:
https://github.com/jeremytammik/FireRatingCloud
Cheers,
Jeremy
BoundingBox rotation not 100% correct unless it's set 3 times
Hi everyone,
I'm applying a transformation to the Cropbox of an elevation view section. However, if I apply the transformation once, the object will not rotate completely, same if applied 2 times. It's only when I set the cropbox 3 times or more, that the transformation is 100% correct.
For instance, rotating it once to 30.0 degrees will make the object rotate only 28.3, if twice it will be 29. 6, after the third time (or 4th, 5th, etc.), the object will be rotated 30.0 degrees. Is this a bug, or am I not setting the cropbox correctly ?
I am doing it the following way:
BoundingBoxXYZ box = myViewSection.CropBox; Transform rotationTransform = myRotationTransform; box.Transform = box.Transform.Multiply(rotationTransform); //Start of transaction myViewSection.CropBox = box; //End of transaction //Start of transaction myViewSection.CropBox = box; //End of transaction //Start of transaction myViewSection.CropBox = box; //End of transaction
If i run the transaction once, the rotation is not completed, but after 3 or more times, the view is rotated correctly. Maybe there is another way to modify a cropbox transformation but I couldn't find any, and I can't understand why doing it once doesn't work.
Re: Cannot create a new tag after successfully loading its family.
This was solved by loading the entire Family of the tag, instead of its specific family symbol.
Re: Revit 2019 API, element.CanBeHidden returning false for 2019, true for 2018
Hi,
Project (with several files and directories cleaned out, copy local flags looked okay?) reattached. Its really just a case of someone casting an eye over TeklaIFCImportForm.cs which shows the creation and attempted hiding of an element, any other unnecessary code and files can be ignored.
Time is limited so I haven't been able to go over this test project in minute detail, but I think it clearly shows the issue. As mentioned this test runs fine in 2018 but fails to hide elements in 2019.
Thanks,
Gary
Re: Transfer data to external database
I was thinking about this problem and I have ide:
while puting data to many table in different task is not a problem in one table you can get error, so maybe it is worth to try create first a empty record only with id and the use range of premade ID to different Task.
Like Time of low use of data base create 10000 ID
and then
1-2500 task one
2501 - 5000 task two
5001 - 7500 task tree
7501-10000 task four
but maybe better way is to make separate table for different category of revit element.
GETCENTERLINECURVES for stirrup rebar
HI guys,
I wrote a plug-in for the 2D detailing of reinforcement.
I use this "ListCurveRET_HK = myrebar.GetCenterlineCurves(True, False, True, MultiplanarOption.IncludeOnlyPlanarCurves, rebMEDIA_Index)" for extrac the curve and then I apply a transformation to draw it on a sketchplane. It works fine for all rebars except closed stirrups like this: https://www.revitcity.com/forums.php?action=viewthread&thread_id=27891
The problem is that the excrated curve is in 3D and I have to flatten it before apply the tranformation.
How I can do this?
Reload DWG to Revit File
Hi,
I am doing a customization in revit architecture like updating parameters.
The parameters are updating correctly but if i want to see them in revit file they are not appearing.
Kindly suggest what are the ways to reload the model after making changes so that the updated attributes appear.
Regards,
Krati
Software Engineer
Re: GETCENTERLINECURVES for stirrup rebar
Hi scarta,
You need to transform the stirrup rebar curve to plannar manually.
Following codes transform stirrup rebar curve to horizonal plane, then you can use your transform to draw 2D
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { Document doc = commandData.Application.ActiveUIDocument.Document; IList<Element> es = new FilteredElementCollector(doc).OfClass(typeof(Rebar)).ToElements(); foreach (var e in es) { Rebar rebar = e as Rebar; IList<Curve> cs = rebar.GetCenterlineCurves(false, false, true, MultiplanarOption.IncludeOnlyPlanarCurves, 0); BoundingBoxXYZ box = rebar.get_BoundingBox(doc.ActiveView); //rebat plane normal XYZ normal = rebar.Normal; //find a line in rebar plane Line line = cs.FirstOrDefault(m => m is Line) as Line; //rotate axis XYZ axis = line.Direction.CrossProduct(normal).Normalize(); //the angle that to ratate double angle = normal.AngleTo(XYZ.BasisZ); //the transformed curves which lay on horizonal plane List<Curve> transformed = new List<Curve>(); foreach(Curve c in cs) { transformed.Add(c.CreateTransformed(Transform.CreateRotation(axis, angle))); } } return Result.Succeeded; }
CADLinks
Apologies for the simplistic nature of the question and thank you in advance for any clarification.
First a little background I am using Revit 2018 and programming in C#.
As I understand it CAD Links can be made to files of the following format DWG, DXF, DGN, SAT & SKP.
When I utilise the following:
IList<Element> Revitlist = (IList<Element>)new FilteredElementCollector(openDoc).OfClass(typeof(RevitLinkType)).WhereElementIsElementType().ToList<Element>();
This provides me with a list of these Linked files.
I can create (Reload) a link to a DWG file utilising:
trans.Start();
cadLinkType.LoadFrom(string Path);
trans.Commit();
if I try the same for any other supported CAD Link types i.e. DXF it returns an error stating it is not a DWG.
Question
How do you create (Reload) a link to none DWG CadLinkType formats.
What am I missing?
Again thank you for your assistance.
Re: Reload DWG to Revit File
Hi!
You can use CADLinkType.Reload method, but it appeared in API since Revit 2018, there is no appropriate method in older Revit versions.
Be careful, CADLinkType represents both CAD links and CAD imports. The function IsLink can be used to distinguish between the two. CAD imports are not ExternalFileReferences; they are brought completely into the document and maintain no connection to their original file. (this is from documentation)