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

Re: Temporary Transaction Trick Exception

$
0
0
In general, if I do not use the transaction at all, then everything works fine. If I use a transaction and rollback then a different error occurs after the transaction in the code. But if the code is debugged on the line, then there are no errors. but even if errors do not occur, the code does not work as correctly as before using the transaction. For example, points that used to belong to the room, when using the transaction room, for some reason do not belong

Re: How do I get all the outermost walls in the model?

$
0
0

Yup, I fully agree. 

 

I have asked the development team for advice on how to tackle this effectively.

 

Cheers,

 

Jeremy

 

which Button start Execute

$
0
0

if I had many buttons with the same Execute, is there a way to know which button was pushed?

Automatic BOQ generation via coding

$
0
0

How can we generate BOQ of any structure via coding using BIM. I want to use revit for BIM but I am unable to start my work. Further, I am novice to coding and programming stuff. 

It would be very helpful if any leads will be provided.

Re: GETCENTERLINECURVES for stirrup rebar

$
0
0

Hi JimJia

I did a test with your code, but I miss something, the curve extracted from the bracket is not planar but in 3D, the first 6 curves are planar, the other 6 are on a different plane. Your code, if I have analyzed it well, read the normal of a line and align the others using this normal. This is fine for the first 6 but not for the others that remain on a different level. I think I need something to clear off one of the three xyz components to flatten the curves, like "Flatten command" in AutoCAD.

 

Thanks

Stefano

Export ifc access denied

$
0
0

the code:

 

try
                                {
                                    ifcExport(doc, v, "name_of_file", "C:\\test123\\ifc_out");
                                }
                                catch (Exception ex) { File.AppendAllLines(path, new string[] { "ifcExport Exception: " + ex.Message }); }

 

public void ifcExport(Document doc, Autodesk.Revit.DB.View viewExport, string filename, string path)
{
IFCExportOptions ifcOptions = new IFCExportOptions();
ifcOptions.ExportBaseQuantities = true;
ifcOptions.FamilyMappingFile = "C:\\test123\\SAS_IFC-export.txt";
ifcOptions.FileVersion = IFCVersion.IFC2x3;
ifcOptions.FilterViewId = viewExport.Id;
ifcOptions.WallAndColumnSplitting = true;

doc.Export(path, filename, ifcOptions);
}

but for some reason it keeps giving me this error message, no matter what folder i choose to export to.

Access to the path 'C:\test123\ifc_out' is denied.

 

and to make the case even stranger, if i make an nwc export to the exact same folder and that works without any errors or warnings.

 

I have no idea why it does give me this error for an ifc file while i can write other file types to the folder without any issues.

 

Edit:

it made me also wonder, when i installed the IFC for revit (from Autodesk) do i even need to call the default doc.export ? or is there another method i should be calling to make the ifc exports ?

Re: which Button start Execute

$
0
0

You could have something in every button click event that first writes to the Journal, then executes the command/external event. For each button, you could change what is written to the journal prior to code execution.

 

For reference

WriteJournalComment

Re: which Button start Execute

$
0
0

what kind of button you are referring to? a winform button or a ribbon item in revit api?

 

if it is the winform button, just get the unique name of the button for example:

string name =(sender asButton).Text;

If its the revit api you have to be a bit more creative, maybe sent the name to some temporary txt file:

File.AppendAllLines(filePathOfTxtFile, new string[] { "Button_01"}

and read the last line in your execute, so you know that last pushed button.


Re: which Button start Execute

Re: Temporary Transaction Trick Exception

$
0
0
I use a transaction inside a loop for each face of the room. Maybe this is the problem?

Re: Export ifc access denied

$
0
0

Dear Dante,

 

Thank you for your query.

 

That does sound strange indeed.

 

What happens if you specify no path at all?

 

Oh no, I see that the folder must exist, according to the docs:

 

http://www.revitapidocs.com/2018.1/7efa4eb3-8d94-b8e7-f608-3dbae751331d.htm

 

For testing purposes, I would use the simplest possible one, and one that belongs to you, e.g., your Windows home folder, or run Revit as administrator, so that it has more powerful access when writing files.

 

The output filename can be left empty, it seems.

 

Afaik, the IFC for Revit is automatically hooked up to the standard doc.Export method.

 

I would also try raising this question in the IFC for Revit discussion forum:

 

https://sourceforge.net/p/ifcexporter/discussion/general

 

They are presumably the most experienced with all IFC-related questions.

 

Best regards,

 

Jeremy

 

Re: How do I get all the outermost walls in the model?

$
0
0

I heard back from the development team, and they say:

 

BuildingEnvelopeAnalyzer is supposed to be a reliable method to achieve this.

 

If there are problems with the results, this should be filed as a problem report. 

 

For us to do so, please submit a minimal reproducible case:

 

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

 

To perform your own geometric analysis, you could also look for walls which don't have bounding rooms on both sides. This is easy, assuming rooms have been set in the model.

 

Cheers,

 

Jeremy

 

Re: Finding Exterior walls by BuildingEnvelopeAnalyzer

$
0
0

Dear Jinsol and Alexandra,

 

I raised this issue with the development team, and they say:

 

BuildingEnvelopeAnalyzer is supposed to be a reliable method to achieve this.

 

If there are problems with the results, this should be filed as a problem report.

 

For us to do so, please submit a minimal reproducible case:

 

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

 

To perform your own geometric analysis, you could also look for walls which don't have bounding rooms on both sides. That is easy, assuming rooms have been set in the model.

 

Cheers,

 

Jeremy

 

 

Re: Filtering exterior walls

$
0
0

I raised this issue with the development team, and they say:

 

BuildingEnvelopeAnalyzer is supposed to be a reliable method to achieve this.

 

If there are problems with the results, this should be filed as a problem report.

 

For us to do so, please submit a minimal reproducible case:

 

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

 

To perform your own geometric analysis, you could also look for walls which don't have bounding rooms on both sides. That is easy, assuming rooms have been set in the model.

 

Cheers,

 

Jeremy

 

 

Re: Create view with coloured elements

$
0
0

Thank you very much Jeremy and RPTHOMAS108,

 

I've found a solution that suits me based on your input. I'll paste it here in case someone else wants to reuse it:

 

IEnumerable<ViewFamilyType> viewFamilyTypes = from elem in new FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType))
let type = elem as ViewFamilyType
where type.ViewFamily == ViewFamily.ThreeDimensional
select type;

