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

Re: Execute External Command via Button on a Form

$
0
0

Okay, thanks a lot, I just have one question, I tried changing the code to an external event by doing this:

 public class ExternalCommandFloorThickness : IExternalEventHandler
    {
        public Result Execute()
        {

            UIApplication uiapp = ExternalCommandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;
            Document doc = uidoc.Document;

but I get the error:

 

in the line: UIApplication uiapp = ExternalCommandData.Application;


Re: Execute External Command via Button on a Form

$
0
0

I just saw that the screenshot did not attach, so here is the error:

Capture.PNG

"A clas contains reference to Application and View which are needed by external command.

An object reference is required for the non-static field, method, or property 'ExternalCommandData.Application'"

Executing Move from Dock Pane Will Not Let You Complete the Command

$
0
0

Good morning,

 

We recently extended the functionality of our dock pane to include the ability to execute Revit commands.

 

All seemed to be working well until we hit commands like Move and Rotate. The commands execute just fine, CanPostCommand returns true, and the command actually executes (you can tell because the cursor changes).

 

However, it will not let you complete the command.

 

I have attempted many different ways to try and correct this, such as using SendKeys or the WinApi to send the keyboard shortcuts to execute instead of PostCommand to no avail. I even went so far as to send the keystrokes directly to the main window handle, or setting the main window to foreground before executing and nothing. Those didn't work at all. I found that sendkeys is a known issue in 2019, but it did not work for me in any version.

 

PostCommand works, it just won't let you finish.

 

I have created a bare bones dock pane example to show this. And this issue appears to happen on any command that involves rotation or movement, i'm not sure how to explain it, but it does not affect commands like Create Similar or the like.

 

This test plugin will add a tab to the ribbon called "Test Dock Pane Issue", with one button to show or hide the pane if it disappears. But it should pop right up the first time it is registered.

Then, click on any element, use Move from the dock pane, and you will see that you cannot complete the Move command.

 

Attached are the solution, and the plugin files for 2018-2020 if you just want to test it without looking at the code first.

 

Help! I hope i have not stumbled upon an issue with the API. 

 

I know AdWindows is not supported, and although i tried that route this example does not use that so i should be able to get support for this issue with PostCommand.

 

Thanks

Re: Get definition of built-in parameter with-out having an element

$
0
0

Thanks  for your help

 

But how can I know the ParamaterType for example Length, Number, Integer, Text, Area, Yes/No, etc?

Revit Bim model - Geotechnical site investigation

$
0
0

Hello,

I am investigating uncertainty in geotechnical BIM. I'm trying to create a geotechnical model for a site. The current aim is to create boreholes on a site then create the layers in the soil from the boreholes. To investigate uncertainty im creating a model in Revit, currently most of the advice from my online research is to use Autodesk Civil 3D for geotechnics but I'm only using revit. My current plan for the model is to create the boreholes as new component loaded families with each individual borehole being a new family and having each layer of the borehole have its out subcategory. Once I've got all my boreholes (approximately 15 boreholes) I can place the on the site of a new project (on architectural). The create layers of the soil similar to the attached images. For each of these layers I was thinking of making individual levels so I can use multiple topographies across the layers.

 

I have limited experience with revit so any advice about my plan or advice on actually completing this would be appreciated. 

 I'm currently struggling to create the boreholes with its multiple layers of different catagories

Re: Revit Bim model - Geotechnical site investigation

$
0
0

Is this a Revit API issue, or an end user question?

 

Are you doing anything programmatically yourself, or just using the standard Revit user interface?

 

If you are not doing anything programmatically, this is not the best place to ask such a question.

 

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: Revit Bim model - Geotechnical site investigation

$
0
0

Thanks for the advice will repost in the appropriate board 

Marine Construction

$
0
0

Marine construction focuses on anything built along the shoreline. These structures help to prevent damage to the property located near the water. Common structures for this type of construction include bulkheads, seawalls, retaining walls, and revetments.


Cannot get rebar number

$
0
0

Hi, I have a problem with obtaining rebar number via Revit API. I can spot Rebar number in Revit Lookup tool, but when I retrieve all of the parameters in API by rebar Parameters property I cant find it there. Any attempt to get its value end with null reference exception. What am I missing? 

Re: Cannot get rebar number

Re: Executing Move from Dock Pane Will Not Let You Complete the Command

$
0
0

I might have just stumbled upon something...

 

Looking into it now.

Re: How to get the Intersection between a curve and a plane

$
0
0

If the curve is a line, there is an alternative approach which may be easier to implement with Revit API. For a given line and a plane, let's call the intersection point P. Now if you project the line onto the plane, the result passes through P.

So you can easily project two points of the line onto the plane -Plane.Project() - create another line that passes through those two points - Line.Create(Un)bound() - and the last thing you have to do is to find the intersection of those two lines - Line.Intersect()

 

Something like this:

// Plane plane
// Line line
UV uv1, uv2 = new UV();

plane.Project(line.Origin, out uv1, out double d);
plane.Project(line.Origin + line.Direction, out uv2, out double b);

XYZ xyz1 = plane.Origin + (uv1.U * plane.XVec) + (uv1.V * plane.YVec);
XYZ xyz2 = plane.Origin + (uv2.U * plane.XVec) + (uv2.V * plane.YVec);

Line projectedLine = Line.CreateUnbound(xyz1, xyz2 - xyz1);

IntersectionResultArray iResult = new IntersectionResultArray();
if (line.Intersect(projectedLine, out iResult) != SetComparisonResult.Disjoint) return iResult.get_Item(0).XYZPoint;

Problems setting all family instance symbols to another family symbol

$
0
0

Hi! I am trying to swap all instances of family symbols in a project with a different family and its symbol which is selected from a UI by the user. The code seems to execute with no exceptions but no changes are taking place to the model even after committing the transaction. I'm not sure if this is possible, but it seems like a typical use case so I'm sure its something simple in my code. Appreciate any assistance anyone can provide!!

 

 public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;
            Document doc = commandData.Application.ActiveUIDocument.Document;

            FormPopulatePlbgFixtures form = new FormPopulatePlbgFixtures(doc);
            var result = form.ShowDialog();


            if (result == DialogResult.OK)
            {
                var trans = new Transaction(doc, "Family Swap");
                trans.Start();

                try
                {
                    //Loop through each Swap Family
                    for (var i = 0; i < form.SwapReturnValues.Count; i++)
                    {
                        var selectedFamily
                            = new FilteredElementCollector(doc)
                                .OfClass(typeof(Family))
                                .Cast<Family>() // family
                                .FirstOrDefault(x => x.Name.Equals(form.SwapReturnValues[i].swapFamilyName));

                        //var famElem = doc.GetElement(selectedFamily.Id);

                        FamilySymbol selectedFamSymbol = null;

                        //Get all family symbols
                        var familySymbolIds = selectedFamily.GetFamilySymbolIds();

                        //Match the selected swap family symbol
                        foreach (var id in familySymbolIds)
                        {
                            var familySymbol = selectedFamily.Document.GetElement(id) as FamilySymbol;


                            // Get family symbol name
                            if (familySymbol.Name == form.SwapReturnValues[i].swapFamilyType)
                                selectedFamSymbol = familySymbol;
                            break;
                        }

                        //Loop through each arch family instance
                        foreach (var f in form.SwapReturnList)
                        {
                            var fam = f.FamilySymbol.Family;
                            var fi = f.FamilyInstance;
                            var fs = f.FamilySymbol;

                            //set family and symbol
                            var famTypeId = doc.GetDefaultFamilyTypeId(selectedFamSymbol.GetTypeId());
                           
                            var typename = fs.GetType().FullName;

                            var subtrans = new SubTransaction(doc);
                            subtrans.Start();
                           
                            fs = selectedFamSymbol;
                            subtrans.Commit();

                            
                        }
                    }
                    doc.Regenerate();
                    trans.Commit();
                    return Result.Succeeded;
                }
                catch (Exception e)
                {
                    trans.RollBack();
                    return Result.Failed;
                }
            }

            return Result.Cancelled;

        }

Re: Executing Move from Dock Pane Will Not Let You Complete the Command

$
0
0

Unfortunately that was a dead end, although i did find out how to get all the images for the revit commands on the dock pane now 🙂

UIAutomation gave me the same results in this issue. I was able to invoke the command but unable to finish it.

Re: Problems setting all family instance symbols to another family symbol

$
0
0

Hi  ,

1)choose the element type

