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

Re: CAD import layer-split geometry

$
0
0

Hi, again, I'll try.

 

Always try it first in the UI, if it's possible there then there might be a chance it's also possible in the API.

If it's not possible in the UI, then it's also not possilbe (or at least not supported/advised) in the API.

 

DWG link or import:

A. we can delete a layer by selecting import > Query command > pick dwg element > delete.

trouble here is that if the link is reloaded the delete elements are back!

Not sure if it's possible in API, can't see a method for it (GeometryElement is a displayed result of the original so no use for deleting elements)

B. Delete the subcategory of the DWG? > results in the element(s) no longer having a "layer" so doesn't work in UI.

 

Can't you turn visibility off for the layer or edit the DWG itself, or better split in 2 dwg the one to keep and the to use for the addin, and unload/detach when ready?

 

- Michel


Re: Ignore warning message contraints on EditFamily

$
0
0

A test I done with the RevitModelChecker :

It detects an error on EditingFamily like me : but,  he is able to dismiss warnings...

So I suppose it is possible with the API...

But How to?

 

screenshot_41.png

Re: Revit 2021 Version Information Issue

$
0
0

I get from Revit 2021:

 

.VersionNumber: 2021
.VersionBuild: 21.0.0.383
.VersionName: Autodesk Revit 2021

 

I've for a long time used .VersionNumber and that has always been a year. Not sure about version build but 21.0.0.383 is more akin to what I think of as a version build than 20200220_1100(x64).

 

20200220_1100(x64) is a product version and you can get from the assembly information of Revit.exe.

Re: Revit 2021 Version Information Issue

$
0
0

Yes, But... In all other previous versions of Revit 20XX the .VersionBuild has had this similar format e.g. 20200220_1100(x64), and now, for some reason it does not, so why the change with Revit 2021 version information, was it intentional, or is it an oversite, and will be changed back to the way is was in a future release? that is the real question.

Re: Ignore warning message contraints on EditFamily

$
0
0

Hi Pierre,

 

you can use an Event to prevent the failure. Here is an example :

 

