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

回复: Ducts are disconnected after changing size using code

$
0
0

Hi ,

 

Thank you so much for your great help and suggestion. I just revise the code and successfully to finish my code Smiley Very Happy. Here is the screenshot of the result, amazing fast auto routing for duct: 

Capture.PNG

Best Regards,

 

Cherry Truong


Re: Split wall

$
0
0

Hi @BenoitE&A,

 

It looks what you need is the feature Split Element. As the other post mentions, the API is not yet exposed. 

https://forums.autodesk.com/t5/revit-api-forum/split-wall-using-revit-api/td-p/6562014

 

While with current API, it is feasible to do something. I did some investigation today and made it working with Line Wall. The code tells the logic how to split the wall by the middle point. you could apply it with the point you calculated. 

 

It will need more work with other types of wall: Arc, Eclipse, Spline, Nurbus, but I'd think the logic would be similar. Hope it could help you a bit. 

 

btw,  what  shared is about aligning wall to a given curve, which is also interesting to know.

 

 

 void splitWall(Document rvtDoc)
        { 
            Transaction trans = new Transaction(rvtDoc);
            trans.Start("mysplitwall");

            FilteredElementCollector FEC = new FilteredElementCollector(rvtDoc).OfCategory(BuiltInCategory.OST_Walls);
            IList<ElementId> wallids = FEC.ToElementIds() as IList<ElementId>;

            foreach (ElementId wallid in wallids)
            {
                Element e = rvtDoc.GetElement(wallid);
                if (e.Location == null) continue;
                Wall wall_1 = e as Wall;

                Curve wallCurve = ((LocationCurve)wall_1.Location).Curve;
                double stParam = wallCurve.GetEndParameter(0);
                double endParam = wallCurve.GetEndParameter(1);

                XYZ stPoint = wallCurve.Evaluate(stParam, false);
                XYZ endPoint = wallCurve.Evaluate(endParam, false);

                //assume split the wall in the middle point
                double midParam = (endParam - stParam) / 2.0;
                XYZ midPoint = wallCurve.Evaluate(midParam, false);

                if (wallCurve is Line)
                {
                    Line newLine1 = Line.CreateBound(stPoint, midPoint);

                    //becasue we will update endpoit of original wall,
                    //check if the endpoint has been joined with another successive wall 
                    //disallow the join, in order to update the endpoint
                    if (WallUtils.IsWallJoinAllowedAtEnd(wall_1, 1))
                        WallUtils.DisallowWallJoinAtEnd(wall_1, 1);

                    //align original wall with the new curve
                    ((LocationCurve)wall_1.Location).Curve = newLine1;

                    //because the successive wall will also update endpoint (its first segment)
                    //create new wall on the second segment of the first wall directly
                    //then the new wall and successive wall will be joined automatically 
                    Line newLine2 = Line.CreateBound(midPoint, endPoint);
                    Wall wall_2 = Wall.Create(rvtDoc, newLine2, wall_1.LevelId, false);

                }
                else if (wallCurve is Arc)
                {

                }
                else
                {
                    //other types of Walls
                }
            }
            trans.Commit();
        }

 

 

 

 

Re: Not able to add views on sheet correctly - viewport

$
0
0

Any news on this? Having Similar Problems. Would love to hear from you.

Re: Temporarily highlight an element (without selecting)

Re: Creating a C++ plugin

$
0
0

Happy New Year!

 

Any luck yet your end?

  

I heard back from the development team, and they say: 

  

I was able to create a working C++ add-in project. Things to remember:

 

  • You need C++/CLI support. This is an optional install in VS2017 when installing C++.
  • You need to use 64-bit configuration.

 

That seemed to be it for the settings required.

 

The project was created as New Project -> Visual C++ -> CLR -> ClassLibrary.

 

Best regards,

 

Jeremy

 

Re: Creating a C++ plugin

$
0
0

Hi Jeremy,

 

Hope you enjoyed the holidays.  Thank you so much for following up on this. you saved me hours (if not days) of head scratching. I just got back from the holidays myself and gave your solution a shot. The problem appeared to be in the project type. My non-working project was created as: Visual C++ > Windows Desktop > Dynamic-Link Library (DLL). Using CLR ClassLibrary fixed the issue (New Project -> Visual C++ -> CLR -> ClassLibrary) fixed the issue

 

