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

Re: How to change language for annotation text and dimension using api?

$
0
0

Hi Jere,

Thanks for your suggestion. So, First I'll check with non Revit api forums to change the annotations language manually.

At the mean time, if you heard any ideas please let me know. It is very helpful to me.

Thank You.


Re: Can not set value for AssetPropertyDistance["textture_RealWorldScaleX&a

$
0
0
I had figured out what's happening. If the source image file of the appearance in the material are removed or deleted, all these related properties can't be set until the UnifiedBitmapBitmap property is set to a valid existing file path.So if I set the UnfiedBitmapBitmap property first, then set the TextTureRealWorldScaleX, TextureRealWorldScaleY will be OK. It's an order problem.

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

$
0
0

Hi!

 

It is simple to get a storage type of the parameter. Just use document.get_TypeOfStorage(BuiltInParameter...

 

Getting built-in parameter unit type is a bit more complicated. If you know the category parameter belongs to, you can create a view schedule in temporary transaction. You can find your parameter in schedule.Definition.GetSchedulableFields list:

var schedulableField = schedule
	.Definition
	.GetSchedulableFields()
	.Where(x => x.FieldType == ScheduleFieldType.Instance || x.FieldType == ScheduleFieldType.ElementType)
	.First(x => x.ParameterId == new ElementId(BuiltInParameter....));

Then add this schedulable field to the schedule, and get a schedule filed unit type:

schedule.Definition.AddField(schedulableField);
var unitType = schedule.Definition.GetField(0).UnitType;

This method works both for shared and built-in parameter.

Dynamo for drawing MEP

$
0
0

Dear all
Is there any method to use DYNAMIC to draw in revit in line strokes with cad link.
Thank all

Re: Dynamo for drawing MEP

Re: Programatically push Place on Work Plane button

$
0
0

Dear Harry,

 

I do not see any screencast attached.

 

Can you share the code for the UISpy method you are using?

 

That might be of interest to others as well.

 

I am not aware of any Revit API support for pushing buttons. In fact, I am pretty certain there is none.

 

All the Revit API support I know about for pushing buttons is wrapped in the dialogue box showing event and Failure API functionality:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.32

 

I also implemented my own Windows hook method to push an arbitrary button:

 

https://thebuildingcoder.typepad.com/blog/2009/10/dismiss-dialogue-using-windows-api.html

 

I assume you are aware of that approach.

 

Is that what you mean by 'UISpy method'?

 

Cheers,

 

Jeremy

 

 

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

$
0
0

Hi  ,

 

Thanks for the answer. I tried some things out to see if you only can get a simple wall to the viewer, without the need of running the viewer exe. So directly in Revit. I used as a startpoint the example from   " HelixToolkitInRevitOne" and added the following code:

 

public Result Execute(ExternalCommandData data, ref string message, ElementSet elemSet)
        {           
            try
            {
                MainWindow mw = new MainWindow();

                UIApplication uiapp = data.Application;
                UIDocument uidoc = uiapp.ActiveUIDocument;
                Application app = uiapp.Application;
                Document doc = uidoc.Document;
                {
                    List<XYZ> xyz = new List<XYZ>();

                    var meshBuilder = new MeshBuilder();

                    GeometryModel3D wall = new GeometryModel3D();

                    IList<Reference> reference = uidoc.Selection.PickObjects(ObjectType.Element, new ImportSelectionFilter(), "Select wall to convert Geometry");

                    foreach (Reference r in reference)
                    {
                        var import = doc.GetElement(r) as Wall;                   

                        Autodesk.Revit.DB.Options opt = new Options();
                        Autodesk.Revit.DB.GeometryElement geomElem = import.get_Geometry(opt);
                        foreach (GeometryObject geomObj in geomElem)
                        {
                            Solid geomSolid = geomObj as Solid;
                            if (null != geomSolid)
                            {
                                foreach (Face geomFace in geomSolid.Faces)
                                {
                                    Mesh mesh = geomFace.Triangulate();

                                    XYZ[] triangleCorners = new XYZ[3];

                                    for (int i = 0; i < mesh.NumTriangles; ++i)
                                    {
                                        MeshTriangle triangle = mesh.get_Triangle(i);

                                        triangleCorners[0] = triangle.get_Vertex(0);
                                        triangleCorners[1] = triangle.get_Vertex(1);
                                        triangleCorners[2] = triangle.get_Vertex(2);

                                        meshBuilder.AddPolygon(listPoints(triangleCorners));       
                                    }
                                }
                            }
                        }                        
                    }

                    ModelVisual3D visual = new ModelVisual3D();
                    wall.Geometry = meshBuilder.ToMesh();
                    wall.Material = new DiffuseMaterial(new SolidColorBrush(Colors.Gray));
                    wall.BackMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.Gray));

                    Model3DGroup modelGroup = new Model3DGroup();
                    modelGroup.Children.Add(wall);

                    visual.Content = modelGroup;
                    mw.viewPort3d.Children.Add(visual);

                    mw.Show();
                }
            }

            catch (Exception ex)
            {
                string exMessage = "No exception message was included";
                if (ex.Message != null)
                {
                    if (ex.Message.Length > 0)
                    {
                        exMessage = ex.Message;
                    }
                }
                TaskDialog.Show("error", exMessage);
            }
            return Result.Succeeded;
        }          

        public List<Point3D> listPoints(XYZ[] p)
        {
            List<Point3D> listP = new List<Point3D>();

            foreach (XYZ points in p)
            {
                Point3D p1 = new Point3D(points.X*304.8, points.Y*304.8, points.Z*304.8);

                listP.Add(p1);
            }
            
            return listP;
        }
    }

