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

PostCommand do not have reaction

$
0
0

Hi.

 

I want to do Solid Extrusion by Post command, My step is following :

 

1. Create a profile in Revit Family Document

1.createProfile.png

 

2. Select the profile

2.select.png

 

3. Run my adding execute Post command to form Solid.

 

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application; 
            RevitCommandId cmdId = RevitCommandId.LookupPostableCommandId(PostableCommand.SolidExtrusion);
            uiapp.PostCommand(cmdId);              
            return Result.Succeeded;
        }

 

 

But the results is nothing and no exception too,

How can I correctly form solid ?

 

thanks

 

 

 

 


Re: PostCommand do not have reaction

$
0
0

Hi  ,

Your code works fine for me.

Use try-catch and see whether you get any error !!!!!

You are saying nothing is happening after executing your command so my question is "Is your addin file contains the correct class name and dll location?"

use task dialog in your code to show some messages to check whether your addin is working fine or not!!!

If the taskdialog doesn't appear then the problem may be with your addin file.

 

Re: Using a geometry viewer in a revit addin to preview results

$
0
0

Hi Jeremy,

 

I wanted to let you know I succesfully implemented the helix toolkit wpf viewer using the suggested decoupling of processes. See attachted image. The example of IPC for disentanglement of CEFSharp was based on a windowsforms application, so I had to make some changes to make it work with a WPF Window.

 

Now that I can launch a viewer from within the revit context, and can communicate with it from my revit command/application, the next step is to get geometry from revit to the viewer. I already succesfully tested to generate an OBJ file using your OBJ exporter voor Revit 2014 (upgraded to 2018) and display it in the viewer. However, as I was reading, I found your ideas on creating an improved version of your exporter using the custom exporter framework. Is this something you already implemented, or have planned to do?

 

I will continue to make my addin work with the existing pieces of the puzzle I have so far. An improvement on the OBJ exporter would be a nice-to-have feature, but your existing exporter does the trick. Once I have cooked something up, I'm happy to share my efforts if you're interested.

 

Again briefly my use-case: I want to create an addin that lets the user generate some revit ceiling geometry, and adjust the position and composition of this ceiling interactively with some sliders and input fields in my addin. This to-be-created geometry depends on existing wall and room geometry in the revit project. As such, in my addin, I want to preview the to-be-created- ceiling geometry, in the context of the relevant revit geometry. For this I want to import some relevant revit elements into my viewer to display the context, and then display the the to-be-created geometry in that viewer as well. When the user is satisfied, he can click ok, the preview will close, and the addin will generate revit objects according to the layout and settings chosen in the viewer.

Re: Create 3D model curve from List in project document

$
0
0

Hi  ,

Is it possible via Revit UI?

because in Revit UI if it is possible then through Revit API you can achieve this functionality.

From my understanding, I think you can't extrude list of model curves in the project document.

However, You can use the model-in-place command but this command also opens the Revit family editor to create the extrusion.

 

I hope this helps.

Re: PostCommand do not have reaction

$
0
0

Hi  ,

Thank for your reply,

 

I try add task dialog in my code that work correctly, My code and results figure as following :

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            try
            {
                RevitCommandId cmdId = RevitCommandId.LookupPostableCommandId(PostableCommand.SolidExtrusion);
                uiapp.PostCommand(cmdId);

            }
            catch (Exception e)
            {
            }

            TaskDialog.Show("Test", "Hello");
            return Result.Succeeded;
        }

 

hello.png

 

And, I tried another command like Default3DView that can correctly change view form plane to 3D-view

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            RevitCommandId cmdId = RevitCommandId.LookupPostableCommandId(PostableCommand.Default3DView);
            uiapp.PostCommand(cmdId);
            return Result.Succeeded;
        }

thank you

 

Re: Filtering Categories using Custom Exporter. Worked fine pre 2020

$
0
0

This is what the process looks like. 

 

Full project in the 3D view.

 

