GithubHelp home page GithubHelp logo

gtalarico / revitapidocs.code Goto Github PK

View Code? Open in Web Editor NEW
125.0 24.0 56.0 104 KB

Python Scripts fo Repository for RevitAPIdocs.com

License: MIT License

Python 91.55% C# 7.18% HTML 1.28%
python ironpython revit-api revitpythonshell csharp

revitapidocs.code's Introduction

Revit API Docs - Code Samples

Code Sample Repository for RevitAPIdocs.com/code

This repository allows the Revit API Community to contribute to the Code Samples section of Revit API Docs.

How does it work?

The Code Samples page uses the Github API to read this repository and inject the files into the browser. [Note: for performance reasons, the code is Cached and will only be refreshed every 6 hours]

Contriutions

Who can contribute?

Anyone who writes Revit API code and would like to share them with the community.

What languages are accepted?

Python, CSharp

One off contributions

  1. Fork this repository

  2. Add / Modify the scripts on your fork

  3. Create a Pull Request

    (More info on how to Create a Pull Request from your fork here)

Regular contributions

Once you have made a few contributions, feel free to request to be added as a Repository Contributor:

  1. Create an Issue Requesting to be added as a Contributor in the Issues Page
  2. Once you have been added as a contributor, you will be able to Push directly to the repository.

Notes:

  1. Scripts should be placed in the appropriate folder, and have the expected extension for that language.
  2. The filename should be {Category}_{Name}.{ext}, for example: Snippets_CreateDraftingView.py
  3. The categories are only loosely defined, and can be revised as the code base grows.
  4. Scripts must include the license and information described below.

License and Credits

All contributions added to this repository will be shared using the MIT License. Authors can include their own credits, but they should also keep the information listed below at the beginning of each file:

{Short Description}
{Longer Description - Optional}

Tested Revit API: {comma separated years}