2)get the element type id

3)choose the element to which you want to change the type

4) using ChangeTypeId ,change the element type.

ElementId typeid;//get the element typeid
Element e;//choose the element
e.ChangeTypeId(typeid);//change the typeid

Re: Revit 2019 Addin Manager cannot load external dll

$
0
0

I've actually found that you can resolve this error in some cases by attempting to load the missing dll as another command through the Addin Manager. Although the support dll will fail to load any commands, I've found that after it fails, the error is resolved.

 

This method feels a bit dirty and I don't think it will work for all cases, but it may serve as a quick option when you just want to move on in your testing. 

Re: Cannot get rebar number

$
0
0

Yes, I did, I know that Rebar number is TextParameter. In my case I'm passing rebar from previous method so I don't need to filter it, the problem is that it rebar number parameter seems to be missing in rebar object.

 

My work flow looks like this, I create rebar in Revit API, then I want to create rebar container out of those bars. But I also want to put rebar number parameter into one of rebar container parameters, so I look for it... and I'm failing. If I only create bars in Revit API then I'm able to find its rebar number by Revit Lookup, so I'm kind of sure that bar and its number was created properly. Here is the code:

public static Autodesk.Revit.DB.Structure.Rebar CreateRebar(int hostNumberId, XYZ normal, Autodesk.DesignScript.Geometry.PolyCurve polyCurve)
{
//Some logic here
return rebar;
}
public static Autodesk.Revit.DB.Structure.RebarContainer CreateContainer(Autodesk.Revit.DB.Structure.Rebar[] rebar,int hostIdNumber)
{
ParameterSet set = rebar[0].Parameters;
Parameter param = rebar[0].get_Parameter(BuiltInParameter.REBAR_NUMBER);
//Create container etc.
return container;
}

