I am trying to align my basement and 1st-floor plans so that the exterior of my basement wall lines up with the exterior core face of my 1st-floor plan match. They seem to be linked somehow because whenever I move one floor plan it shifts the other the same amount. I have tried turning on underlay and aligning walls, I have tried moving the plans with dimensions locked and unlocked, nothing I do seems to work. Does anyone have suggestions? I have attached a couple of photos with overlay on between the two floor plans. In the second photo I show a dimension of 1 1/8" which is the amount the two plans are offset.
Floor Levels will not align
OpenFileDialog problem
Hi everyone,
I am creating an add in to batch insert Revit links to models.
The first task is to add selected models path to listbox1 as following image:
and following is my Code:
private void bt_AddModel_MouseClick(object sender, MouseEventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); if (openFileDialog1.ShowDialog()==DialogResult.OK) { string[] files = openFileDialog1.FileNames; foreach(string s in files) { listBox1.Items.Add(s); } } }
But the problem is, after selecting all the files and click OK, the Winform add in close as well instead of add the files list into listbox.
If anyone have experience in this, please help me.
Thank you so much for your help :).
Best Regards,
Cherry Truong
Re: How to modify the rebar bar segments dimensions?
I guess that earlier should use the property ShapeId. This property is marked as deprecated since 2018.
Best regards
creating walls and getting the levels
public List<Wall> CreateWalls()
{
double width = ElementModification.ElementModification.mmToFeet(10000.0);
double depth = ElementModification.ElementModification.mmToFeet(5000.0);
Level level1 = (Level)ElementFilter.ElementFiltering.FindElement(
m_rvtDoc, typeof(Level), "Level 1 ", null);
if (level1 == null)
{
TaskDialog.Show("Revit Intro Lab", "Cannot find (Level 1). Maybe you use " +
"a diffrent template? Try with DefaultMetric.rte.");
return null;
}
im trying to learn how to creat wall but there is some problem. plz help
when i debug this code, it on Revit shows up Null command "Cannot find (Level 1). Maybe you use a diffrent template? Try with DefaultMetric.rte. and i also using DefaultMetric.rte.
how to solve this problem?
Re: creating walls and getting the levels
I'm not sure but I would use FilteredElementCollector to Levels and then - depending on which wall type you need - use the the Wall.Create Method:
(Document, IList(Curve), ElementId, ElementId, Boolean).
Edit: If you want to adjust height and offset you should use another method:
(Document, Curve, ElementId, ElementId, Double, Double, Boolean, Boolean)
See www.revitapidocs.com for more information.
Re: creating walls and getting the levels
Hi,
Did you check your Revit document (rvt) contains view names "Level 1" and "Level 2"?
You can check that in your project browser
Re: creating walls and getting the levels
Hi
try using the below code
To get the level
FilteredElementCollector COllector = new FilteredElementCollector(doc).OfClass(typeof(Level)); var ele = from Element in COllector where Element.Name == "Level 1" select Element; Level lev = ele.Cast<Level>().ElementAt<Level>(0);
To create the wall
using (Transaction walltrans = new Transaction(doc)) { walltrans.Start("transaction name"); XYZ start; XYZ end; Line geoline1 = Line.CreateBound(start1, end1); Wall w1 = Wall.Create(doc, geoline1, lev.Id, true); walltrans.Commit(); }
Re: creating walls and getting the levels
Hi
If it solves your issue could you please accept it as solution!
Re: Conduit Fitting re-assign Level
Dear Studio A,
Thank you for your query.
What happens when you perform the same operation manually in the user interface?
In general, the Revit API functionality will [pretty closely replicate the UI functionality with both its desired and possibly undesired features.
What happens if you disconnect the neighbouring conduits before executing the modification?
I hope this helps.
Best regards,
Jeremy
Re: Conduit Fitting re-assign Level
Sorry, duplicated the answer due to network problems... and no possibility to delete the wrong answer here... please ignore.
Re: OpenFileDialog problem
Inside your Windows form, store the selected files in a list that is accessible via a public member function, e.g., SelectedFiles.
Then, access those files and process them after the form has been confirmed and closed:
class Command : IExternalCommand { Result Execute(...) { FileSelectionForm form = new FileSelectionForm(); if (form.ShowDialog()==DialogResult.OK) { string[] files = form.SelectedFiles; foreach(string s in files) { process file } } } }
Lots of samples by The Building Coder demonstrate how to display a Windows form prompting a user for input in an external command and process the results afterwards:
https://www.google.com/search?q=ShowDialog&as_sitesearch=thebuildingcoder.typepad.com
Cheers,
Jeremy
Re: Get the Floor Area above a Room
Dear Sicheng Zhu,
Thank you for your interesting query.
For a completely generic solution, it seems to me that you will require a 2D Boolean operation.
The Revit geometry API does not provide that built-in, but you can easily integrate an external 2D Boolean operations library:
http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.2
Once you have the 2D Boolean operations in place, you can easily create two overlapping horizontal polygons:
- Retrieving the room boundary curves and creating a contiguous curve loop from them.
- Projecting the floor boundary curves, projecting them onto the room top surface, and creating a contiguous curve loop from them.
Here is an example of projecting and transforming a polygon in Revit:
http://thebuildingcoder.typepad.com/blog/2008/12/polygon-transformation.html
This assumes your wall segments are straight, and not curved.
If they are curved, I would suggest using the curve tessellation provided by the Revit geometry API to convert them to straight segments.
With two overlapping 2D polygons and a 2D Boolean operation in place, I hope your problem is perfectly solved in a totally 'common' way.
Best regards,
Jeremy
Re: Floor Levels will not align
Is this a Revit API issue, or an end user question?
Are you doing anything programmatically, or just using the standard Revit user interface?
If you are not doing anything programmatically, 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:
https://forums.autodesk.com/t5/revit-api-forum/this-forum-is-for-revit-api-programming-questions-not-for/td-p/5607765
The people there are much better equipped to answer your question than us programming nerds.
I hope this clarifies.
Thank you for your cooperation and understanding.
Best regards,
Jeremy
Re: Get the Floor Area above a Room
Thank you so much, Jeremy. It seems that it can work well. I will try it later!
How to handle the firing of a Revit command with CommandEventArgs C#
I would like to be able to register which commands are being used within the Revit aplication C#.
To do so, I am trying with the CommandEventArgs.
I know that it is possible to register when the RevitCommandId is the same as e.g. "ID_OBJECTS_WALL" by using the ExecutedEventArgs:
AddInCommandBinding importBindingID_OBJECTS_WALL = application.CreateAddInCommandBinding(RevitCommandId.LookupCommandId("ID_OBJECTS_WALL"));
importBindingID_WINDOW_CLOSE_HIDDEN.Executed += new EventHandler<Autodesk.Revit.UI.Events.ExecutedEventArgs>((sender, arg) => application_Command(sender, arg, "ID_OBJECTS_WALL"));
However, I would like to register ANY command that the user fires and thus, it's not very feasible to use the ExecutedEventArgs with AddInCommandBinding for all Revit commands (+1200).
To do so, I am trying with the CommandEventArgs:
UIControlledApplication.CreateAddInCommandBinding(RevitCommandId) += new EventHandler<Autodesk.Revit.UI.Events.CommandEventArgs>(application_Command);
But I am not sure which namespaces and classes to use to successfully handle this event, I'm not sure if I should use the UIControlledApplication, I'm not sure if I should use the CreateAddInCommandBinding. I have been looking at the Revit Api Docs but I couldn't figure it out.
Is it possible to register ANY command with the CommandEventArgs or the ExecutedEventArgs?
How can I achieve that?
Any help would be appretiated.
Re: iUpdater triggers with sync
I tested the code in a macro, and had access to the UIApplication. But I guess it depends on where you are constructing the Updater object.
In the OnStartUp method of an ExternalApplication you have the UIControlledApplication object, which inturn gives the ControlledApplication object, that you can use to subscribe to the FailuresProcessing event.
public class ExternalApplication : IExternalApplication { private TestUpdater m_Updater; public Autodesk.Revit.UI.Result OnStartup(UIControlledApplication application) { m_Updater = new TestUpdater(application.ActiveAddInId,Guid.Empty, application.ControlledApplication); } } public TestUpdater(AddInId id, Guid p_Guid, ControlledApplication ctrlapp) { // your updater ini code ctrlapp.FailuresProcessing += uiapp_Application_FailuresProcessing; }
Send Value From Winform back to Dynamo Zero Touch (Node) Class that called it
To simplify the situation at hand, as the title suggests:
I would like to know the best practice to send the resulting value (whether it is a user selected value from a combobox or a list of values/elements/etc from a List Checkbox or TreeView) back to the Dynamo Zero Touch Class/Method that has called it. I am familiar with calling another class with the values from a winform but again what I want is for the result to return back to the class/method that called it.
So in example:
Winform Code:
internal partial class RvtForm : System.Windows.Forms.Form {
//Does some procedure populating a combobox or List Checkbox or Tree View for user to select values from
private void button1_Click(object sender, EventArgs e)
{
//At this point how do I send the Selected Value back to value() that called this winform?
this.Close(); }
}
Dynamo Zero Touch Code:
public class Interface { public static List<some identifier> value() { RvtForm form1 = new RvtForm(); System.Windows.Forms.Application.Run(form1); some identifier result = value(s)/element(s)/etc from form1; return result; } }
I would need to know this because the Zero Touch Node will run the winform, the user will select some values from the winform, click a button to confirm, which will trigger to close the winform, I would need the values then to become the output value of the Zero Touch Node to move on to the next node in the sequence of the overall Dynamo Script. Any ideas? Thank you!
Re: Made a new 3DView. It's empty. Why?
Thank you for the interesting discussion, and especially
I summarised it for posterity here:
http://thebuildingcoder.typepad.com/blog/2018/09/floor-area-above-room-and-mysterious-hide.html#3
Cheers,
Jeremy
Execute external command in taskdialog
Is there any possibilities to execute the external command in task dialog command link.
Below is the code which i am using to display the task dialog.
TaskDialog task_dialog_ = new TaskDialog("Eror..!");
task_dialog.MainInstruction = "Could not find BIM Standards";
task_dialog.MainContent = "User needs to enable the BIM Standards";
task_dialog.CommonButtons = TaskDialogCommonButtons.Close;
task_dialog.DefaultButton = TaskDialogResult.Close;
task_dialog.FooterText = "Contact for the provider";
task_dialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Click here to Install the BIM standards");
TaskDialogResult task_show_ = task_dialog.Show();
if (TaskDialogResult.CommandLink1 == task_show)
{
// how to run the existing external command
}
Load IFC from Addin external command
Hi all,
I am using Revit 2019 SDK and working with C#. I have read all existing forum topics related to OpenIFCDocument API and external blogs/websites referencing this API.
I have the following task:
1. manually start Revit and create a new empty project
2. create an Addin which loads an IFC file from local disk
To accomplish the above, I created an Addin and implemented the IExternalCommand interface. I can see and use my Addin in Revit (TaskDialog.Show works just fine).
My problem is the following:
When I call commandData.Application.Application.OpenIFCDocument("C:\\test.ifc", ifcImportOptions), Revit starts to load the IFC (I use IFCImportAction.Open), shows the loading progress bar, takes a minute or so to load, and when it is done loading, the model is not visible.
What am I missing here? Why is the model not visible (if I open the same model manually in Revit via IFC Open UI button, model is loaded ok and is visible)?
I'd appreciate any hints which could help me resolve this.
Thank you.