Author: {Name | {email, and or github page of Author}

Shared on www.revitapidocs.com
For more information visit http://github.com/gtalarico/revitapidocs
License: http://github.com/gtalarico/revitapidocs/blob/master/LICENSE.md

Examples

Filename: CreateDraftingView.py

Creates a drafting view

TESTED REVIT API: 2015, 2016, 2017

Author: Gui Talarico | github.com/gtalarico

Shared on www.revitapidocs.com
For more information visit http://github.com/gtalarico/revitapidocs
License: http://github.com/gtalarico/revitapidocs/blob/master/LICENSE.md

revitapidocs.code's People

Contributors

22mn avatar dnenov avatar franpossetto avatar gtalarico avatar robertcurry0216 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

revitapidocs.code's Issues

Add Get Floor Boundary Script

Remove rwp, simplify, document:

IronPython 2.7.7 (2.7.7.0) on .NET 4.0.30319.42000 (64-bit)

>>> doc
<Autodesk.Revit.DB.Document object at 0x000000000000054B [Autodesk.Revit.DB.Document]>

>>> rpw.db.Collector(of_class='RevitLinkInstance')
<rpw:Collector % ..DB.FilteredElementCollector | count:4>

>>> rpw.db.Collector(of_class='RevitLinkInstance').wrapped_elements
[<rpw:Element % ..DB.RevitLinkInstance | id:6846192>, <rpw:Element % ..DB.RevitLinkInstance | id:6847574>, <rpw:Element % ..DB.RevitLinkInstance | id:6847577>, <rpw:Element % ..DB.RevitLinkInstance | id:6923285>]

>>> rpw.db.Collector(of_class='RevitLinkInstance')[0]
<Autodesk.Revit.DB.RevitLinkInstance object at 0x000000000000054C [Autodesk.Revit.DB.RevitLinkInstance]>

>>> rpw.db.Collector(of_class='RevitLinkInstance')[0].Name
'Containers.rvt : 8 : location <Not Shared>'

>>> rpw.db.Collector(of_class='RevitLinkInstance')[1].Name
'AoR Model.rvt : 9 : location <Not Shared>'

>>> rpw.db.Collector(of_class='RevitLinkInstance')[2].Name
'BOG_Flormorado_EC.rvt : 10 : location <Not Shared>'

>>> ec = rpw.db.Collector(of_class='RevitLinkInstance')[2]

>>> ec
<Autodesk.Revit.DB.RevitLinkInstance object at 0x000000000000054D [Autodesk.Revit.DB.RevitLinkInstance]>

>>> rpw.db.Collector(doc=ec.Document, of_class='Floor')
<rpw:Collector % ..DB.FilteredElementCollector | count:17>

>>> rpw.db.Collector(doc=ec.Document, of_class='Floor')[3]
<Autodesk.Revit.DB.Floor object at 0x000000000000054E [Autodesk.Revit.DB.Floor]>

>>> rpw.db.Collector(doc=ec.Document, of_class='Floor')[3]
<Autodesk.Revit.DB.Floor object at 0x000000000000054F [Autodesk.Revit.DB.Floor]>

>>> rpw.db.Collector(doc=ec.Document, of_class='Floor')[4]
<Autodesk.Revit.DB.Floor object at 0x0000000000000550 [Autodesk.Revit.DB.Floor]>

>>> floor= rpw.db.Collector(doc=ec.Document, of_class='Floor')[4]

>>> Options
<type 'Options'>

>>> floor.get_Geometry(Options())
<Autodesk.Revit.DB.GeometryElement object at 0x0000000000000555 [Autodesk.Revit.DB.GeometryElement]>

>>> geo = floor.get_Geometry(Options())

>>> [g for g in geo]
[<Autodesk.Revit.DB.Solid object at 0x0000000000000556 [Autodesk.Revit.DB.Solid]>]

>>> solid = [g for g in geo][0]

>>> solid
<Autodesk.Revit.DB.Solid object at 0x0000000000000556 [Autodesk.Revit.DB.Solid]>

>>> solid.Faces
<Autodesk.Revit.DB.FaceArray object at 0x0000000000000557 [Autodesk.Revit.DB.FaceArray]>

>>> [f for f in solid.Faces]
[<Autodesk.Revit.DB.PlanarFace object at 0x0000000000000558 [Autodesk.Revit.DB.PlanarFace]>, <Autodesk.Revit.DB.PlanarFace object at 0x0000000000000559 [Autodesk.Revit.DB.PlanarFace]>, <Autodesk.Revit.DB.PlanarFace object at 0x000000000000055A [Autodesk.Revit.DB.PlanarFace]>, <Autodesk.Revit.DB.PlanarFace object at 0x000000000000055B [Autodesk.Revit.DB.PlanarFace]>, <Autodesk.Revit.DB.PlanarFace object at 0x000000000000055C [Autodesk.Revit.DB.PlanarFace]>, <Autodesk.Revit.DB.PlanarFace object at 0x000000000000055D [Autodesk.Revit.DB.PlanarFace]>]

>>> faces = [f for f in solid.Faces]

>>> faces
[<Autodesk.Revit.DB.PlanarFace object at 0x000000000000055E [Autodesk.Revit.DB.PlanarFace]>, <Autodesk.Revit.DB.PlanarFace object at 0x000000000000055F [Autodesk.Revit.DB.PlanarFace]>, <Autodesk.Revit.DB.PlanarFace object at 0x0000000000000560 [Autodesk.Revit.DB.PlanarFace]>, <Autodesk.Revit.DB.PlanarFace object at 0x0000000000000561 [Autodesk.Revit.DB.PlanarFace]>, <Autodesk.Revit.DB.PlanarFace object at 0x0000000000000562 [Autodesk.Revit.DB.PlanarFace]>, <Autodesk.Revit.DB.PlanarFace object at 0x0000000000000563 [Autodesk.Revit.DB.PlanarFace]>]

>>> faces[0]
<Autodesk.Revit.DB.PlanarFace object at 0x000000000000055E [Autodesk.Revit.DB.PlanarFace]>

>>> f = faces[0]

>>> f.FaceNormal
<Autodesk.Revit.DB.XYZ object at 0x0000000000000564 [(0.000000000, 0.000000000, -1.000000000)]>

>>> faces[0].FaceNormal
<Autodesk.Revit.DB.XYZ object at 0x0000000000000565 [(0.000000000, 0.000000000, -1.000000000)]>

>>> faces[1].FaceNormal
<Autodesk.Revit.DB.XYZ object at 0x0000000000000566 [(0.000000000, 0.000000000, 1.000000000)]>

>>> faces[2].FaceNormal
<Autodesk.Revit.DB.XYZ object at 0x0000000000000567 [(1.000000000, 0.000000000, 0.000000000)]>

>>> faces[1].FaceNormal
<Autodesk.Revit.DB.XYZ object at 0x0000000000000568 [(0.000000000, 0.000000000, 1.000000000)]>

>>> top = faces[1]

>>> top
<Autodesk.Revit.DB.PlanarFace object at 0x000000000000055F [Autodesk.Revit.DB.PlanarFace]>

>>> top.EdgeLoops
<Autodesk.Revit.DB.EdgeArrayArray object at 0x000000000000056A [Autodesk.Revit.DB.EdgeArrayArray]>

>>> [e for e in top.EdgeLoops]
[<Autodesk.Revit.DB.EdgeArray object at 0x000000000000056B [Autodesk.Revit.DB.EdgeArray]>]

>>> top.GetEdgesAsCurveLoops()
List[CurveLoop]([<Autodesk.Revit.DB.CurveLoop object at 0x000000000000056C [Autodesk.Revit.DB.CurveLoop]>])

>>> curce = top.GetEdgesAsCurveLoops()

>>> curve = top.GetEdgesAsCurveLoops()

>>> curve
List[CurveLoop]([<Autodesk.Revit.DB.CurveLoop object at 0x000000000000056D [Autodesk.Revit.DB.CurveLoop]>])

>>> [c for c in curve]
[<Autodesk.Revit.DB.CurveLoop object at 0x000000000000056D [Autodesk.Revit.DB.CurveLoop]>]

>>> curve
List[CurveLoop]([<Autodesk.Revit.DB.CurveLoop object at 0x000000000000056D [Autodesk.Revit.DB.CurveLoop]>])

>>> curve[0]
<Autodesk.Revit.DB.CurveLoop object at 0x000000000000056D [Autodesk.Revit.DB.CurveLoop]>

>>> [c for c in curve[0]]
[<Autodesk.Revit.DB.Line object at 0x000000000000056E [Autodesk.Revit.DB.Line]>, <Autodesk.Revit.DB.Line object at 0x000000000000056F [Autodesk.Revit.DB.Line]>, <Autodesk.Revit.DB.Line object at 0x0000000000000570 [Autodesk.Revit.DB.Line]>, <Autodesk.Revit.DB.Line object at 0x0000000000000571 [Autodesk.Revit.DB.Line]>]

>>> [c for c in curve[0]][0]
<Autodesk.Revit.DB.Line object at 0x0000000000000572 [Autodesk.Revit.DB.Line]>

>>> line = [c for c in curve[0]][0]

>>> line.GetEndParameter(0)
0.0

>>> line
<Autodesk.Revit.DB.Line object at 0x0000000000000573 [Autodesk.Revit.DB.Line]>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.