image.pngEverything Visible

 

As logic in first post shows. I switch categories on and off and export.

 

image.pngExporting Doors Category

Here it is exporting the doors category.

Even though it goes to the next category in the list, the doors category did not export. And no errors were shown by the custom exporter.

 

 

Re: Shortcut for Finish button from UIDocument.Selection.PickObjects()?

Re: Wall create by profile

$
0
0

Hi,

 

Thanks i made the script to get the curveloops and overwrite to see the lines that are clockwise with a red line

 

But how can you make a complete curveloop reverse in direction? I know it's possible for a single curve with Curve.Reverse but can't find a sample of a curveloop.Reverse

 

bool isCLockwise = curveLoop.IsCounterclockwise(normal);

Annotation 2019-08-21 100615.png


Re: Wall create by profile

$
0
0

Check the API is not calling it Curveloop.Reverse(); but Curveloop.Flip();

 

Detail view title in French is lacking a colon

$
0
0

Hi!

 

It seems like there is a lack of a punctuation colon in the French versions when you call the title of a Detail View.

By referring to the API properties of a view: View.Title - I'm getting a different result in French and English.

Revit title error.png

 

 

 

 

 

 

 

 

 

 

 

 

 

I've tested Revit versions from 2017 to 2020, also in Polish and Spanish but it seems the issue to be concerning only the French versions.

 

Could anybody confirm?

Trying to retrieve the DimensionType of a Dimension

$
0
0

I'm trying to build a ZeroTouchNode with C# in Visual Studio that's input is a Dimension element and it's output is the DimensionType of that Dimension element. It seemed simple, but I'm having trouble returning the DimensionType element. Instead, the node is returning "Autodesk.Revit.DB.DimensionType". How do I retrieve the actual element? My code is included below. Thanks in advance for the help! 

 

using System;
using System.Linq;
using System.Threading.Tasks;
using System.Text;
using Autodesk.DesignScript.Runtime;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using RevitServices.Persistence;


namespace CustomNodes
{

    public class Dimensions
    {
        private Dimensions()
        {
        }
        public static ElementType GetDimType(Revit.Elements.Element dimensions)
        {

            Document doc = DocumentManager.Instance.CurrentDBDocument;

            Element UnwrappedElement = dimensions.InternalElement;

            ElementId id = UnwrappedElement.GetTypeId();

            ElementType dimType = doc.GetElement(id) as ElementType;

            return dimType;

        }

    }
}

Re: Line based family location don't update Origin after change

$
0
0

  I do not agree with the consensus that this is not a bug. Revit API offers two functions to create a line: Line.CreateUnbound() and Line.CreateBound(). If this behavior were to exist only for Line.CreateUnbound(), I would have agreed that this is not a bug since you are creating an infinite line. With Line.CreateBound(), the length changes but the origin does not, which means that the new bounded line does not match with the intended line.

 

In my specific case, I want to move and scale the pipe in exactly the same direction as it's currently pointing. As the accepted solution at Programmatically extend Pipe length suggests, I just need to change location.Curve property of the pipe. But in my case, since the Origin doesn't change, the pipe location is completely incorrect. The only workaround I can think of is to move the pipe to a random location in a different direction so that the origin updates and then bring it back to the intended position. But this workaround exists doesn't mean that the original issue is not a bug. And this workaround has its own issue. If I change the pipe's direction, its connection breaks. I don't want that to happen so am still figuring out how to get past this problem.

 

BTW If I didn't have to scale the length of the pipe, I could have used ElementTransformUtils.MoveElement() function but it doesn't do the job in my case since there is scaling involved.

Re: Changing pipe direction

$
0
0

 The problem was because of inaccuracy in the cross product. I was deriving the pipe direction by doing two cross-products of unit-norm vectors. In other words, pipeDirection = X.CrossProduct(Y).CrossProduct(X). If X and Y are of unit-norm, I would expect pipeDirection to be unit-norm, but that wasn't the case. I was getting about 0.971 instead of 1.000. I thought that Revit uses doubles and not floats, but may be that's not the case. Once I normalize pipeDirection, it worked fine.

 