When running this code in Revit it is running smoothly unless you zoom to close. But to come real close to the extension "Wood Framing Walls" i think this is a good starting point or you could maybe pass the geometry data to the exe version with some sort of data txt file?

 

Result running within Revit, faces are looking much nicer this way:

 

view3d.gif

Re: Generate Views from Rooms.

$
0
0

Apologies Jeremy for my sloppy and duplicated code but it tends to be how I work when testing out ideas. Its only when I have a clear direction forward do I rationalise the code.

 

Using CreateViaOffset method taking a list of doubles with offsets set as Wall.Width *1.1 results in an error when the wall width changes across its length. The additional code is my initial attempt to identify those situations where the wall of various widths or room separator occur in the same length and to create one unified offset across the length.

 

It is difficult to explain my observations and to be honest I am not fully sure why it is returning the results that it is, as it does not appear to be coved within the help documentation. I wonder if it is a problem with the API as it would appear to be impossible to go from two or more different offsets across the same length (unless they are greater than the previous) without a “Curve loop couldn't be properly trimmed” Error.
My observations are summarised below:

Situation 1.png

Situation 1:
1) foreach( IList<BoundarySegment> sloop in sloops ) returns 5 loops one for each wall.
2) Creating an offset for each wall results in an error “Curve loop couldn't be properly trimmed”. This only occurs when there is a change in offset across a length.
3) If I create an offset for the thinner wall in the same run equal to or greater than the thicker wall there is no error.

 

Situation 2.png

Situation 2:
1) foreach( IList<BoundarySegment> sloop in sloops ) returns 8 loops one for each wall (5), 1 for the room separator and two additional.
2) These two additional loops return elem == null,
3) When the loop does reach the room separator this is caught by the
else if( (BuiltInCategory) elem.Category.Id.IntegerValue == BuiltInCategory.OST_RoomSeparationLines )
4) Values must be set for the two additional loops so that the loop count and list of doubles with offsets count match. These two addition loops look as though they represent offsets from the ends of the two walls to which the room separator is attached; see images in my previous post.
5) As long as the offset where, the room separator is located and for the next wall are equal to or greater than the previous adjoining wall (wall A) there is no error the instant it is less “Curve loop couldn't be properly trimmed.”

 

