API REVIT c#

API REVIT c#

Anonymous
Not applicable
7,009 Views
4 Replies
Message 1 of 5

API REVIT c#

Anonymous
Not applicable

Hello

 

I have a question concerning c# programming

 

When I create a cadlink element in c# language, I would like to get the BASE LEVEL parameter, but I Don't find it.

 

Could someone tell me how to get this parameter?

 

I have a second question concerning parameters which are in a combobox (choice between several existing value)

For exemple for Walls, the parameter TOP_LEVEL_CONSTRAINT.

I can get the parameter value, but when I want to change or to set a new value of it, it doesn't work.

Could someone help me concerning this second question?

 

Best regards

 

 

 

 

0 Likes
7,010 Views
4 Replies
Replies (4)
Message 2 of 5

jlpgy
Advocate
Advocate

Hi:

For you 1st question, I think you want to obtain the reference Level of an Element, don't you? If so, there is a LevelID property for each Element object. You should try this:

Level l = your_document.GetElement(your_element.LevelID);

I didn't get your point of 'cadlink'. Did you mean that your were dealing with the linked elements?

 

For the 2nd question, could you please share some of your codes of setting its value?

单身狗;代码狗;健身狗;jolinpiggy@hotmail.com
0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi

 

thank you for your help. You're right concerning my first question.

my pb is that I forgot to access the level reference between a transaction, that's why it didn't work

 

so, to set a level reference (for example the Bottom level of a wall) , I have to create a transaction, and set the parameter level Id in this transaction and then commit it.

 

For my second question, I mean about linked element.

when you declare a CADlink variable which is your dwg file, and you call a "parameters" method, the list of parameters of the cadlink element are wrong, it is totally different from parameters we see in Revit when we selec a cadlink element manually.

 

Best regards,

0 Likes
Message 4 of 5

Anonymous
Not applicable

Hi,

 

I Added below a picture to show you the problem with my second question. The first question is solved.

I add some code so that you can see what I mean. Do not forget linking a dwg file.

 

public void listeparametredwg()
        {
            
            Document RevitDoc=this.Application.ActiveUIDocument.Document ;
            
            IList<Element> CADlist = (IList<Element>)new FilteredElementCollector(RevitDoc).OfClass(typeof(CADLinkType)).WhereElementIsElementType().ToList<Element>();
    TaskDialog.Show("Number of linked dwg files",CADlist.Count.ToString());
    
    FilteredElementCollector coll = new FilteredElementCollector( RevitDoc  );
    IList<Element>listeElements=coll.WherePasses(new LogicalOrFilter(new ElementIsElementTypeFilterfalse ),new ElementIsElementTypeFiltertrue ) ) ).WhereElementIsNotElementType().ToElements();

    string listOfParameters="";
 
    Element te=listeElements.ElementAt(0) ;
 
ParameterSet ps2=te.Parameters;
foreach (Autodesk.Revit.DB.Parameter p in ps2){listOfParameters +=p.Definition.Name +"\n";}
 TaskDialog.Show  ("DWG parameter",listOfParameters  );
            
        
 
        }

0 Likes
Message 5 of 5

jeremytammik
Autodesk
Autodesk

Thank you for your query and many thanks to Yulong.Jin for his help solving it.

 

When you add a CAD link, several different elements are generated to represent it and maintain its data.

 

You can determine them by researching the database before and after linking in the DWG file, determining exactly which elements were added during that process and what their properties are.

 

This is a typical example of researching for information and relationships in the Revit database.

 

The most important tools for this are RevitLookup, the BipChecker, and other, more intimate exploration tools such as the RevitPythonShell.

 

Please read up on those, use them to find the parameters you are looking for, and enjoy diving into the intricacies of the Revit database:

 

 

I hope this helps.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder