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

Revit API to edit Model Line Weights for a given scale

$
0
0

Hello,

 

If you go to Manage tab, Additional Settings and select Line Weights you are presented with a dialog that has three tabs: Model Line Weights and two other which are out of my scope.

 

The question is:

 

Is there a way to edit a given line weight for a given view scale in the table? For example I'd like to set the line weight 5, for scale 1:100 to 2.8 mm, rather than 2.5mm.

 

Thanks.


Re: NewDimension between Grids - Invalid Number of references

$
0
0

Many thanks RPTHOMAS108. I lost severy hours yesterday trying to find a solution.

 

Please Autodesk dev team, update your samples and when you say "it will be available in a next major release" and two years (and major versions) it still the same, this is not very serious and professional.

 

Best regards

Extract Past Warnings From Rvt file Before 2018

$
0
0

How Exactly do i retreive Rvt Saved warnings with the api ?
if not possible i have already done it using post command and the win api but revit only lets me post command Once . is it possible to Post the review warnings command more than once ?
can i retreive the warning using the Ole Storage concept ?

 

Re: Setting conditional parameters with formulas

$
0
0

Managed to figure it out after getting some sleep! The four formulas used:

 

not(or(Flip Left Right, Left Arrow Down))

and(Flip Up Down, not(Flip Left Right))

and(Flip Left Right, not(Flip Up Down))

and(Flip Left Right, Flip Up Down)

Obtain Generic Appearance Color on MEP Curve Objects

$
0
0

Hello everybody,

 

I would like to obtain the generic appearance color on the MEP curve objects. At this time, I only succeed to retrieve this information on the surface element by using this sample of code.

 

 

      private Color GetAppearenceColor(Document doc, Face face)
        {
            Color appearenceColor = Color.InvalidColorValue;

            Material material = doc.GetElement(face.MaterialElementId) as Material;

            AppearanceAssetElement appearanceElem = material.Document.GetElement(material.AppearanceAssetId) as AppearanceAssetElement;
            Asset theAsset = appearanceElem.GetRenderingAsset();

            AssetProperty colorProperty = theAsset["generic_diffuse"];
            Type type = colorProperty.GetType();
            object apVal = null;
            try
            {
                // using .net reflection to get the value
                var prop = type.GetProperty("Value");
                if (prop != null &&
                    prop.GetIndexParameters().Length == 0)
                {
                    apVal = prop.GetValue(colorProperty);
                }
                else
                {
                    apVal = "<No Value Property>";
                }
            }
            catch (Exception ex)
            {
                apVal = ex.GetType().Name + "-" + ex.Message;
            }

            if (apVal is DoubleArray)
            {
                var doubles = apVal as DoubleArray;

                byte r = (byte)(doubles.get_Item(0) * 255);
                byte g = (byte)(doubles.get_Item(1) * 255);
                byte b = (byte)(doubles.get_Item(2) * 255);

                appearenceColor = new Color(r,g,b);
            }

            return appearenceColor;
        }

 

Could help us to find a similar approach to get this color information on the MEP curve elements?

 

Thanks for your help,

 

Philippe

Get relationship between Parts and Revit Objects

$
0
0

Hello,

 

I would like to obtain the relationship between the Revit Parts and the Revit Objects used to generate the Parts. My purpose is to know from which Revit element(s) a Revit part is created.

 

I already search a way to find this relationship with Revit Lookup without success.

 

Do you have a idea on this topic?

 

Regards,

 

Philippe

Debugger crashing when I hit a breakpoint

$
0
0

Hey all, 

 

I've worked on Revit previously, but the job already had the project built and so forth.  Now, I'm setting out on my own and creating a new Revit addin.  Everything is going fine but one thing, and you guessed it: The debugger crashes when I hit a breakpoint.  The builds for 2016-2018 are all good; they compile and all is right in the world, except when I want to step through the code to see what's happening.  I get this error every time:

Debugger_Error.png

Then, when I go to rebuild my solution, I get this:

 

Build_Error.png

 

It's not updating the DLLs because it says they're still in use.  

 

I've never started from scratch like this, and I've tried researching everything, but it feels like the answers are really vague or I have to run down a really deep rabbit hole that takes me to something completely unrelated before I find a solution.

 

What do I need to do to set up my debugger so it doesn't have a heart attack on me?

 

Side note:

  • Windows 10
  • Visual Studio 2017 Professional
  • Revit 2016,2017 & 2018
  • Computer is brand new:
    • 16GB RAM
    • 256GB SSD, 1TB Hard Drive
    • i7-7700 3.6GHz processor
    • NVIDIA GeForce GTX 1060 Graphics Card

IFC exporting model colors problem with floors

$
0
0

 Hello 

 

When exporting revit model to IFC then everything is colored as i have set them in materials but floors are acting strange .

As soon as i made opening into floors the colors go dark grey. Why? 

 

I need to send colored IFC to client put with this problem it is impossible!

 

 

 

Floor without opening has color in ifc.JPG

Example picture where in revit i exported ifc with orange floor without opening then it is colored orange in ifc  as it is in revit .

 

 

Floor with opening has no color in ifc just making it dark gray with no reason.JPG

Example picture where in revit i exported ifc with orange floor with opening then it is colored to dark grey in ifc .

 