BTW Your rolling offset post only deals with inserting elbows, which works pretty well. In my case, I am inserting T connection and that API is a horrible mess. Here are the issues:

 

  1. CreateTeeFitting() works only when the connection is 90 degrees so you have to use the workaround mentioned in Tee Fitting with no right-angle.
  2. The above workaround works only when the base pipe is placed in a way that's acceptable to Revit. As an example, adding a Tee connection works if the two pipes are placed along X axis and the branch pipe is along the Y-axis. But if I rotate the three pipes slightly, for e.g. by 0.1 degrees, the CreateTeeFitting() function fails.
  3. So now I have to do another workaround, i.e. create dummy pipes in a position that the Revit likes and create a 90 degree T connection. Then delete all the dummy pipes and the fittings that were automatically created except the T connection. Now rotate the T fitting to what I want, for e.g. by 0.1 degrees. Then change the angle of the branch connector to something other than 90 degrees.

 

This issue along with Line based family location don't update Origin after change has taken me about a week to create a T connection at the right place and orientation instead of probably an hour if the API had worked in the first place.

Re: problem: Dimension for column

$
0
0

Hi  

I fixed it, can you watch it?

 

 

Re: problem: Dimension for column

$
0
0

HI  !

Would you please give me detailed instructions? Thank you !

 

 


Re: Changing pipe direction

$
0
0

Thank you very much for your research, solution, and pointers to the other issues.

 

Sorry to hear that it cost you so much time to resolve these issues.

 

I am glad to hear that you succeeded in the end. Congratulations!

 

This all seems very useful to me, so I'll summarise it on The Building Coder for future reference.

 

One little clarification:

 

If X and Y are both unit length, their cross product will still NOT be unit length unless they are exactly perpendicular.

 

Best regards,

 

Jeremy

 

Re: Trying to retrieve the DimensionType of a Dimension

$
0
0

You code looks perfectly fine to me.

 

Probably, there is a misunderstanding involved.

 

The DimensionType IS the actual element.

 

Maybe your target does not expect an Element instance at all, just the ElementId.

 

Therefore, you might be able to just return `id` and skip the call to `GetElement`.

 

Re: problem: Dimension for column

$
0
0

 

    var instanceTransform = columnFamilyInstance.GetTransform();

foreach (Face face in solidCol.Faces) { var normal = face.ComputeNormal(uv); var instanceNormal = instanceTransform.OfVector(normal); if (instanceNormal.IsAlmostEqualTo(XYZ.BasisY) || instanceNormal.Negate().IsAlmostEqualTo(XYZ.BasisY)) { referenceArrayX.Append(face.Reference); }
//... }

Re: problem: Dimension for column

Re: Trying to retrieve the DimensionType of a Dimension

$
0
0

Thank you Jeremy. When I try to return the id, it returned the id of the dimension type, but not the dimension type element. Also, when I tried to return the element using the "Get Element" method and changed the return type to "Element" (as seen below) rather than "ElementType" as I had previously, it still gives me the same output.

 

using System;
using System.Linq;
using System.Threading.Tasks;
using System.Text;
using Autodesk.DesignScript.Runtime;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using RevitServices.Persistence;


namespace theWorks
{

    public class Dimensions
    {
        private Dimensions()
        {
        }
        public static Element GetDimType(Revit.Elements.Element dim)
        {

            Document doc = DocumentManager.Instance.CurrentDBDocument;

            Element UnwrappedElement = dim.InternalElement;

            ElementId id = UnwrappedElement.GetTypeId();

            Element dimType = doc.GetElement(id) as Element;

            return dimType;

        }

    }
}

dynamo example.png

Viewing all 66815 articles
Browse latest View live


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