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

Re: Selecting in Linked Documents

$
0
0
You actually can't do that in Revit. Revit will only allow you to select elements in the current document. If you can't do it in Revit, you won't be able to do it via an addin.


Re: How to evaluate if p (of type parameter) is not filled in C#

$
0
0

I am debbuging the code and

p.AsStringValue()

is null

 

for the ElementType 1044, which actually has a parameter value Ss_25_11_16_70 for p.

 

And so when evaluating

 

if (p.AsStringValue() != null)

this is true

 

so any entry filled in is no longer appearing.

 

For the entries which are not filled in they still appear.

Re: How to evaluate if p (of type parameter) is not filled in C#

$
0
0

Hi ,

1)First check whether the Parameter "Classification.Uniclass.Ss.Number" has some value using

if (p.HasValue)

2)If it has some value then try to get the value as string using

      

P.AsValueString()

Re: SendKeys not working for shortcuts in Revit 2019?

$
0
0

Thanks for the answer man! didnt knew that mayor change in revit.

 

so what im trying to do is to implement a radial menu in which users can configure and call so save a second or two each time they execute a command. so i need to use shortcuts for this since i cant think of any other way.

 

do you know any other alternative to SendKey that i can try on ? any info is appreciate it.

 

thanks!

How to get the roughness and metal factor of the material?

$
0
0

Hi.

How can i get the roughness and metal factor of the material using Revit API? Are properties material.Shininess what i need for metallic factor, material.Smoothness for roughness?

Thank you for your help.

Re: How to handle the firing of a Revit command with CommandEventArgs C#

$
0
0

Unfortunately it is not possible to register any command in Revit.

I ended up using this method:

 

 

        public void application_DocumentChanged(Object sender, DocumentChangedEventArgs args_changed)
        {
            // get document from event args_changed.
            Document doc = args_changed.GetDocument();

            // dump the element information
            ICollection<ElementId> addedElem = args_changed.GetAddedElementIds();
            foreach (ElementId id in addedElem)
            {
                DumpEventArgs(id, doc, "Added");
            }

            ICollection<ElementId> deletedElem = args_changed.GetDeletedElementIds();
            foreach (ElementId id in deletedElem)
            {
                DumpEventArgs(id, doc, "Deleted");
            }

            ICollection<ElementId> modifiedElem = args_changed.GetModifiedElementIds();
            foreach (ElementId id in modifiedElem)
            {
                DumpEventArgs(id, doc, "Modified");
            }
        }

 

And I also used

 

elem.Category.Name

to identify which element in being added or modified.

 

to retrieve this:

        private void DumpEventArgs(ElementId id, Document doc, string changeType)
        {
            Element elem = doc.GetElement(id);

            if (elem == null)
            {
                // this branch is for deleted element due to the deleted element cannot be retrieve from the document.

                MessageBox.Show($"The user {Environment.UserName} edited a document: {changeType} of unknown category");
            }

            else
            {
                MessageBox.Show($"The user {Environment.UserName} edited a document: {changeType} {elem.Category.Name}");
            }
        }

 

Re: How to get the roughness and metal factor of the material?

Annotation Tag placement

$
0
0

I want to use the c# api to pre-populate the category-tag mapping you get when clicking the "Loaded Tags and Symbols" button in the Annotation Ribbon in the native Revit UI and then launch tag placement dialog you get when you click on the native Revit "Tag by Category" button. Is this possible to do without completely rewriting the existing functionality?

Thanks,

Tony


Re: Why is the ElementType empty of all elements in model?

$
0
0

When I ran your code the debug environment gave the warning of the collector being reset. This may have been caused by my investigation of the elements within debug.

 

From the RevitAPI.chm

 

"One special consideration when using this class in .NET: the debugger will attempt to traverse the members of the collector because of its implementation of IEnumerable. You may see strange results if you also attempt to extract the first element or all elements from the collector while the debugger is also looking at the contents of the collector."

 

It isn't something I'm overly familiar with since I never use it that way i.e. when I use it the scope is limited to a few lines:  declaring the collector, applying the filter(s) and then extracting the Elements to iterate. In your case you keep the scope open within the iteration so there is more possibilities for inadvertently affecting it. I've never been told to use it directly and don't see the benefit? My interpretation is that it was made to implement IEnumarable to give it compatibility with LINQ not to give it certain other behaviours of the IEnumerable interface.

 

I think you need to decide a better way of establishing what elements you should be getting. I don't know what you are missing? When I ran your code with the minor changes above I got the walls and column ElementTypes I thought you were looking to find?

 