I am using the latest IFC exporter Version 18.2.0, 7/19/2017 from

https://apps.autodesk.com/RVT/en/Detail/Index?id=6193770166503453647&appLang=en&os=Win64

 

Hope you can help to find solution.

 

Kaupo


Re: How to display XYZ points in Revit doc

$
0
0

This is what I'm talking about with Dynamo. It's clearly found a way to do it. I just can't figure out where in the Dynamo source code it's actually accomplishing this:

DynamoTempPoint.png

 

Re: Get relationship between Parts and Revit Objects

$
0
0

The Part class has a method: GetSourceElementIds.

 

If a part has been merged it may derive from more than one original source.

 

There is another method on the Part class to get the source categories used to generate the part: GetSourceElementOriginalCategoryIds.

 

 

Re: Revit 2016 addin-manager not hitting breakpoint

$
0
0

Hi Ryan, 

 

So, if I'm understanding this correctly:

  • This is a known issue with Windows 10? 
  • If I went from Windows 8 -> 10, everything should be ok; but if I started with 10 (which I did), this is going to happen? 
  • Is this strictly Windows 10, or could it be a Visual Studio 2017 issue as well?
  • Finally: If I started with Win10 and VS2017, what is my best course of action to remedy the situation?

 

Thanks for the help!  Also, I put a similar issue up with some screen shot to give you an idea of exactly what I'm going through here.

Re: Revit 2016 addin-manager not hitting breakpoint

$
0
0

 

I ended up changing some debugging options

 

This is working for me:

2017-10-03_1418.png

Re: Revit 2016 addin-manager not hitting breakpoint

$
0
0

Thanks!  I'll give it a shot.  Hopefully it works!!  Not being able to debug is severely slowing me down...

How to Sort List of CurveLoop

$
0
0

I want to sort list of curveloop by first point of curveloop, something like this:

 

lstLine = lstLine.OrderBy(l => l.GetEndPoint(0).Y).ToList();

Re: How to Sort List of CurveLoop

$
0
0

got it already

 

lstCurveLoop = lstCurveLoop.OrderBy(c => c.ElementAt(0).GetEndPoint(0).Y).ToList();
lstCurveLoop = lstCurveLoop.OrderBy(c => c.ElementAt(0).GetEndPoint(0).X).ToList();


PolyLine to Curve

$
0
0

How to get curves from polyline?

Re: PolyLine to Curve

$
0
0

Hi!

 

You can get the list of points of your polyline with polyLine.GetCoordinates() method, then you can create segments via Line.CreateBound

Re: PolyLine to Curve

$
0
0

Hi aignatovich,

 

Thank you for your reply.

That is how i am implementing it now.

I am trying to read polyline from imported cad file where the polyline consist of line and arc.

So far when i test my cad file, looks like when polyline contains arc, the arches in polyline not detected as part of polyline

but as individual arc. I wonder will this behavior be consistent for all conditions.

Is polyline in Revit can only contains lines, not arc? 

How do I start using Macros from the internet?

$
0
0

Hi!

 

I am as new as one can be in Macros for Revit.

Right now, I am not even at writing own macros, but rather copying from the internet.

 

So I found this great macro called legendOnSheets

 

This is what I did

  1. Macro Manager
  2. Created a module, C#
  3. Created a Macro, named it legendOnSheets
  4. For now, I left the  Revit Macros generated code and pasted everything inside { } from the link previously mentioned, inside {} in the Macro Editor.
  5. I compiled with F8, and got an error message that complains about  ActiveUIDocument: does not contain a definition for ActiveUIDocument

 

What am I doing wrong?

Thanks in advance!

Comment Duct accessories

$
0
0

Hi,

 

I am quite new in using revit API.  I try to set the value of the "Comments" parameter of duct accessories using this code :

 

using System;
using System.Collections.Generic;
using System.Linq;

using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;

[TransactionAttribute(TransactionMode.Manual)]
[RegenerationAttribute(RegenerationOption.Manual)]
public class CommentDuctAccessories : IExternalCommand
{
   public Result Execute(ExternalCommandData commandData,ref string message,ElementSet elements)
    {
        UIApplication uiapp = commandData.Application;
        UIDocument uidoc = uiapp.ActiveUIDocument;
        Document doc = uidoc.Document;

        ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_DuctAccessory);
        FilteredElementCollector collector = new FilteredElementCollector(doc);
        IList<Element> ductAcc = collector.WherePasses(filter).WhereElementIsNotElementType().ToElements();
        String prompt = "The duct accessories in the current document are:\n";

        foreach (Element e in ductAcc)
        {
            prompt += e.Name + "\n";
            Parameter parameter = e.LookupParameter("Comments");
            using (Transaction t = new Transaction(doc, "Set Parameter"))
            {
                t.Start("Set Parameter");
                parameter.Set("Test");
                t.Commit();
            }
        }
        TaskDialog.Show("Revit", prompt);

        return Result.Succeeded;
    }
}

 

I got no error message and the TaskDialog shows the list of duct accessories as expected.  But after running the code, revit doesn't respond once i click on any object of the model.

 

Do you know what i am doing wrong ?

 

Thank by advance for your help.

Viewing all 67020 articles
Browse latest View live


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