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

Re: import rhino into revit


3D VIEW TO WINDOWS COORDINATE

$
0
0

Hello to all of you
someone has an example of code to find a point in general coordination from a 3d view to its equivalent in windows point I can do it on a 2d view but in 3d it exceeds my skills

thank you


 

Re: 3D VIEW TO WINDOWS COORDINATE

Re: 3D VIEW TO WINDOWS COORDINATE

$
0
0
thanks for the answer but i would like the opposite of this method

to know a xyz point of revit in 3d view to coord windows and not a windows 2d coordinate to xyz in revit 3dview.

 

Possible to retrieve instance driven filled region area parameter from family?

$
0
0

Hi,

I'm working on a experiment to get the filled region area parameter value from a detail item family instance. I can get the parameter value by using FilteredElementCollector(Family Document). But this value is only belong to the default filled region size inside the family document. I'm wondering if is possible to retrieve the value from the project document where the region area is driven by the instance parameter inputs in the project. My goal is to retrieve the the area parameter value without writing a formula, so I can easier to handle more complex shapes.  Thank you!

In Family Editor:                                  

filledRegion_1.png

In Project:

filledRegion_2.png

Creates a new duct from two points with revit 2019 api

$
0
0

Hi everyone,

I have a little problem. I could not get the systemTypeId to create the wind pipe from 2 points (XYZ) with a new project. I use the function following:

public static Duct Create(
	Document document,
	ElementId systemTypeId,
	ElementId ductTypeId,
	ElementId levelId,
	XYZ startPoint,
	XYZ endPoint
)

In the 2016 revit version I used the a function very easily but i can't found this function in above Revit 2017 version.

public Duct NewDuct(
	XYZ point1,
	XYZ point2,
	DuctType ductType
)

Please help me. Thank you.

Best regards

 

 

 

 

 

 

Model Group

$
0
0

dear everyone
simple way to (only) load a model group
(load as group)

Does BoundingBoxIntersectsFilter work for text note?

$
0
0
I created two overlap text notes in a document, and run the code below, seems BoundingBoxIntersectsFilter does not work for text note. What's wrong? Any other easy way to check if text notes are interesected? Thanks. RevitDb.FilteredElementCollector collectorNotes = new RevitDb.FilteredElementCollector(Document.RevitDoc) .OfClass(typeof(RevitDb.TextNote)); var notes = collectorNotes.ToElements(); foreach (RevitDb.TextNote note in notes) { var view = Document.RevitDoc.GetElement(note.OwnerViewId) as RevitDb.View; var box = note.get_BoundingBox(view); var ol = new RevitDb.Outline(box.Min, box.Max); RevitDb.FilteredElementCollector collector = new RevitDb.FilteredElementCollector(Document.RevitDoc) .OfClass(typeof(RevitDb.TextNote)) .WherePasses(new RevitDb.BoundingBoxIntersectsFilter(ol)); var elements = collector.ToElements(); if (elements.Count > 0) { } }

Re: Simple user input

$
0
0

Clearly this is a solution I hadn´t considered. Very original and do the point. Anyway this seems to be even harder than forms so im guesssing thats what Im gonna use. Thanks you so much for your anwser. Very complete and very didactid.

Regards.

Re: Possible to retrieve instance driven filled region area parameter from famil

$
0
0

I'm also curious if there is an efficient way to do this. Hopefully someone more experienced has a better method.

 

The only way that I know how to do this is as follows:

  1. In your project document, collect the instance parameter values that control the filled region in question for every instance that you need to record and save them.
  2. Using the Document.EditFamily() method, open the family document
  3. Start a temporary transaction within the family document
  4. Using the FamilyManager in the family document, set the instance values of the parameters saved from above.
  5. Using the known ElementId or UniqueId of the filled region in question, find and save the area value of  the filled region.
  6. Repeat steps 4 and 5 for each instance you need the area of. 
  7. RollBack the temporary transaction.

Definition vs Pameter. InternalDefinition vs ExternalDefinition.

$
0
0

Hi there. I got this concept a little bit unclear. So I have created a shared parameter using the Definition Class. 

According to API "definition" is a base class that supports the addition of new parameter definitions. Allright, then I want to use that parameter to create a filter so I need to fit:

 

ParameterValueProvider pvp = new ParameterValueProvider(MyParameter.Id);

 

I can see that the subtypes of Definition are Internal or External. While inserting the parameter in the project I have to use externalDefinition object cause Im working with a shared parameter. But ExternalDefinition doesn´t have .Id property. InternalDefinition have this .Id property but I dont know how to correlate one Definition to another in my code.

