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

Re: Grids Off-Axis

$
0
0

Indeed Jeremy, I did miss that one, and it is precisely what is required. When it is run on a vertical grid, it works as expected. I modified your code so that the start and end points are given the same X value (i.e. truly vertical) to remove the microscopic "off-axis". It fails here:

// "The curve is unbound or not coincident with the original one of the datum plane"

grid.SetCurveInView(DatumExtentType.Model, view, newLine);

 

To be clear, if my code is run on a vertical grid (i.e. not really effecting a change, but still functionally the same), it completes without error. 

 

The main change I made to your code is:

XYZ newStart = newXYZ(start.X, start.Y, start.Z);

XYZ newEnd = newXYZ(start.X, end.Y, end.Z);

 

A test file with faulty vertical grids can be found here:

Off-Axis Test File

 

For completeness, here is my code:

// only fixes vertical or horizontal - IsVertical
        public static Result FixGridAxisByPick(UIDocument uidoc, bool IsVertical, out string pstrMsg)
        {
            Document doc = uidoc.Document;
            Selection sel = uidoc.Selection;
            Autodesk.Revit.DB.View view = doc.ActiveView;
            string lstrMsg = "Off-Axis Error Results:";

            ISelectionFilter f = new JtElementsOfClassSelectionFilter<Grid>();
            Reference elemRef = sel.PickObject(ObjectType.Element, f, "Pick a grid");
            Grid grid = doc.GetElement(elemRef) as Grid;

            IList<Curve> gridCurves = grid.GetCurvesInView(DatumExtentType.Model, view);

            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("Modify Grid Endpoints");

                foreach (Curve c in gridCurves)
                {
                    XYZ start = c.GetEndPoint(0);
                    XYZ end = c.GetEndPoint(1);

                    MessageBox.Show("start: "
                        + start.ToString()
                        + Environment.NewLine
                        + " end: "
                        + end.ToString());

                    //XYZ newStart = start + 10 * XYZ.BasisY;
                    //XYZ newEnd = end - 10 * XYZ.BasisY;
                    XYZ newStart = new XYZ(start.X, start.Y, start.Z);
                    XYZ newEnd = new XYZ(start.X, end.Y, end.Z);

                    MessageBox.Show("newStart: "
                        + newStart.ToString()
                        + Environment.NewLine
                        + " newEnd: "
                        + newEnd.ToString());

                    Line newLine = Line.CreateBound(newStart, newEnd);

                    // *** fails on this line ***
                    // "The curve is unbound or not coincident with the original one of the datum plane"
                    grid.SetCurveInView(DatumExtentType.Model, view, newLine);
                }
                tx.Commit();
            }
            pstrMsg = lstrMsg;
            return Result.Succeeded;
        }

I am not asking you to debug for me, but I am not able to interpret the exception message. Thanks for any advice. Dale 

 


Re: HELLOWORLD WALKTROUGH LESSON - USING TRY CATCH - NEED SOME GUIDANCE

$
0
0

Hi akosi,

 

Try-catch statements are used to "try" and execute a piece of code and then "catch" any exceptions which are generated if the code fails to execute correctly.  This means that instead of your application crashing, you can display an error message or handle the exception appropriately.  The basic premise works like this:

 

 

 

try
{
	// Attempt to execute this code
}
catch
{
	// catch and deal with exceptions here
}

 

 

Further information can be found HERE, in Microsoft's C# language reference.  As for the example you are working through, you can add a try catch to your code as follows:

 

 

[Transaction(TransactionMode.Manual)]
class HelloWorld : IExternalCommand
{
    public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
    {
        UIApplication uiApp = commandData.Application;
        UIDocument uiDoc = uiApp.ActiveUIDocument;
        Application app = uiApp.Application;
        Document doc = uiDoc.Document;

        try
        {
            // Display Hello world! in TaskDialog
			TaskDialog.Show("Try Catch Example", "Hello world!");
        }
        catch (Exception ex)
        {
            // Code did not execute successfully, display exception error
			TaskDialog.Show("Exception Caught", "Exception: " + ex);
			// return Failed
            return Result.Failed;
        }

		// Code executed successfully, return Succeeded
        return Result.Succeeded;
    }
}

Hope this helps.

 

Roppa

 

 

UI coordinates

$
0
0

Hi All,

 

how can I get the visible coordinates of the end user (North & East) from Location property.

 

here is my trial to convert which is retrieve wrong coordinates.

 

                                LocationPoint loc = familyInstance.Location as LocationPoint;
                                XYZ dpPoint = loc.Point;
                                Transform trf = familyInstance.GetTotalTransform();
                                XYZ uiPoint = trf.OfPoint(dpPoint);

Thanks,

Re: UI coordinates

Re: Display REVIT floor plans on a HTML web page along with custom attributes

$
0
0

HI, 

You should check out the Forge Platform.. 