//And then open transaction
using (Transaction trans = new Transaction(doc, "name"))
{
trans.Start();

//create view View3D new3D = View3D.CreateIsometric(doc, viewFamilyTypes.First().Id); new3D.Name = "Name"; //Set Visual Style to Shaded = 4 new3D.get_Parameter(BuiltInParameter.MODEL_GRAPHICS_STYLE).Set(4); OverrideGraphicSettings graphics = new OverrideGraphicSettings(); //set the transparency graphics.SetSurfaceTransparency(60); //define the level of detail graphics.SetDetailLevel(ViewDetailLevel.Coarse); int index = 0; //=========================== Verifications =========================== foreach (Element element in totalElements) { //max and minimum of indicator double max = LISTA.Max(); double min = LISTA.Min(); double indicator = LISTA[index]; //in here I do the verification and withdraw the value from a list //set the color Autodesk.Revit.DB.Color color = new Autodesk.Revit.DB.Color(0, 0, 0); if (indicator > 4 / 5 * (max - min)) { color = new Autodesk.Revit.DB.Color(255, 69, 0); // Orange Red } else if (indicator > 3 / 5 * (max - min)) { color = new Autodesk.Revit.DB.Color(255, 165, 0); // Orange } else if (indicator > 2 / 5 * (max - min)) { color = new Autodesk.Revit.DB.Color(255, 255, 224); // Light yellow } else if (indicator > 1 / 5 * (max - min)) { color = new Autodesk.Revit.DB.Color(173, 255, 47); // Green yellow } else { color = new Autodesk.Revit.DB.Color(0, 128, 0); // green } //set the color graphics.SetProjectionFillColor(color); //and then fill the Patern as 'Solid Fill' //a) find the solid fill Id List<FillPatternElement> fillPatternList = new FilteredElementCollector(doc).WherePasses(new ElementClassFilter(typeof(FillPatternElement))). ToElements().Cast<FillPatternElement>().ToList(); ElementId solidFillPatternId = null; foreach (FillPatternElement fp in fillPatternList) { if (fp.GetFillPattern().IsSolidFill) { solidFillPatternId = fp.Id; break; } } //b) set the id graphics.SetProjectionFillPatternId(solidFillPatternId); //and finally I override the graphic settings of the element new3D.SetElementOverrides(element.Id, graphics); index = 0; }
trans.Commit();
}
MessageBox.Show("Views created.");

 

it is highly likely this code can be simplified, but it worked for me for now.

 

Cheers

Ruben

 


Re: Transferring Legends between Documents (unwanted duplicate legend being crea

Obtain list of all materials in elements

$
0
0

Hello everyone.

 

I would like to know if there is a method to obtain the list of all materials used in an element. I know that, if we use the Element.GetMaterialIds method we can obtain the Id list of all materials used. However, I get one Id per material (as expected). 

 

For instance, if I have Wall1 with 5 materials: cement, brick, insulation, brick, cement; I will obtain a list of 3 Ids (because 2 out of 5 are repeated). 

 

What I would like to obtain is a list with all 5 materials, regardless of being repeated. Furthermore, is it possible to obtain a list in the correct order? E.g., if cement is Finish, then I get it first, then the 2nd one, and so on.

 

Thank you all!

Ruben

Re: Export ifc access denied

$
0
0

its is really strange as i get it working for Dwg / nwc and whatsoever.

 

made absolutely sure the dir exists by doublechecking with the Directory.exists(path) bool. its returning a true (as i knew should ;) )

So i tried running as Admin: nope...

 

 

so the next step was to try a an empty string "" and that already gave me a more sensible error message:

"Modifying  is forbidden because the document has no open transaction."

 

Although i think its is a strange message. after all, Why would an export need an transaction ?

but the good thing is, it worked !!

 

so it seems that the IFC export needs to be done within an transaction, while the other exports (nwc/dwg) do not need an transaction.

 

so the final step was to again try to set a name, with the only difference that the export is done within an transaction:

All worked as designed! 

 

Re: Obtain list of all materials in elements

$
0
0

Take a look at CompoundStructure Class. Does this help:

compoundStructure  = wall.WallType.GetCompoundStructure();
IList<CompoundStructureLayer> csLayers = 
         compoundStructure.GetLayers();
foreach (CompoundStructureLayer csLayer in csLayers)
{
        ElementId matId = cslayer.MaterialId;
        //do something with Material Id
}

Re: add revit buttons to new addin

$
0
0

Hi, tnx for answer, but I already do that in a custom tab, what Id like to do is: add actually revit button in my tab,not create a custom button for custom functionality.

 

or if I need to add a custom button, there is some code, to make exactly the same actions of the button?, i mean, for example:
if you click: Insert> link revit.
then call file chooser and when select file, and link it when accept

 


Regards!

Regards!

Viewing all 67020 articles
Browse latest View live


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