In conclusion it appears the API CreateViaOffset method taking a list of doubles with offsets will not allow walls of various widths within the same run when the offset is less than the previous?

I hope this explains my problem?


Re: Mah metro WPF

$
0
0

I've already got that metro works. 
This issue was that ControlzEx.dll is also needed if you want metro to works. After that, that works like an usual windows 

 

 

Re: Mah metro WPF

$
0
0

Wow, that's great! Congratulations!

 

Thank you for letting us know.

 

Would you like to share a little sample, e.g., a code snippet and screen snapshot, so we can see what use it is?

 

Re: Can not set value for AssetPropertyDistance["textture_RealWorldScaleX&a

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

$
0
0

Dear Folkert,

 

Wow, that looks great!

 

And very simple, as well.

 

I definitely agree this is a brilliant starting point.

 

Why would you want to pass the geometry data to the external exe version?

 

If you really wanted to, you could either use a file or an in-memory communication channel.

 

With the geometry data in hand, you can also easily generate a useful generic file format like glTF:

 

 

Could you possibly share the entire Visual Studio solution to make it very simple for others to recompile and test?

 

Thank you!

 

Best regards,

 

Jeremy

 

Application Event with SynchronizeWithCentral Method

$
0
0

Hi Everyone, I would like to confirm the following hypothesis. 

 

I´m working on Revit Addin that performs several actions: Collect elements, Hide elements, Unhide Elements and Synchronize.  Synchronization is the first action that runs in this Script. Everything works fine, but if I subscribed that External Command on the Application Event "Document Printing", the Synchronization fails (The rest of the actions works fine).

 

I copy the whole code into a new External Command and it works perfectly.

The only difference is: the first one has a Push Button on the Ribbon Bar and the second one has not. In the first case, I defined an External Application to call this External Command. In Fact, if I use the push button works fine. But if I subscribe to an event Sychorization fails.

 

Maybe this difference causes an error? The existence of the External Application that creates a button in the Ribbon Bar combined to an Application Event causes an error in the Synch Action? Does it make sense? 

 

If someone knows what really happen could explain to me?

Thanks and Regards, 

Re: Programatically push Place on Work Plane button

Re: Programatically push Place on Work Plane button


Re: Programatically push Place on Work Plane button

$
0
0

The screencast is https://autode.sk/2DNve7K

(I select it from the My Screencasts dropdown but it does not get attached to my post, so I am providing the URL instead)

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

$
0
0

Hi Jeremy,

 

Thanks!

 

The reason i thought to sent it to the external exe version is that if someone want to zoom in really close it's more smooth. But when you dont' need that  it's working very well this way. And maybe you can change something in the settings in wpf so you can't zoom in to much. Looks like the "Wood Framing Walls " is using this technique.

 

Attached you find the zip file with the complete sollution.

 

Wow glTF is really nice, never seen that before. What would be the workflow, get geometry like i did, make a glTF of it and sent it to a WPF?

 

Re: Programatically push Place on Work Plane button

$
0
0

Thank you for the pointer to Inspect and the screencast URL. I see it, with the title Windows Automation toggle button.

 

I should think that the Windows and .NET APIs should enable you to locate that button and toggle it programmatically.

 

Possibly it requires something more forceful that just a simple click to get the message across to Revit.

 

Good luck finding an elegant solution to this!

 

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

$
0
0

Dear Folkert,

 

Thank you for the Visual Studio solution.

 

I have not done much for or with glTF, but it seems like an extremely efficient and well-thought-out format.

 

I implemented a data collector for it in the room volume glTF generator:

 

https://thebuildingcoder.typepad.com/blog/2019/06/room-volume-gltf-generator.html

 

I left the further processing and final glTF file generation to Michael Beale, though, and I don't know whether he published his results.

 

Cheers,

 

Jeremy

 

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

Viewing all 66705 articles
Browse latest View live


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