If the aim is to collect all model elements then my approach would be to split into two extractions and one iteration:

 

1) Extract instances with parameters

2) Extract ElementTypes and their parameters

3) Link the ElementType parameter information to the instance list via ElementID (.GetTypeID)

 

I used to use Cateogory.HasMaterialQuantities but I don't think that is safe e.g. staircases. Not sure what is ultimately meant by 'WhereElementIsViewIndependent'. I believe it is a bit more general than elements with solid geometry (grids/levels/scope boxes etc.). 

 

 

 

Dynamo vs API

$
0
0

HI! im new in the forum , and i have some questions about customizing Revit to process automation , and task management , ive been using dynamo for a whole year , since i was introduced in the world of dynamo and visual programming using grasshopper with rhino , the universe became so attractive to me , a whole masterpiece!

so im looking for ideas or recomendations between learning C# to the Revit API or continue learning about Dynamo , 

 

 

¿ what is the difference between this Revit API , MACROS MANAGER vs Dynamo?

i Know the Revit API can source a whole package to develop software apps inside revit , to automate tasks , workflows , etc.

i use Dynamo specially to built-in complex geometry and manipulate native revit geometry , as well to Run Dynamo player with scripts to automate documentation process, but now i feel attracted to the world of API , but i didnt have any knowledge with coding , im taking now a whole course in special focus in Design script , but i would like some opinions of this topic

thanks you all!

greetings..!!!

Re: SendKeys not working for shortcuts in Revit 2019?

Re: Can not distinguish the rebar shape when I use the api CreateFromCurves?

$
0
0

The points in rebar instance,should bigger than a value.(the value is about diameter or angle or some others).The points I showed, is not right enough.

Help Need for familysymbol

$
0
0

Hello, 

 

I'am trying to changed a code made by someone that doesn't work in my company any more.

The code is loading a familysimbol of a titleblock, but i what to stop that, and insteed to get the titbleblocks placed in a list fo sheets.

 

The code:

                    FamilySymbol titleBlock = null;

                    var formatoUsar = rev.FormatoFichDes != null ? rev.FormatoFichDes.Designacao : "";
                    if (rev.Rosto != null)
                    {
                        if (formatoUsar != "")
                        {
                            string pathRosto = rev.Rosto.GetPathFolha();

                            if (!System.IO.File.Exists(pathRosto))
                                pathRosto = rev.Rosto.GetPathFolha(rev.FormatoFichDes);

                            string keyTitleBlocksCarregados = pathRosto + "_" + rev.FormatoFichDes.Designacao;
                            if (!titleBlocksCarregados.TryGetValue(keyTitleBlocksCarregados, out titleBlock) && System.IO.File.Exists(pathRosto))
                            {
                              
                               
                                uiDoc.Document.LoadFamilySymbol(pathRosto, rev.FormatoFichDes.Designacao, new SampleFamilyLoadOptions(), out titleBlock);
                               
                                if (titleBlock != null)
                                    titleBlocksCarregados.Add(keyTitleBlocksCarregados, titleBlock);
                            }

                            if (titleBlock != null)
                            {
                                var titleBlockInstance = new FilteredElementCollector(uiDoc.Document).OfCategory(BuiltInCategory.OST_TitleBlocks).OfClass(typeof(FamilyInstance)).Where(x => x.get_Parameter(BuiltInParameter.SHEET_NUMBER).AsString() == rev.Referencia).FirstOrDefault();

                                if (viewSheet == null)
                                {
                                    viewSheet = ViewSheet.Create(uiDoc.Document, titleBlock.Id);
                                    sheetViewsCriadas.Add(rev.Referencia);
                                }
                                else
                                {
                                    if (titleBlockInstance != null)
                                    {
                                        if (titleBlockInstance.GetTypeId() != titleBlock.Id)
                                        {
                                            FamilyInstance.ChangeTypeId(uiDoc.Document, new List<ElementId>() { titleBlockInstance.Id }, titleBlock.Id);
                                        }
                                    }
                                    else
                                        erros.Add("A folha " + rev.Referencia + " não tem title block.");


                                }
                            }
                            else
                                erros.Add("Não foi encontrado o Family Type " + formatoUsar + " no rosto associado à peça desenhada " + rev.Referencia);
                        }
                        else
                            erros.Add("A peça desenhada " + rev.Referencia + " não tem formato associado");
                    }
                    else
                        erros.Add("A peça desenhada " + rev.Referencia + " não tem rosto associado");

How about the points not in planar face want to build directshape?