I will update this thread if I ran into any issue since the reason that I am creating a C++ plugin instead of C# is to use some unmanaged C++ libraries. 

 

Best,

Get host geometry in family document

$
0
0

I am looking for a way to identify the extrusion in a family document that is the default host geometry. I would like to hide it in a view.  The hiding I can do.  I just can't find a way to identify the extrusion.  I am using the Lookup Utility, but can't seem to find the difference between user created extrusions and the one that exist in a face based family document by default.  There must be something glaringly obvious i am missing.

Re: Get UniqueId of deleted element within dynamic updater? (with feature reques

$
0
0

I know this is not a solution that we all hoped for, but since half a decade has passed and we still don't have this implemented in Revit by the Autodesk team, I thought I do my best to expand on Troy's solution: 

First we need to override the "delete" command: 

        private static void OverrideDelete(UIApplication app)
        {
            try
            {
                var commandId = RevitCommandId.LookupCommandId("ID_BUTTON_DELETE");
                if (commandId == null || !commandId.CanHaveBinding) return;

                var binding = app.CreateAddInCommandBinding(commandId);
                binding.Executed += OnDelete;
            }
            catch (Exception)
            {
                //ignored
            }
        }

Once we have that we need a handler for the new method that we will fire up instead: 

        /// <summary>
        /// Handler for when user deletes an element from the model.
        /// </summary>
        private static void OnDelete(object sender, ExecutedEventArgs e)
        {
            try
            {
                var deleted = new Dictionary<string, Element>();
                var deletedIds = new List<ElementId>();

                var selection = new UIDocument(e.ActiveDocument).Selection.GetElementIds();
                using (var trans = new Transaction(e.ActiveDocument, "Delete"))
                {
                    trans.Start();

                    // (Konrad) First we need to find out what Elements will be deleted if we were to proceed.
                    // Remember that Elements in Revit are intertwined so deleted one, might affect others.
                    // In SubTransaction we can delete them, collected actual affected Ids, and then undo.
                    using (var subTrans = new SubTransaction(e.ActiveDocument))
                    {
                        subTrans.Start();

                        if (selection.Any())
                        {
                            deletedIds = e.ActiveDocument.Delete(selection).ToList();
                        }

                        subTrans.RollBack();
                    }

                    // (Konrad) Now that we have actual affected Ids of deleted elements, we can get their UniqueIds
                    // We need these UniqueIds.
                    if (deletedIds.Any())
                    {
                        foreach (var id in deletedIds)
                        {
                            var el = e.ActiveDocument.GetElement(id);
                            if (el == null) continue;

                            if (!deleted.ContainsKey(el.UniqueId)) deleted.Add(el.UniqueId, el);
                        }
                    }

                    // (Konrad) Finally we actually delete the selected elements so that user doesn't notice that
                    // we have hijacked the Delete method.
                    e.ActiveDocument.Delete(selection);

                    trans.Commit();
                }
            }
            catch (Exception)
            {
                //ignored
            }
        }

So this is a little bit more detail on the method that Troy suggested. I have tested it a little, and it works for my use case. 

Good luck! 


Mechanical System Type

$
0
0

 

Mechanical System Type.PNG

Hello

Can someone tell me which path to take for (read of get) this value. see image above

 

Dockable Pane Render Bug on Revit 2017 or Earlier

$
0
0

I have a WPF UI with a DataGrid hosted in a DockablePane.  It looks great in Revit 2018 and above, but in 2017 the DataGrid extends beyond the right side and bottom, which makes my bottom button bar invisible.  To make matters worse, it only affects some machines,  and only 2017 or below.

 

This is not a WPF layout issue, as the Page renders perfectly when launched outside of Revit, or when using 2018+.

 

 

Are there any known render issues for WPF contents extending beyond the extents of the dockable panels??  

 

Re: Get UniqueId of deleted element within dynamic updater? (with feature reques

$
0
0

 Thanks for expanding on the original idea. Code looks great.

回复: Mechanical System Type

$
0
0

Hi :

Try this property:

Duct.MEPSystem.Name

Or you can get further information via:

Duct.MEPSystem.GetTypeID()

Use the following method to retieve the mep system type element:

Document.GetElement( *mep system ID* ) as MEPSystemType

Suggest you install a handy addin :

RevitLookup

 

Re: Mechanical System Type

$
0
0

Hi ,

You can get the DUCT SYSTEM TYPE by using the below code

Duct d;
d.get_Parameter(BuiltInParameter.RBS_DUCT_SYSTEM_TYPE_PARAM).AsValueString()

If this helped solve your problem please mark it as solution, so other users can get this solutions as wellSmiley Happy

回复: Ducts are disconnected after changing size using code

$
0
0

Hi:

So great to hear that you accomplished it.

What's more, I do remember that there is a similar solution in Revit SDK samples.

It should be stored in %intallation directory%/Revit 201X SDK/Samples/AutoRoute/

It also implement an experimental automation to route Duct network from a Mechanical Facility to several Duct Terminals.

Re: Get host geometry in family document

$
0
0

Hi,

just a guess.

The Extrusion that has the lowest ID value of all.

 

Revitalizer


Re: SAT Family Import UI works, API doesn't

$
0
0

Hi ,

I don't know exactly what you want...But to import SAT file into the family document you can use SATImportOptions.

String sat_path="YOUR SAT FILE PATH";
SATImportOptions SAT_IOption = new SATImportOptions();
SAT_IOption.VisibleLayersOnly = true; SAT_IOption.Placement = ImportPlacement.Centered; SAT_IOption.ColorMode = ImportColorMode.Preserved; SAT_IOption.Unit = ImportUnit.Default; //get the view for the placement of imported SAT file(i.e REF.LEVEL) FilteredElementCollector view_collector = new FilteredElementCollector(doc).OfClass(typeof(View)).WhereElementIsNotElementType(); IList<ElementId> view_ids = view_collector.ToElementIds() as IList<ElementId>; View view = null; foreach (ElementId view_id in view_ids) { View v = doc.GetElement(view_id) as View; if (v.Name.Contains("Ref. Level")) { view = v; } } //import the .SAT file to family template file ((i.e)Metric Generic Model.rft) doc.Import(sat_path, SAT_IOption, view);

 

Localization website

set door frameMeterial property in type parameter

$
0
0

We are trying to change the door frame meterial property,where we can change  family instance  frame meterial  property ,the changes are not applied to door. So we decided to set the family symbol property .but builtin parameter for Door_Frame_Meterial  returns Object reference not set to an instance of an object Error.

Code Snippet:

---------------

public void doorprop(document doc1)

{

using (Transaction t=new Transaction(doc1,"doorProp"))

{

t.start();

FilteredElementCollector fec=new FilteredElementCollector(doc1)

                                                     .ofClass(typeof(FamilySymbol))

                                                     .ofCategory(BuiltinCategory.OST_Doors);

/*FilteredElementCollector fec=new FilteredElementCollector(doc1)

                                                     .ofClass(typeof(FamilyInstance))

                                                     .ofCategory(BuiltinCategory.OST_Doors);*/

foreach(Element door in fec)

{

if(door.Name=="0915 x 2134mm")

{

string value0="Glass";

Parameter p1=door.get_Parameter(BuiltInParameter.DOOR_FRAME_MATERIAL);

p12.AsValueString();

p12.Set(value0); /*i get error here*/

value0="";

}

}

t.commit();

}

 

}

suggest some solutions.

thankyou;

with regards;

somu.

 

how to handle "missingmemberexception: name" with revit python shell

$
0
0

hello all,

 

im new to programming and the revit API so maybe the solution is quite easy but i couldnt find a good topic about how to handle .net exceptions with python. 

Capture.JPG

You can see that the python shell is giving me an exception missingmemberexception: Name. In this case i just want him to move on to the next item its iterating through and ignore the exception. 

 

Is this possible? are there any good tutorials on how to handle .net exceptions with python?

 

 

 

Re: How to modify some parameters value (like "Luminous Flux") inside

$
0
0

I have just bumped into exactly the same problem. Did you find a solution or workaround since then?

Viewing all 67020 articles
Browse latest View live


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