If there is certain elements that you need in order for your addin to work, wouldnt it be better to just check for those elements?
I dont think there is any way to check by code if there has been a purge in the model.
If there is certain elements that you need in order for your addin to work, wouldnt it be better to just check for those elements?
I dont think there is any way to check by code if there has been a purge in the model.
yes I did in C:\ProgramData\Autodesk\Revit\Addins\2016
I have found a solution by myself. If all layers of the compound structure have different widths it's possible to identify the associated parts using the part parameter DPART_LAYER_WIDTH. If at least to layers have the same width I use another approach:
Setup:
In my project directory I have a reference set up to use System.ComponentModel.Annotations v4.2.1.0 and it is being copied to local.
In my app.config file I have the following binding redirect for System.ComponentModel.Annotations: "<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />"
My project is set up as an application plugin that launches my application when a button is clicked from the ribbon panel in the addins section of revit. I know that I have that set up correctly because it has run correctly prior to my latest addition (which involves Entity Framework reading/writing to a database). I have a class that extends DBContext stored in the variable _context. When I first initialize _context I immediately run the command _context.Database.Migrate(). Upon running this command I get the error below. This issue only occurs when i run this application through revit. I have a standalone application that runs outside of Revit and makes the exact same calls that doesn't have any problem finding/loading System.ComponentModel.Annotations. I'm not sure why my application can't load this dependency when running through Revit, but can through my standalone project (both of which have identical references). Does anyone have any ideas on how to fix this?
System.IO.FileNotFoundException
HResult=0x80070002
Message=Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Source=Microsoft.EntityFrameworkCore
StackTrace:
at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.CoreConventionSetBuilder.CreateConventionSet()
at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateConventionSet(IConventionSetBuilder conventionSetBuilder)
at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder, IModelValidator validator)
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel()
at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.GetRelationalService[TService](IInfrastructure`1 databaseFacade)
at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate(DatabaseFacade databaseFacade)
at BT.Data.Repo.FacilityRepo.RunMigrations() in C:\Views\Plugins\LifeSciences\BT.Data.Repo\FacilityRepo.cs:line 66
at BT.Controller.Controller.RunMigration() in C:\Views\Plugins\LifeSciences\BT.Controller\Controller.cs:line 118
at BT.Controller.Controller..ctor() in C:\Views\Plugins\LifeSciences\BT.Controller\Controller.cs:line 83
at BT.Controller.Interfaces.SController.get_Controller() in C:\Views\Plugins\LifeSciences\BT.Controller\Interfaces\SController.cs:line 30
at BT.LifeSciencesPlugin.Views.LifeSciencesView..ctor() in C:\Views\Plugins\LifeSciences\BT.LifeSciencesPlugin\Views\LifeSciencesView.xaml.cs:line 66
at BT.LifeSciencesPlugin.LifeSciencesPlugin..ctor() in C:\Views\Plugins\LifeSciences\BT.LifeSciencesPlugin\LifeSciencesPlugin.cs:line 77
After basically resetting the project and reloading all the references, my exception went away. Not sure why exactly, but I must have had some reference set up wrong, or was including the wrong version of a reference.
I have a curious Revit API Question I was wondering if you can help me with. I would like to have the initial dialog box from the Splash screen open up an API Command. For example, if I click on New Project (My browser / plugin starts up) instead of the traditional template request.
Do you know what API or method I could use to create such an application?
Thank you very much!
- Kevin
I use similar code and verified with your plan A, there is an exception saying "The direction of dimension is invalid", the reason is the input value "dimension" should be inside the plan of doc.ActiveView. So I changed the input value dimension of the following code line to line1.GeometryCurve as Line, it works, but you just need to offset Z of the dimension line to make it looks good.
Dimension dim = doc.Create.NewDimension(doc.ActiveView,dimensionline1.GeometryCurve as Line, ra);
Let me know if it works for you.
Hi,
Is it the same revit version in two computers?
I got one issue when I build an application with 2016 reference dll and then run in 2017 revit version.
Thanks,
Eden Oo
Hi I've spend days on this, and read the Magic Voodoo page several times. And am desperate, I really need to know the details of how you accomplished Dimensioning walls in RevitLink.
Hi
In your addin file,check whether you gave new path of your .dll file in <Assembly> path</Assembly> and
check for the Class name also <FullClassName>Class name</FullClassName>
Dear Kevin,
Thank you for raising this issue here in public after our private email conversation.
I cannot read the file that you attached named 'image.jpeg'. It does not appear to be a JPEG file.
I do not think what you are after is covered by the Revit API.
You may be able to implement something based on the Windows and .NET API, watching for specific events on specific window classes or their buttons. Windows can trigger an event before a specific form is displayed, and you might be able to hook into that.
Once Revit actually loads and opens a project file, there are Revit API events that you can register for and react to.
However, afaict, you wish your add-in to become active before any document has been selected and opened.
I hope this helps.
Cheers,
Jeremy
Hi,
We need to change the Primary design option of a Design Option set via API. We know that it's being tracked as part of ticket CF-66. Can we know what the status of it is?
Is this the same issue as in your other thread?
https://forums.autodesk.com/t5/revit-api-forum/fails-to-load-dependencies/td-p/8227232
In that case, can we assume that it is now resolved as well?
Thank you!
Cheers,
Jeremy
I want to retrieve all warnings in the document in the same order as they are represented in the warnings dialog.
My macro is going to let the user type in the warnings number from the dialog and isolate those elements etc.
Is there any logic to the order of the warnings in the warning dialog that I'm not seeing?
nothing wrong with that because if it not correct Revit shows error msg for missing file
the new pass and assembly name are correct
both are Revit 2016 but application created in windows 10 and the other computer is windows 7
dose that effect??
I want to add some attributes into Space's property to define the owner information of this space, how can I achieve this using Revit's API or can I override the class and using it in my own project?
Hi
Could you please send your Visual Studio project file and addin manifest file to investigate?
(Here your files are not confidential)
Dear Philippe and Floris,
Thank you for your query.
There are a couple of places to look whenever you have a Revit API question.
One of the first, obviously, is an Internet search.
I searched for 'revit api determine sheet size'.
The very first link that is displayed leads to The Building Coder discussion on Determining Sheet Size:
http://thebuildingcoder.typepad.com/blog/2010/05/determine-sheet-size.html
It describes the external command CmdSheetSize in The Building Coder samples:
https://github.com/jeremytammik/the_building_coder_samples
I tested running that command in Revit 2019.1 on a sample project I have containing three sheets, and it reports the following:
1 title block element type retrieved by filtered element collector: Title block element type A0 metric 28295 Title block instances: Sheet number A101 size is 1188 x 840 (3.9 x 2.76), id 333539, type A0 metric 28295 Sheet number A102 size is 1188 x 840 (3.9 x 2.76), id 334896, type A0 metric 28295 Sheet number A103 size is 1188 x 840 (3.9 x 2.76), id 334924, type A0 metric 28295 View sheet instances: View sheet name Level 1 number A101 id 333535 View sheet name Level 2 and 3D number A102 id 334892 View sheet name Room 2 on Level 1 number A103 id 334920
Does that include all the information you need?
Please always perform your own search and testing before raising such questions here in the forum. It will save time and effort both for yourself and others.
Thank you!
Best regards,
Jeremy
It is simple: You have to rearrange the string a little to match the format:
"fb332d47-8286-4829-bd40-46c26de8ebac-000258d5:0:RVTLINK:2796184:1:SURFACE/5"
NOT
"fb332d47-8286-4829-bd40-46c26de8ebac-000258d5:RVTLINK/fb332d47-8286-4829-bd40-46c26de8ebac-000258d4:2796184:1:SURFACE/5"
myCeiling = linkedDoc.GetElement(new ElementId(2796176)) as Ceiling; Reference top = HostObjectUtils.GetBottomFaces(myCeiling).First(); if (inLinked) top = top.CreateLinkReference(myRevitLinkInstance); string myConvertToStableRepresentation = top.ConvertToStableRepresentation(doc); ReferenceArray _resArr = new ReferenceArray(); // List<Reference> myListReference = new List<Reference>(); for (int ip = 0; ip < 2; ip++) { int index = 1 + (ip * /*_gridCount*/2 * 2); //string myCTSRwith = myConvertToStableRepresentation + string.Format("/{0}", index); List<string> myListString = myConvertToStableRepresentation.Split(new char[] { ':' }).ToList(); int lenLST = myListString.Count; string myCTSRwith = myListString[0] + ":0:RVTLINK:" + myListString[lenLST - 3] + ":" + myListString[lenLST - 2] + ":" + myListString[lenLST - 1] + string.Format("/{0}", index); Reference HatchRef = null; try { HatchRef = Reference.ParseFromStableRepresentation(doc, myCTSRwith); } catch { } if (HatchRef == null) continue; _resArr.Append(HatchRef); }
There are two main ways to add data to a Revit element:
Extensible storage and shared parameters.
The latter is optionally displayed in the property palette, can be made accessible to the end user for reading and writing, and is honoured by Revit, e.g., for scheduling.
The latter is only visible to the add-in that creates it and is much more modern and efficient.
Please refer to The Building Coder topic group for more information on extensible storage:
http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.23
Cheers,
Jeremy