And here is screenshot showing bars created in RevitAPI:

RevitLookUp.png

 

EDIT: "Numer zbrojenia" means rebar number in polish ;]

Curve Array vs. CurveLoop

$
0
0

Dear all,

 

Could someone elaboorate why there are two classes that do quite similar things:

CurveArray vs. CurveLoop 

And why revit api asks for a curveArray when generating e.g. a Wall or a Floor but not a CurveLoop where esentialy the definition in the documentation of a curveloop would be  more in line with the requirments by the newfloor methode....

 

???

room boundingbox and offset problem

$
0
0

hello,

For our Revit addin (in c#), I need to get some room boundingbox (based on model values)
For this I use element.Get_BoundingBox function, but it seems , the Z coordinates do not respect the base and limit offsets of the room ,
for example, a room has a level to 0 coordinate, a base offest equal to -400.0, in this case the box.min.z value is 0 in place of -400.0

is it normal and I am missing some logical aspect , or is it a Revit problem ?

How can I find the right values (I know how to compute them by recalculating from levels and offsets , but I prefer if I can have the result by a direct api call)

attached, a demonstration c# project and a test rvt file inside

 

thanks in advance

Luc

Re: Only one instance addin plugin

$
0
0

Sorry, meant this.


Possibility run only one instance of plugin on PC.

If user run revit 2018 and 2019 on same PC allow run only one instance of plugin.

 

thx.

Viewing all 66690 articles
Browse latest View live


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