[Transaction(TransactionMode.Manual)] public class Command : IExternalCommand { public Result Execute(ExternalCommandData extCmdData, ref string msg, ElementSet elmtSet) { UIApplication uiapp = extCmdData.Application; UIDocument uiDoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uiDoc.Document; try { string strName = "demo_family_error";//set your Name List<FamilySymbol> lstSym = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast<FamilySymbol>().Where(x => x.FamilyName.Equals(strName)).ToList(); Family fam = lstSym.First().Family; app.FailuresProcessing += App_FailuresProcessing; try { Document docFam = doc.EditFamily(fam); docFam.Close(false); } catch (Exception ex) { string strM = ex.Message; } } catch (Exception e) { msg = e.Message; return Result.Failed; } return Result.Succeeded; } private void App_FailuresProcessing(object sender, FailuresProcessingEventArgs e) { FailuresProcessingEventArgs fpArgs = e as FailuresProcessingEventArgs; FailuresAccessor accessor = fpArgs.GetFailuresAccessor(); FailureHandlingOptions op = accessor.GetFailureHandlingOptions(); op.SetClearAfterRollback(true); accessor.SetFailureHandlingOptions(op); fpArgs.SetProcessingResult(FailureProcessingResult.ProceedWithRollBack); } }

 

😉

Modifying document from app.DocumentOpened simply will..not..work

$
0
0

I've been looking at this until I'm blue.  This makes zero sense.  I can modify (add elements) to my document on a per-sheet basis, but the code only works if I kick it off from an IExternalCommand, not any event handlers from IExternalApplication.  I run the exact same code in both cases and only one works.  No exceptions or errors are reported.  However when running from the event handler, the element ids of the new elements become invalid and nothing appears on the sheet.  At first I thought it was due to the missing attributes for my application class, but adding those did nothing.  Please help.  this is urgent.

 

 

[Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] public class EventHandlers : IExternalApplication { public Result OnStartup(UIControlledApplication application) { try { application.ControlledApplication.DocumentOpened += new EventHandler<DocumentOpenedEventArgs>(Application_DocumentOpened); } catch { return Result.Failed; } return Result.Succeeded; }

 

 

 

private void Application_DocumentOpened(object sender, DocumentOpenedEventArgs args) { Document doc = args.Document; if(doc.IsReadOnly) Logger.log("Warning: Document is read only!"); if(doc.PathName.EndsWith("input.rvt")) { supressDialogs = true; FilteredElementCollector coll = new FilteredElementCollector(doc); List<int> referenceMarkerIds = new List<int>(); var all = coll.OfClass(typeof(ViewSheetSet)).ToElements(); foreach(ViewSheetSet vss in all) { foreach(View view in vss.Views) { Logger.log("Processing .. " + view.Name); if(view is ViewSheet) { Logger.log("Adding markers .. " + view.Name); var ids = ReferencePlacement.placeMarkers(doc, view as ViewSheet); referenceMarkerIds.AddRange(ids); foreach(int id in ids) Logger.log("added .. " + id.ToString()); } } } String basePath = Directory.GetParent(doc.PathName).FullName; ReferencePlacement.writeElementIDs(basePath, referenceMarkerIds); } }

 

 

Pertinent section of placeMarkers call (again, this works when I run it from a command)

 

using(Transaction t = new Transaction(doc, "Create reference shape")) { t.Start(); DirectShape ds = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_GenericModel)); ds.ApplicationId = "Application id"; ds.ApplicationDataId = "Geometry object id"; ds.SetName(name); ds.SetShape(result.GetGeometricalObjects()); t.Commit(); var status = t.GetStatus(); elem = ds; } return elem;

 

Re: Modifying document from app.DocumentOpened simply will..not..work

$
0
0

Looks like my code was hitting an exception (something reported when running form a command but silently ignored when running from the event handler).  

Re: Modifying document from app.DocumentOpened simply will..not..work

$
0
0

Hi,

Handling the error solved it?

 

Else according to the documentation it should be possible: DocumentOpened Event :

"Remarks
This event is raised immediately after Revit has finished opening a document. It is raised even when document opening failed or was cancelled (during DocumentOpening event).

Handlers of this event are permitted to make modifications to any document (including the active document), except for documents that are currently in read-only mode...."

 

Also check the status DocumentOpenedEventArgs.Status = Succeeded

The code inside the DocumentOpened event also works if run from Command (you only state it with the PlaceMarkers)

 

- Michel


Re: Modifying document from app.DocumentOpened simply will..not..work

Re: Can not get UIView of PreivewControl

$
0
0

Hello.

You cannot get the UIView because you tried to get it before loading the instance of PreviewControl.

It can help you:

 

var previewControl = new PreviewControl(document, viewId); previewControl.Loaded += (sender, args) => { previewControl.UIView.ZoomToFit(); };

 

Heating and cooling load Analytical Surfaces with Revit API

$
0
0

Is possible to extract heating and cooling load Analytical Surace with Revit API and export it to Excel? I wish to extract parameters like Wall Area and direction, Glazing Area.
The main goal is to extract the data of wall area and direction from Revit and import to other software to conduct heat load estimation(By HAP, excel sheet).

furthermore, the gbXML from Revit does not work, the walls seemed to broken up too much in the Revit model when i open using HAP or CVS since The Analytical Model that is produced from gbXML differs from the Physical Model that is in Revit Views. I believe the best way is to find an approach to extract data by API.

 

 

Analytical Surfaces.JPG

 

 

 

 

Python in Dynamo video tutorial(Dynamo之Python编程教学视频)

$
0
0

     In order to help engineers learn  how to use Python in Dynamo, I recorded a set of  Python in Dynamo tutorial videos,which inculde Python 、 Revit api and Dynamo node, Welcome to the videos!

Youtube: https://www.youtube.com/playlist?list=PLYOpJJEZoCNqJOMmR5KWnzXRqLL1CvTDY

or search "Dynamo之Python编程" in Youtube

My email:1056291511@qq.com

      为了帮助工程人员学习如何在Dynamo中使用Python编程,录制了一套Dynamo中Python编程教学视频,涉及到如何学习Python,如何调用Revit api和原生节点,欢迎观看!

b站:https://space.bilibili.com/38879307/video

邮箱:1056291511@qq.com

Re: Garage door opener

WindowsForm dynamic update

$
0
0

Hi,

I've built a Windows Form in Revit, that displays some information on the project when a button is clicked.

So far, I've used the DocumentChanged() event to determine if something has changed since the last time I clicked the button.

 

What I'd like to achieve is a Form where it allows to dynamicallyselect and modify objects in Revit, and display the updated information in the Form, without having to exit and restart the Form.

 

My current Form is modeless, meaning it doesn't allow any actions in Revit while it is active. I understand that I might need to use a modal form, but I'm not sure if that will allow me the same functionality.

 

I've tried reading the information about ExternalEvents and Modeless_Dialogue etc., but it's very hard for me to understand, and no matter how much I read into it I quickly get confused as to which method will help me achieve my goal.

 

Any advice? I'd appreciate even a direction on which specific things to read up on.

Thanks

Re: Display an image loaded in memory via the .NET API.

$
0
0

Helo Jeremy,

 

Thank you for the reply. Since I am not very familiar with Revit yet, may I please ask a followup question on the subject...?

By what you are saying, I am I to assume that regarding images, I can only replicate the behaviours described in this section of the knowledge base more or less? https://knowledge.autodesk.com/support/revit-products/learn-explore/caas/CloudHelp/cloudhelp/2018/ENU/Revit-Model/files/GUID-FDBF9893-B13A-4B6E-BF9E-2C38D8B684C1-htm.html

Coming from an AutoCAD programming background there are custom entities in ObjectARX and Overrules in .NET, which can help us introduce *some* new functionality. Are there no corresponding APIs for Revit?

Regards,
Aristotelis.


Re: Adding analytic cconstruction options via an additional .xml

$
0
0

They reply:

 

Thanks for the info. So as I understand, Fredrik want to add his own Analytical Constructions to be available for selection in Revit Window and Door Types. I will forward the request.We did, however, opened up Analytical Properties to be user defined for Window and Door Types in Revit 2020. Maybe that can help? Fredrik could provide a set of predefined types in a Revit template?

 

analytical_props_windows.png

 

Modify Model Lines of an Existing Floor Slab

$
0
0

Dear Revit API,

I need to change the borders of a Floor Slab automatically. The ID of the element should not change (I can't delete / recreate another Floor). I tried to capture the underlying ModelCurves and change them but I get errors. I wonder, is it possible what I try to do and what is the best way ?

Thank you

Re: Garage door opener

Dependency Version Conflict (Assembly Binding for .DLLs)

$
0
0

I would like to see if anyone else has experienced difficulty with running an addin that references a newer version of an assembly that Revit itself already uses as a dependency?

 

Because of data management needs in my application, I would like to use Newtonsoft.Json version 12.0.3.  However, when I run the debugger, I observe that by the time my addin has loaded, it has already bound to version 9.00.1.19813.

 

I can only assume the reason for this is that Revit 2020 already references a 2016 version of Newtonsoft.json, as shown in the program files and indicated by the debugger.  As a result, none of the traditional fixes or remedies for alternate assembly binding appear to work.  Even creating a Directory.Build.props file and setting the MSBuild properties 

 

<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects><GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>

does not seem to resolve the reference to the latest version.  It still throws an exception indicating that it has bound to version 9.  As a result, I cannot get the functionality I need because it didn't exist in version 9.

 

Has anyone else encountered this problem or a similar scenario (screenshots attached for clarity)?

The document was opened detached, so saveascentral must be set to true?

$
0
0

Hello,

I am trying to open a BIM 360 model and then do a save-as to make a local copy of the cloud model that is NOT attached to the central model at all. Just a local copy.

I am having an issue that I can't seem to understand...

This is an extract from my code (the variables are already defined elsewhere, don't worry, they aren't what are causing the issue):

revitModelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath(projectGuid, modelGuid); OpenOptions openOptions = new OpenOptions(); openOptions.AllowOpeningLocalByWrongUser = true; openOptions.Audit = true; uiapp.OpenAndActivateDocument(revitModelPath, openOptions, true, myCallback); SaveAsOptions saveOpts = new SaveAsOptions(); WorksharingSaveAsOptions worksharing = new WorksharingSaveAsOptions(); worksharing.SaveAsCentral = false; saveOpts.SetWorksharingOptions(worksharing); saveOpts.OverwriteExistingFile = true; doc.SaveAs(savePath, saveOpts);

 The code opens and activates the BIM 360 document just fine without any problems. The problem is that last line, when I run it I get this error:

"The document just had worksharing enabled or was opened detached, so WorksharingSaveAsOptions.SaveAsCentral must be set to true for SaveAs."

 

That doesn't make sense to me... Of course the document was opened detached, precisely BECAUSE I wanted the option to save it as local (and not central)... Is there a reason the API won't allow me to do this? Is there a different way I should try to code this? 

I'm probably missing something obvious but this seems an impossible problem to solve. Any help is very much appreciated!!

Thank you!

Viewing all 66666 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>