Link of the video with the 3 examples: Link
Re: WPF window loses control when Revit API displays an error message
Re: get category visibility
sorry but i do not see how this relevent?
i do not want to SetVisibility only to know if it is On/Off
Re: Opensource API for reading IFC Files..
Dear Jon,
thank you for your support . you are absolutely correct, after installing the VS 2015 error removed .
sincerely yours,
Mehdi
Re: Can Revit add-in update itself?
Hi Guillaume,
thank you for the response, yes, this is what I am thinking about. The questions is, is the plugin itself allowed to do that, or shall we implement an external updater application that takes care of the file replacement. I would like to check, if someone has ever faced this question and advice the right path to approach it.
Thank you,
Martin
can't run analyse in cloud
can't run analyse in cloud. I have a licence (revit 2017) but when I try to use "anlyse in cloud" it says to me that I have no authorization.
How can I run this? Do I have to buy an additional license (to use the cloud, not robot or revit structure)?
Thanks to any help!
Luciana
Placing a new family on a face in Python
Hi,
I'm putting together a routine to place face based families on a face of a generic object.
Looking at the API documentation, there is a method for doing this which look the one the to use:
NewFamilyInstance(Face, XYZ, XYZ, FamilySymbol) Inserts a new instance of a family onto a face of an existing element, using a location, reference direction, and a type/symbol.
I'm using Python through dynamo, I select the family symbol using a FilteredElementCollector.
When I run the code, it fails with the NewFamilyInstance with the error: TypeError: expected XYZ, got Surface
import clr clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import * # Import RevitNodes clr.AddReference("RevitNodes") import Revit clr.AddReference('RevitAPI') import Autodesk from Autodesk.Revit.DB import * # Import Revit elements from Revit.Elements import * # Import DocumentManager clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager import sys sys.path.append('C:/Program Files (x86)/IronPython 2.7/Lib') from math import atan2, radians, cos, sin, degrees, sqrt, ceil doc = DocumentManager.Instance.CurrentDBDocument uiapp = DocumentManager.Instance.CurrentUIApplication app = uiapp.Application adoc = doc.ActiveView facetoplace = IN[0][0] familysym = IN[1] #NewFamilyInstance(Face, XYZ, XYZ, FamilySymbol) Inserts a new instance of a family onto a face of an existing element, using a location, reference direction, and a type/symbol. #Find family Symbol familysymname = "Brick" familysymtouse = 0 collector = FilteredElementCollector(doc).OfClass(FamilySymbol) famtypeitr = collector.GetElementIdIterator() famtypeitr.Reset() for item in famtypeitr: getfelement = doc.GetElement(item) getffamily = getfelement.Family getfname = getffamily.Name if getfname == familysym: familysymtouse = getfelement b1 = doc.Create.NewFamilyInstance(facetoplace, XYZ(1,0,0), XYZ(0,0,0), familysymtouse) OUT = [familysymtouse]
This is the Dynamo part:
Whats going wrong, I believe I'm giving all the required inputs?
Thanks.
Re: OpenAndActivateDocument() fails
A Dynamo script runs on the active document. I do not know what Dynamo is doing behind the scenes but this may be a transaction issue or Dynamo will not allow you to change the document while it's processing. Below are the remarks from the help file:
This method, if successful, changes the active document. It is not allowed to have an open transaction in the active document when calling this method. Consequently, this method can only be used in manual transaction mode, not in automatic mode. Additionally, this method may not be called from inside an event handler.
I've always created a Revit addin whenever I need to change the active document to batch process.
Re: Direction of Reference (Reference Plane or Reference Line)
I use FAIR59's code
for check the direction, i use this
FamilyInstance familyInstance = element as FamilyInstance; IList<Reference> familyInstanceReferences = familyInstance.GetReferences(FamilyInstanceReferenceType.StrongReference); foreach (Reference familyInstanceReference in familyInstanceReferences) { if (DimensionUtils.GetReferenceDirection(doc, familyInstanceReference).ToString() == XYZ.BasisX.ToString() || DimensionUtils.GetReferenceDirection(doc, familyInstanceReference).ToString() == XYZ.BasisX.Negate().ToString()) { firstArray.Append(familyInstanceReference); } }
Re: Programatically uncheck "V/G Overrides Model" parameter in a view
Thank you very much, FAIR59. The SetNonControlledTemplateParameterIds() method is exactly what I needed.
I was able to apply this to all view templates in the current document with the following code:
UIApplication application = commandData.Application; Document doc = application.ActiveUIDocument.Document; FilteredElementCollector views = new FilteredElementCollector(doc).OfClass(typeof(View)); View template = null; View cur = null; try {
foreach(var current in views.Reverse()) { cur = current as View; if (!cur.IsTemplate) { if (cur.ViewTemplateId != ElementId.InvalidElementId) template = doc.GetElement(cur.ViewTemplateId) as View; else continue; ElementId VGModel_ID = ElementId.InvalidElementId; List<ElementId> nonControledParams = template.GetNonControlledTemplateParameterIds().ToList(); foreach (var id in nonControledParams) { if (id.IntegerValue == (int)BuiltInParameter.VIS_GRAPHICS_MODEL) { VGModel_ID = id; break; } } using (Transaction t = new Transaction(doc, "Change Template")) { t.Start(); if (VGModel_ID == ElementId.InvalidElementId) { nonControledParams.Add(new ElementId(BuiltInParameter.VIS_GRAPHICS_MODEL)); template.SetNonControlledTemplateParameterIds(nonControledParams); } t.Commit(); } } } } catch(Exception e) { TaskDialog.Show("Exception", e.Message); }
Check family types before loading.
My company has a folder for job specific families(project Library) in each of our project directories. I am working on an addin that allows the user to load families directly from that library. I have that part of it working fine. I am looking for a way to compare types within the family/and project and load the missing types. Is this possible? Below is my code
public static Element FindElementByName(Document doc,Type targetType,string targetName) { return new FilteredElementCollector( doc ).OfClass( targetType ).FirstOrDefault<Element>(e => e.Name.Equals( targetName ) ); } public void cx() { UIDocument uidoc= this.ActiveUIDocument; Document doc= uidoc.Document; string CentralModelLocale = Path.GetDirectoryName(ModelPathUtils.ConvertModelPathToUserVisiblePath(doc.GetWorksharingCentralModelPath())); //set initial directory for Project library string targetpath=string.Concat(CentralModelLocale,"\\Project Library"); OpenFileDialog opd = new OpenFileDialog(); opd.InitialDirectory=targetpath; opd.Multiselect=true; opd.Filter = "Revit Families (*.rfa)|*.rfa" ; if(opd.ShowDialog() == DialogResult.OK) { string[] familyfiles=opd.FileNames; foreach (string families in familyfiles) { Family family = FindElementByName(doc,typeof(Family),families)as Family; if( null == family ) { // It is not present, so load the file using (Transaction t = new Transaction(doc)) { t.Start("Loading Family"); doc.LoadFamily(families); t.Commit(); }} } }} } }
Re: Can Revit add-in update itself?
If you are using Revit to trigger the addin update, and the addin you intend replacing is already loaded, I don't believe that there is a way to unload any loaded addins. You will get a file-in-use error if attempting to overwrite the .addin or .dll files. You could maybe write a trigger file to be used after Revit is closed. For what it may be worth, I use the following to run a batch file, and then copy/overwrite the same batch file when it finishes running. Maybe this could be incorporated. I would be very interested in your (or other) solution. Dale
// start process Process process = new Process(); ProcessStartInfo startInfo = process.StartInfo; startInfo.FileName = lstrBatFileNameFull; startInfo.Arguments = args; // to copy batch file after it has closed process = System.Diagnostics.Process.Start(startInfo); process.WaitForExit(); if (process.HasExited) { File.Copy(lstrBatFileNameFullSource, lstrBatFileNameFullTarget, true); }
How to export decal textures
We're working on a revit plugin that exports revit view into a special OBJ format. Some Revit models contain decal images. We checked the API document and have not found anything about extracting decal textures from Revit file. Is there anyone that happen to know how? Please advise.
BTW, we are working on Revit 2017. Thanks so much.
Printing code in c#.Net to print the sheets in Revit
Hi,
I want to build the plug-in to print the sheets using c#.Net code.
I am using Revit 2017.
Please help ASAP.
Thank You
Sheet Printing Code in C# for Revit 2017
HI,
I want to build the plug-in to print the particular sheet in c# for Revit 2017.
I haven't got any solution to do like this.
In Details:
I want to call the printer on Addin click and print the sheets in pdf format at a particular location.
Please help ASAP.
Thank you.
Re: Revit 2018 API - Undocumented Changes - Have you found any?
Hi Matt,
Thanks for your suggestion, but not sure how the new style would be loaded by customers.
The problem persists in 2018.1, so I guess my post didn't get through to the developers - I thought this Forum was monitored by them?.
The annoying part is although I only create the custom style if it isn't present in the model, users are going to end up with 100's of dimension styles called "SecretInternalLinAngDimStyle5473j6181" - because this is not the name I gave it.
I would appreciate this being passed on to the developers with most urgency. Meanwhile I will check if we are part of the beta program.
Best regards
Paul
Re: get category visibility
Hi,
in your solution, you mention an exception:
"but i get exception saids "Object reference not set to an instance of an object.""
I just explained why it happened, thought would be interesting.
When using another than the current API version (2018), it would be useful to mention that, avoiding people to give hints which won't work in older versions without modifications.
You ask:
"i would like you also to know how to check if an Element is inVisibile by VG Filter and WorkSet"
Sorry, I don't have an answer now, perhaps one of the other readers may pick it up ?
You should create a new forum thread since this one is already marked as solved and does not reflect your new question in its title, so people may overlook it.
Revitalizer
Re: Family origin point coordinates , not room aware point inside a family doc
Hey Fair59, do you know of a way to get the insertion point from a FamilySymbol? Perhaps the insertion point can just be a vector. For example, if the ReferencePlanes intersect at XYZ(-1,-1,-1), that will be the insertion point.
When you import the FamilySymbol as a FamilyInstance, the object will be XYZ(1,1,1) farther away from X(0,0,0) compared to if the insertion point was XYZ(0,0,0).
Anyways, I know I can calculate the insertion point by looking at the ReferencePlanes of the original family. However, it can be inconsistent, I think. Or at least it can be somewhat complicated.
One reason is that the insertion point doesn't always only depend on the intersection of ReferencePlanes. I think Z depends on Ref. Level as well. Wall-Hosted Families use the wall for the X insertion.
Also, I noticed there's a way to make it so you have two parallel ReferencePlanes that Defines the Origin. Normally, setting one as Defines Origin, removes it from the other parallel ReferencePlanes. Here are the steps to do this:
1) Make a non-parallel ReferencePlane
2) Make this non-parallel ReferencePlane Defines Origin. At this point nothing else is parallel to this plane so Defines Origin is not removed form anything else.
3) Rotate the non-parallel plane to be parallel to another plane that Defines Origin. Now two parallel planes Defines Origin.
Even though two parallel planes Defines Origin, Revit seems to use the rotated plane as the one that Defines Origin.
Also, I prefer not to have to open the original Family Document just to get the insertion point.
When I'm in the upper level family that imports the original Family, the only way I can think of to get the insertion point is the following:
1) Place FamilyInstance at XYZ(0,0,0)
2) Get familyInstance.Location()
Anyways, I prefer not to have to place it before finding out the insertion point. I want to place it at a location based on the insertion point. Yes I can do steps 1 and 2 then move it, but I prefer to place it correctly the first time.
How to trace back which view the imported or linked drawing is saved?
HI ~
How to trace back which view the imported or linked drawing is saved?
Request master help answer.
Thanks!
How to completely remove an imported drawing from a revit model?
HI ~
How to completely remove an imported drawing from a revit model?
I have used this code but did not clean it up.
"Deleting DWG Imports and their categories – Boost Your BIM"
https://boostyourbim.wordpress.com/2013/09/16/deleting-dwg-imports-their-categories/
Request master help answer.
Thanks!
Re: How to completely remove an imported drawing from a revit model?
public static Result DeleteImportInstances(Document pDoc, out int pintDeletions) { Result lresResult = Result.Cancelled; pintDeletions = 0; IList<ElementId> Ids = new List<ElementId>(); foreach (ImportInstance ii in new FilteredElementCollector(pDoc) .OfClass(typeof(ImportInstance)) .Cast<ImportInstance>() .Where(i => i.IsLinked == false)) { ElementId Id = ii.Id; if (!Ids.Contains(Id)) Ids.Add(Id); } using (Transaction tr = new Transaction(pDoc, "DeleteImportInstances")) { tr.Start(); pDoc.Delete(Ids); tr.Commit(); lresResult = Result.Succeeded; pintDeletions = Ids.Count; } return lresResult; }