It will help you solve this case.. 

 

The viewer works perfectly well with Revit models.. 

 

 

Re: Display REVIT floor plans on a HTML web page along with custom attributes

$
0
0

Thank you for pointing me to Forge platform.

 

Please one last question:

 

Would you know if my customer would have to pay more if they want to embed their designs in web pages. These are web pages that will be used within the company's intranet?  Customer already has Autocad 2015.

 

Thanks,

Saurabh

 

Re: Display REVIT floor plans on a HTML web page along with custom attributes

$
0
0

Someone need a subscription on Forge, but i don't know all the details.. 

 

Re: HELLOWORLD WALKTROUGH LESSON - USING TRY CATCH - NEED SOME GUIDANCE


Re: Create wall based window family with non rectangular cut

$
0
0

Now I found a solution:

 

I do not use void extrusions because the boolean operations are not implemented for walls in family documents. Instead I use openings, which can be constructed of curve arrays.

Re: access ID and Unique ID values for instance families using Python

$
0
0

Jeremy -

 

thanks for your reply.

 

Apologize for not posting earlier, I had family issues.

 

Using Python I can pull the Id and UniqueId using few lines, as in the below ex. for Conduits and Conduit Fittings.

 

Thanks for your help!

 

con = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Conduit).WhereElementIsNotElementType().ToElements()
con_fit = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_ConduitFitting).WhereElementIsNotElementType().ToElements()
con_ID = [i.Id for i in con]
con_U_ID =[i.UniqueId for i in con]
con_fit_ID =[i.Id for i in con_fit]
con_fit_U_ID =[i.UniqueId for i in con_fit]

Re: Walkthrough lesson on HOW TO ADD RIBBON PANEL in VB

$
0
0

Good Idea!. I didnt think of that.  Thank you!

Re: Walkthrough lesson on HOW TO ADD RIBBON PANEL in VB

read Stair width (by component)

$
0
0

Hello everybody,

I use c # and need to understand the width of a component-generated stair and select it.

 

I have its selection (element) but can not read the parameters and its geometry in particular and its width.

Thank you, Claudio

Re: API bug in ElementIntersectsElementFilter

$
0
0

Looks like the case.  The radius is 29999' 11 7/8" and with single precision values we basically get about 6-7 digits of precision so 29999.9895833333 which probably gives us a resulting 29999.98 (roughly) and the rebar 1/2 diameter is 0.015625' so it's pretty close to the murky region. 

 

The consternation is that it isn't a failed intersection all over the piece, only at certain locations so in calculating it must just be random enough, in terms of floating point rounding, that it works sometimes and not others.  I would like to see it a little more consistently failing at the middle of the element (where the camber delta is greatest and not at the end where the camber delta is not) but as it's really rounding precision error it's probably too much to ask.

 

If, however, Revit is working in double precision then this is a legit bug, even with the bar hosted to the warped element.

 

 

Re: Background processes monitoring or checking

$
0
0

Gotcha, sorry I misunderstood then.  I would agree with the others then, try testing the code independently of the dialog and then start adding UI layer on to it and see if you start getting an issue...


Re: read Stair width (by component)

$
0
0

Hi ,

 

I'm not an expert in this field but have you tried this ?

 

element.LookupParameter("Width")

 

You have to write the exact name of the parameter.

 

You can also try

 

element.get_Parameter(BuiltInParameter.STAIRS_RAILING_WIDTH) => Try to look at all available parameters and choose the one that best answers to your issue

 

Regards,

 

GM

How to get the geometry in coarse detaillevel without a view?

$
0
0

Hi,

 

When I use get_geometry function to get the geometry from elements, I set the DetailLevel parameter of options. 

 

No matter the value is coarse or fine, the result which is the function return is same.

 

For example, the geometry of a Pipe in the coarse detaillevel should be a line, but the API has return a solid in fact.

 

Only when I set the view parameter of options to a coarse view, I can get a line.

 

So how can I  to get the geometry in coarse detaillevel without a view?

 

thanks.

Re: UI coordinates

Re: REVIT LT trial version

$
0
0

Dear John,

 

Thank you for your query and posting it in a public forum.

 

Unfortunately, you picked an inappropriate forum for this topic.

 

Otherwise, 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:

 

http://forums.autodesk.com/t5/revit-api/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: Updater Exception due to Recursion

$
0
0

Afaik, the different updater types have different priorities and are executed in a specific order.

 

Choose the correct updater priority.

 

If that does not help, check out the hints on Dynamic Update of Elements that Mutually Influence each Other in 

 

http://thebuildingcoder.typepad.com/blog/2013/12/devlab-munich.html

 

Here is The Building Coder topic on DMU:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.31

 

Good luck!

 

Please let us know how you end up solving this.

 

Thank you!

 

Cheers,

 

Jeremy

Viewing all 67020 articles
Browse latest View live


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