Seems strange that there isn´t a way to retrieve the new parameter you just created with the Definition without doing that through an element in a different process. Any ideas? Regards.

Re: Efficient way to check if an element exists in a view

$
0
0

Stopping the collector at the first element:

Element e = new FilteredElementCollector(doc, view.Id).OfClass(typeof(ImportInstance)).FirstElement();

Possible Speed improvement:

  • Select all ImportInstances
  • check if its a DWG:
  • if no: exclude from collector in view-loop. (=> no need for category.Name check in loop)
  • if yes:   if dwg is ViewSpecific, i.e. is "2D annotation"in view, (=> ownerview contains dwg, and can be added to viewsWithCAD, and ownerview can be excluded from view-loop)

 

IEnumerable<ImportInstance> instances = new FilteredElementCollector(doc)
            	.OfClass(typeof(ImportInstance))
            	.Cast<ImportInstance>();
List<ElementId> toExclude = new List<ElementId>();
foreach(ImportInstance instance in instances)
{
    if ( !instance.Category.Name.EndsWith(".dwg"))
    {
    	toExclude.Add(instance.Id);
    	continue;
    }
    if( instance.ViewSpecific) // dwg only exists in ownerview
    {
    	View ownerview = doc.GetElement(instance.OwnerViewId) as View;
    	viewsWithCAD.Add(ownerview);
    	if( viewElements.Contains(ownerview)) viewElements.Remove(ownerview);
    }
}
foreach (Element viewElement in viewElements)
{
    View view = (View)viewElement;
    var stopwatch = new Stopwatch();
    stopwatch.Start();
    Element e = null;
    if (toExclude.Count>0)
    {
	e = new FilteredElementCollector(doc, view.Id)
			.Excluding(toExclude)
			.OfClass(typeof(ImportInstance))
			.FirstElement();
    } else{
	e = new FilteredElementCollector(doc, view.Id)
			.OfClass(typeof(ImportInstance))
			.FirstElement();
    }
    stopwatch.Stop();
    Debug.WriteLine(view.Name + ": " + stopwatch.ElapsedMilliseconds + "ms");

    if(e!=null) //if the current view contains at least 1 DWG ImportInstance, then the view is added to the list
    {
        viewsWithCAD.Add(view);
    }
}

Re: Get Face From PickObject(ObjectType.Face)

$
0
0

As the link:

https://forums.autodesk.com/t5/revit-api-forum/check-out-the-self-paced-guide-my-first-plug-in/m-p/3032684#U3032684

with this statement:

"Note on 5/11/2018: My First Plug-in is being migrated to Knowledge Base (similar to this forum). Right now, the marketing URL is not working. In a mean time, you can access here:
https://knowledge.autodesk.com/community/collection/my-first-autodesk-revit-plug

Still work in progress. Working on updating all the links, to the latest three releases, etc."

 

However as the picture show the link is "Not Found"?!

Could someone give a hand? thx~

404.jpg

Re: I want to draw plane in project

$
0
0

I knew I had to use DirectShape through trial and error..!

(Previously, I made the desired polygon shape, but its type was a ModelLine...it was not polygon..)

 

The code at the bottom is the code that makes HermiteSpline!

 

doc=__revit__.ActiveUIDocument.Document

transV = Transaction( doc, 'TEST')
transV.Start("test")

builder=WireframeBuilder()

points=[]

points.append(XYZ(0, 0, 0))
points.append(XYZ(10, 0, 0))
points.append(XYZ(10, 10, 0))
points.append(XYZ(0, 10, 0))

points.append(XYZ(0, 0, 5))    
points.append(XYZ(10, 0, 5))
points.append(XYZ(10, 10, 5))
points.append(XYZ(0, 10, 5))

points.append(XYZ(0, 0, 10))
points.append(XYZ(10, 0, 10))
points.append(XYZ(10, 10, 10))
points.append(XYZ(0, 10, 10))

builder.AddCurve(HermiteSpline.Create(points, False))
categoryId = ElementId(BuiltInCategory.OST_GenericModel)
ds = DirectShape.CreateElement(doc, categoryId)
ds.SetShape(builder)

transV.Commit()

I want to change red code to fit a polygon!! 

 

This picture is my desired picture

캡처.PNG

I have 6 points information..! like this