$
0
0

I meeted a question before ,and ask the question here:

 

 

https://forums.autodesk.com/t5/revit-api-forum/use-the-tessellatedshapebuilder-but-some-faces-not-show-and-no/m-p/8333808#M34104

 

Now,I know that:

A

The tessellatedface  describe:Constructs a tessellated face without holes. Face data is always set, even if the input data are invalid (e.g., describes a wildly non-planar face). A TessellatedShepeBuilder's function is used to check the data and heal them if possible.

Which means the points should in a planar face.such as (1,1,0).(2,2,0),(3,3,0) Z is 0. 

 

B

If the points not in a planar face,we can use revit api to check it and heal them if possible.

DoesFaceHaveEnoughLoopsAndVertices(Which I found may be the function to check it)

describes :

 

Checks whether 'face' has enough loops and vertcies to be valid.

 

I use the function to check the tessellatedface  it returns true,but it also not show out the face.

the points ,according to what I know,is not in a plannar face.

 

Now ,I want ask :

 

Did here a way to draw a mesh by the points which  not in a planar face or how to check the tessellatedface and heal them  ?(which I mean,I use the DoesFaceHaveEnoughLoopsAndVertices function it return true but also can not show out the face.Did I found the wrong function).

 

PS:

I had search a way like this:

https://forums.autodesk.com/t5/revit-api-forum/broken-mesh-with-tessellatedshapebuilder/m-p/7722380

Which can show me to use more face to form a big mesh which the points not in a planar face?

 

Thanks ~

 

The picture below:

三维图.png

 

which just has the Staircase,no Both sides;

(Sorry poor English)

Re: Fabrication Part Family Name

$
0
0

Thanks Vaentin and Jeremy.


 wrote:

Hi ,

 

I guess you are either looking for the Family parameter which the BuiltinParameter is "ELEM_FAMILY_PARAM" or the Fabrication Service parameter which BuiltinParameter is "FABRICATION_SERVICE_PARAM" with both of them you should use the Method AsValueString.

 

Please see examples below:

 

fabrication service.JPGFamily.JPG

 

Hope this helps to solve your issue.

 

 

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

 

Valentin Noves

BIM Manager
www.valentinnoves.com


 


When in 3D view, Revit crashes with a fatal error upon right-clicking ViewCube

$
0
0

I have searched through the journal file and found the line in which the fatal error occurs.  However, I can't find any forum suggesting what it be referring to.  Below is the part in the journal file:

 

' 0:< DBG_INFO: Recent Dynamic Added but not to Dynamics, this means that this element is not dynamic anymore with RDYs removed.: line 194 of d:\ship\2018_px64\source\revit\revitdb\display\GraphicsMgr.cpp.
' 0:< Unconverted MessageBox "A fatal error has occurred.  The application will be terminated.  You have the opportunity to save recovery files for all of your changed projects.
'

Re: Why is the ElementType empty of all elements in model?

$
0
0

I ended up doing what you said in 1) and 2).

 

1) I used a combination of filters to obtain the instances:

//filter

List<Element> collector = new FilteredElementCollector(doc)
.WhereElementIsNotElementType()
.Where(e => e.IsPhysicalElement())
.ToList<Element>();

//method for filter

public static bool IsPhysicalElement(this Element e) { if (e.Category == null) return false; if (e.ViewSpecific) return false; return e.Category.CategoryType == CategoryType.Model && e.Category.CanAddSubcategory; }

2) and to obtain the ElementTypes:

 // filter

List<Element> collector_types = new FilteredElementCollector(doc) .WhereElementIsElementType() .ToList<Element>();

 

I haven't managed to successfully do 3).

Now I need to retrieve just the ElementTypes which are being used in the Revit model, i.e. the ElementTypes with at least an instance in the Revit model. Will 3) help retrieve just the ElementTypes in use?

 

Thank you very much for your help.

 

Re: Annotation Tag placement

$
0
0

I added screenshots of the functions I am referring to.

How to delete a segment when drawing walls?

$
0
0

Hello,

 

I'm trying to determine how I can "go back" or delete a segment of wall that I am placing, when I am in the process of placing a chain of walls. 

Eg. I accidentally drew a segment of a wall which is incorrect. I don't want to have to go back and redraw all the segments in the chain and I just want to delete the last segment placed so that I can continue to trace out the wall.

 

Thank you

Re: Pick Points from Active View

$
0
0

Hey,

How do you stop the loop when you are done selecting?

Thanks

Viewing all 66855 articles
Browse latest View live


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