I've managed to get the dwg database, but i get na error in transation:
I've managed to get the dwg database, but i get na error in transation:
public static void Etrans(string desenho) { System.Windows.MessageBox.Show(desenho + " Passou"); Autodesk.AutoCAD.ApplicationServices.Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; Database myDB = new Autodesk.AutoCAD.DatabaseServices.Database(false, true); using (myDB) { myDB.ReadDwgFile(desenho, FileOpenMode.OpenForReadAndAllShare, true, ""); System.Windows.MessageBox.Show("DB Passou"); string verDb = myDB.Ltscale.ToString(); System.Windows.MessageBox.Show(verDb); try { System.Windows.MessageBox.Show("Entrou try"); DBDictionary nod2 = myDB.NamedObjectsDictionaryId.GetObject(OpenMode.ForRead) as DBDictionary; ObjectId imageDictId2 = nod2.GetAt("ACAD_IMAGE_DICT"); string verDit = imageDictId2.IsNull.ToString(); System.Windows.Forms.MessageBox.Show(verDit); using (Autodesk.AutoCAD.DatabaseServices.Transaction myTrans = myDB.TransactionManager.StartTransaction()) { DBDictionary nod = myTrans.GetObject(myDB.NamedObjectsDictionaryId, OpenMode.ForRead) as DBDictionary; ObjectId imageDictId = nod.GetAt("ACAD_IMAGE_DICT"); DBDictionary imageDict = myTrans.GetObject(imageDictId, OpenMode.ForRead) as DBDictionary; foreach (DBDictionaryEntry dbDictEntry in imageDict) { RasterImageDef rasterImageDef = myTrans.GetObject(dbDictEntry.Value, OpenMode.ForWrite) as RasterImageDef; try { if (System.IO.File.Exists(rasterImageDef.SourceFileName)) { dynamic dwgPathUri = new Uri(desenho); dynamic rasterImagePathUri = new Uri(rasterImageDef.SourceFileName); // Make the raster image path // relative to the drawing path dynamic relativeRasterPathUri = dwgPathUri.MakeRelativeUri(rasterImagePathUri); // Set the source path as relative rasterImageDef.SourceFileName = Uri.UnescapeDataString(relativeRasterPathUri.ToString()); // Reload for AutoCAD to // resolve active path rasterImageDef.Load(); // Check if we found it //RasterImage raster = new RasterImage(); } } catch (Exception ex) { System.Windows.MessageBox.Show("Erro_Raster"); } myDB.SaveAs(desenho, DwgVersion.Current); myDB.Dispose(); } } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString()); } } } #endregion }
This is the code, called by:
foreach (var f in files) { if(f.FullName.Contains(".dwg")) { ZiTools.Etrans(f.FullName); }
I'm not quite sure you can change the design of Revit's built-in buttons, it seems to be baked in the code directly.
However, you can very easily reorganize the quick access toolbar.
To do so, simply right-click on the quick access toolbar, and then click on "Customize Quick Access Toolbar". This will allow you to add/remove tools from the toolbar, but also choose in which order the tools are displayed.
This solution is not API-focused, but I doubt you would need to do those changes more than a couple times, so a macro would be overkill anyway.
Antoine
Hello! Thanks for your answer but it always returns true. So I can't check visibility my category
Does your question have anything whatsoever to do with the Revit API?
If so, would you care to explain what?
wrote: Could someone recommend a good example.
The DockableDialogs example in the SDK is WPF. It's good in that it shows the various API's necessary to build an external app, but it was not designed to be a great WPF reference.
We are trying to solve that problem right now. I will update the thread if we find more convenient solution.
When I imported a rvt file to my project. All materials and some of the menus have now changed to Spanish. I prefer not having to learn a new language so how do I get all back to English? In settings it is still English chosen. Is this a bug or what is the function of suddenly half the software change language?
Hi
Try this:
Right click on your Revit shortcut on your desktop and choose "Properties"
At the end of target cell, set "/language ENU"
You can replace ENU to other languages you like e.g. CHT for Chinese Traditional or JPN for Japanese.
Thanks for the tip.
But I tried that already. It was ENU as it is supposed to be.
This must be something else.
Every Revit database element has a name.
You apparently imported a Spanish model.
The elements it contains apparently have Spanish names.
A solution might be to rename all the elements appropriately.
By the way, are you doing anything programmatically yourself, or just using the standard Revit user interface?
If you are not doing anything programmatically, this is not the best place to ask such a question.
Please note that this discussion forum is dedicated to programming Revit using the Revit API.
Therefore, you cannot expect an answer to a question such as yours relating to installation, product usage or end user support issues here.
You should try one of the non-API Revit product support discussion forums instead for that:
The people there are much better equipped to answer your question than us programming nerds.
If you are doing it programmatically, please be aware that the Revit API hardly ever supports any functionality that is not also available in the user interface.
Therefore, if the UI does not support this, the API will probably not do so either.
So, it will always help to research the optimal manual approach to a solution first, before attacking the task programmatically.
I hope this clarifies.
Thank you for your cooperation and understanding.
Best regards,
Jeremy
That would be great! Thank you!
I see some results seaching for 'revit api wpf sample':
https://duckduckgo.com/?q=revit+api+wpf+sample
Haven't checked them out in detail myself.
Some are shared by The Building Coder as well:
https://thebuildingcoder.typepad.com/blog/wpf
It would indeed be great to have one single recommended best-practice starting point.
Have you checked out Ali Asad's suggestion?
https://thebuildingcoder.typepad.com/blog/2019/01/room-boundaries-to-csv-and-wpf-template.html#3
This StackOverflow thread discusses how to create one starting with the DockableDialogs SDK sample:
https://stackoverflow.com/questions/40096793/best-starting-point-for-wpf-revit-add-in
Cheers,
Jeremy
Hi
You can use Wall.Orientation to get the external face normal vector which will help you get the face you want.
Please refer this for more information.
Hi
I'm not sure about what's non-uniform ceiling.
But if you want to get the ceiling height, instead of using dividing the volume by the room's area, try to use the built-in parameter "CEILING_HEIGHTABOVELEVEL_PARAM" of the ceiling to get the height.
Hope this helps.
Hi
From your descriptions I can only guess it's because Revit does not support for multi-threading which means that before you finish your current work, you can not do anything further.
The above is just my guess, if you can provide more details(your code or a reproducible sample file), we can know better of your problem.
Hello Everyone!
How to access the ActiveUIDocument from outside of the Execute method?
My goal is to get data from my active document, with a Button Click on a windows form.
Currently the method which is called by the button click, is within the same class, where the form was initialized.
I was able to do it in macro editor (ThisDocument tdoc = new ThisDocument -> tdoc.ActiveUIDocument).
How to access it with a plugin?
Hi, all
I am confused on how to use the Revit API to get the "LocationCurve" origin coordinates of the wall. As the picture shows, I want to get the value of the "origin" parameter.
Thanks for any help.
There is always the possibility, for example, if there is a method in the ASM (which both Revit and Dynamo use, hence why in theory, anything Dynamo can do, can also be done via the Revit API) which isn't publicly exposed.
You are wrong about claiming there is no way to perform a face v face intersection via the Revit API and return a curve. You need to use the Face class Intersect method which sets the curve via its out parameter as shown below.
To establish if two faces intersect, simply evaluate the FaceIntersectionFaceResult enum which this method returns. A face > face intersection doesn't make much sense, I think you mean trim a face with another face, like punching a hole through a source face and cutting face? You cant do that in Dynamo or Revit, but there are still workarounds.
Ultimately this all boils down to the right tool for the right job: Revit and Dynamo have their uses, but there are far more powerful computational and parametric design tools out there with highly evolved geometry engines which may suit your workflow better. Grasshopper/Rhino or Microstation/GC are two alternatives which each have their own pro's and con's but underpinned by highly sophisticated geometry engines which easily surpass Revit/Dynamo.
I suggest you use https://www.revitapidocs.com and search for what you need so you can ascertain whether a function in Dynamo is in the Revit API (99% of cases the answer is yes), or if you just have a general goal, its always a good start point.