points.append(XYZ(-10848.766951799216, 14340.654043232033, 46287.753331318323))
points.append(XYZ(-19322.304456566035, -335.94343486409929, 46287.753331318323))
points.append(XYZ(-11195.841935968094, -14411.389406344417, 46287.753331318323))
points.append(XYZ(7826.249840568762, -14411.389406344702, 46287.753331318323))
points.append(XYZ(16126.249853251407, -35.367681556537747, 46287.753331318323))
points.append(XYZ(7826.2498405691467, 14340.654043231816, 46287.753331318323))

please..save me...ㅠㅠ

 

Re: Does BoundingBoxIntersectsFilter work for text note?

$
0
0

I was trying the same thing a while ago. Here's what I know:

 

BoundingBoxIntersectsFilter only works on 3d Elements. 2d Elements are ignored.

What you can do, though you must decide for yourself if this is worth it, is the folowing:

 

For every textnote, use it's bounding box to create a new 3d Solid. This new 3d Solid will have the same dimensions ans position as the textNote, therefore you can use it as a subsitute for the textnote and use the BoundingBoxIntersectionFilter.

 

(Note: If you ever try this with Tags, please consider the fact that the boudingBox of a tag goes all the way from the tag itself to the tagged item, and thus is much larger than the tag itself).

 


Re: Creates a new duct from two points with revit 2019 api

$
0
0

Hi  ,

try using the below code

MEPSystemType mepSystemType = new FilteredElementCollector(doc)
        .OfClass(typeof(MEPSystemType))
        .Cast<MEPSystemType>()
        .FirstOrDefault(sysType => sysType.SystemClassification == MEPSystemClassification.SupplyAir);

MEPSystemClassification classify MEP connectors and systems and drives certain behavior for a particular system type

MEPSystemClassification 

 

I hope this helps.

Re: Model Group

Re: Is the first Edgeloop still the outer loop?

$
0
0

Yes, got them. And it does the job quite nicly, for reference once again:

https://thebuildingcoder.typepad.com/blog/2015/01/wall-elevation-profiles-in-the-building-coder-samples.html

 

On friday I was a bit made that this functionality is hidden away in a class that is called 

Autodesk.Revit.DB.IFC.ExporterIFCUtils.SortCurveLoops

I mean it is obvious that you have to look into the ExporterIFCUtils namespace in order to make a distinction between inner and outer boundary loops.... 

 

But today I feel like a little kid looking for easter eggs, I wounder what more is hidden within the Revit API.

Maybe there is a line saying:

 

"This apt has super easter bunny powers"

Re: Creates a new duct from two points with revit 2019 api

$
0
0

Autodesk.Revit.DB.Mechanical.DuctType ductType = GetDuctType();
ElementId levelId=GetLevelId();
XYZ startPoint = new XYZ();
XYZ endPoint = new XYZ(100, 100,0);

var mecSystem = new FilteredElementCollector(doc)
.OfClass(typeof(MEPSystem))
.Cast<MEPSystem>()
.FirstOrDefault(sysType => sysType.GetType() == typeof(MechanicalSystem));
ElementId systemTypeId = mecSystem.GetTypeId();
Duct duct = Duct.Create(doc,systemTypeId, ductType.Id,levelId,startPoint,endPoint);

in the project if I have not set the equipment, air terminals, ducts then mecSystem = null

Is there a way to still create a duct with the Duct.Create function without having to draw the duct first in the revit?

 

 

 

 

 

Re: Creates a new duct from two points with revit 2019 api

$
0
0

Hi  ,

Yes, it is possible to create a duct with the Duct.Create() without having to draw the duct first in the Revit.

Here is the complete code to draw a duct in Revit using Revit API

 

Level L;

                FilteredElementCollector collector = new FilteredElementCollector(doc).OfClass(typeof(DuctType)).WhereElementIsElementType();
                DuctType DT = collector.First() as DuctType;

                MEPSystemType mepSystemType = new FilteredElementCollector(doc)
         .OfClass(typeof(MEPSystemType))
         .Cast<MEPSystemType>()
         .FirstOrDefault(sysType => sysType.SystemClassification == MEPSystemClassification.SupplyAir);

                Duct duct = Duct.Create(doc,mepSystemType.Id ,DT.Id, L.Id,new XYZ(0, 0, 0), new XYZ(100, 100, 0));

If you still have any questions...can you please explain briefly?

 

 

Please note:sys.SystemClassification and sys.GetType() are doing different operations here.

Here we are filtering duct type and duct system type from the project not from the placed elements.

Viewing all 66690 articles
Browse latest View live


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