Você está na página 1de 143

Página 2

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.


www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade
Página 3
Página 4

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
........................................................................................................... 11

........................................................................ 14

........................................................................................ 19

....................................................................................... 29

Página 5
Página 6

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
....................................................................................................................... 174

................................................................................................................. 137

Página 7
Página 8

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
.................................................................................................................... 285

Página 9
Página 10

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 11
Página 12

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 13
Página 14

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 15
Página 16

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 17
Página 18

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 19
Página 20

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 21
Página 22

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 23
Página 24

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 25
Página 26

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 27
Página 28

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 29
Página 30

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 31
Página 32

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 33
Página 34

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 35
Página 36

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 37
Página 38

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 39
Página 40

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 41
Página 42

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 43
Página 44

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 45
Página 46

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 47
Página 48

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 49
Página 50

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 51
Página 52

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 53
Página 54

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 55
Página 56

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 57
Página 58

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 59
Página 60

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 61
Página 62

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 63
Página 64

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 65
Página 66

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 67
Página 68

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 69
Página 70

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 71
Página 72

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 73
Página 74

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 75
Página 76

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 77
Página 78

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 79
Página 80

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 81
Página 82

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 83
Página 84

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 85
Página 86

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 87
Página 88

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 89
Página 90

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 91
Página 92

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 93
Página 94

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 95
Página 96

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 97
Página 98

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 99
Página 100

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 101
Página 102

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
{
"license": "",
"file_hash": null,
"name": "Dynamo Unchained - ZeroTouch",
"version": "1.0.0",
"description": "ZeroTouch sample node for the Dynamo Unchained workshop",
"group": "",
"keywords": null,
"dependencies": [],
"contents": "",
"engine_version": "1.3.0.0",
"engine": "dynamo",
"engine_metadata": "",
"site_url": "",
"repository_url": "",
"contains_binaries": true,
"node_libraries": [
"DynamoUnchained.ZeroTouch, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
]
}

Página 103
Página 104

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
<?xml version="1.0"?>
<doc>
<assembly>
<name>DynamoUnchained.ZeroTouch</name>
</assembly>
<namespaces>
namespace DynamoUnchained.ZeroTouch <namespace name="DynamoUnchained.ZeroTouch">
{ <category>eTlipse_v_20190806</category>
public static class OlaDynamo{ </namespace>
public static string DigaOla(string Nome) { </namespaces>
return "Olá " + Nome + "!"; </doc>
}
}
}

public static double MediaNumerica(double Numero1, double Numero2) {


return ((Numero1 + Numero2) / 2);
}

Página 105
Página 106

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
foreach (var i in list) {
if (i % 2 == 0) {
pares.Add(i);
} else {
impares.Add(i);
}
}

// Cria um dicionário e o retorna


var d = new Dictionary<string, object>();
d.Add("pares", pares);
d.Add("impares", impares);
return d;

// O código acima pode ser simplificado em uma linha


//return new Dictionary<string, object> { { "par", par }, { "impar", impar
} };
}

public static IList AddItemToEnd([ArbitraryDimensionArrayImport] object item,


IList list) {
return new ArrayList(list) //Clone original list
{
item //Add item to the end of cloned list.
};
}

using Autodesk.DesignScript.Runtime;

[MultiReturn(new[] { "pares", "impares" })]


public static Dictionary<string, object> SeparaImparPar(List<int> list) {
var pares = new List<int>();
var impares = new List<int>();

// Checa se o inteiro é par ou ímpar

Página 107
Página 108

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.DesignScript.Runtime;
[MultiReturn(new[] { "X", "Y", "Z" })] using Autodesk.DesignScript.Geometry;
public static Dictionary<string, object> PointCoordinates(Point point) {
return new Dictionary<string, object> { { "X", point.X }, { "Y", point.Y
}, { "Z", point.Z } }; namespace DynamoUnchained.ZeroTouch
} {
public static Line ByCoordinates(double X1, double Y1, double Z1, double X2, public static class DynamoPersonalizado{
double Y2, double Z2) {
var p1 = Point.ByCoordinates(X1, Y1, Z1); public static string DigaOla(string Nome) {
var p2 = Point.ByCoordinates(X2, Y2, Z2); return "Olá " + Nome + "!";
}
return Line.ByStartPointEndPoint(p1, p2);
} public static double MediaNumerica(double Numero1, double Numero2) {
return ((Numero1 + Numero2) / 2);
}

[MultiReturn(new[] { "pares", "impares" })]


public static Dictionary<string, object> SeparaImparPar(List<int> list) {
var pares = new List<int>();
var impares = new List<int>();

// Checa se o inteiro é par ou ímpar


foreach (var i in list) {
if (i % 2 == 0) {
pares.Add(i);
} else {
impares.Add(i);
}
public static Line ByCoordinatesReturnInteger(double X1, double Y1, double Z1, }
double X2, double Y2, double Z2) {
var p1 = Point.ByCoordinates(X1, Y1, Z1); // Cria um dicionário e o retorna
var p2 = Point.ByCoordinates(X2, Y2, Z2); var d = new Dictionary<string, object>();
var l = Line.ByStartPointEndPoint(p1, p2); d.Add("pares", pares);
p1.Dispose(); d.Add("impares", impares);
p2.Dispose(); return d;
return l;
} // O código acima pode ser simplificado em uma linha
//return new Dictionary<string, object> { { "par", par }, { "impar", impar
public static Line ByCoordinatesReturnLine(double X1, double Y1, double Z1, } };
double X2, double Y2, double Z2) { }
using (var p1 = Point.ByCoordinates(X1, Y1, Z1)) {
using (var p2 = Point.ByCoordinates(X2, Y2, Z2)) { [MultiReturn(new[] { "X", "Y", "Z" })]
return Line.ByStartPointEndPoint(p1, p2); public static Dictionary<string, object> PointCoordinates(Point point) {
} return new Dictionary<string, object> { { "X", point.X }, { "Y", point.Y
} }, { "Z", point.Z } };
} }

public static Line ByCoordinates(double X1, double Y1, double Z1, double X2,
double Y2, double Z2) {
var p1 = Point.ByCoordinates(X1, Y1, Z1);
var p2 = Point.ByCoordinates(X2, Y2, Z2);

Página 109
Página 110

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
return Line.ByStartPointEndPoint(p1, p2);
}

public static Line ByCoordinatesReturnInteger(double X1, double Y1, double Z1,


double X2, double Y2, double Z2) {
var p1 = Point.ByCoordinates(X1, Y1, Z1);
var p2 = Point.ByCoordinates(X2, Y2, Z2);
var l = Line.ByStartPointEndPoint(p1, p2);
p1.Dispose();
p2.Dispose();
return l;
}

public static Line ByCoordinatesReturnLine(double X1, double Y1, double Z1,


double X2, double Y2, double Z2) {
using (var p1 = Point.ByCoordinates(X1, Y1, Z1)) {
using (var p2 = Point.ByCoordinates(X2, Y2, Z2)) {
return Line.ByStartPointEndPoint(p1, p2);
}
}
}

}
}

Página 111
Página 112

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
public static Autodesk.Revit.DB.Wall wall1; // Revit wall
public static Revit.Elements.Wall wall2; // Dynamo wall

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.DesignScript.Runtime;
using Autodesk.DesignScript.Geometry;

Página 113
Página 114

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
using Autodesk.Revit.DB;
using Revit.Elements;
using RevitServices.Persistence; /// <summary>
using Revit.GeometryConversion; /// Converte uma em uma lista de segmentos
/// </summary>
namespace DynamoUnchained.ZeroTouch /// <param name="text">String a ser convertida</param>
{ /// <param name="size">Tamanho do texto</param>
public static class DynamoPersonalizado{ /// <returns></returns>
[IsVisibleInDynamoLibrary(false)]
public static Autodesk.DesignScript.Geometry.Curve public static IEnumerable<Line> TextToLines(string text, int size) {
GetWallBaseline(Revit.Elements.Wall wall) { List<Line> lines = new List<Line>();
//get Revit Wall
var revitWall = wall.InternalElement; //using System.Drawing para conversão para pontos da fonte
//revit API using (Font font = new System.Drawing.Font("Arial", size,
var locationCurve = revitWall.Location as LocationCurve; FontStyle.Regular))
//convert to Dynamo and return it using (GraphicsPath gp = new GraphicsPath())
return locationCurve.Curve.ToProtoType(); using (StringFormat sf = new StringFormat()) {
} sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;

} gp.AddString(text, font.FontFamily, (int)font.Style, font.Size, new


} PointF(0, 0), sf);
// Converte os pontos da fonte para pontos do Dynamo
var points = gp.PathPoints.Select(p =>
Autodesk.DesignScript.Geometry.Point.ByCoordinates(p.X, -p.Y, 0)).ToList();
var types = gp.PathTypes;

Autodesk.DesignScript.Geometry.Point start = null;


// Cria linhas
for (var i = 0; i < types.Count(); i++) {
//Types:
//0 início de uma forma
//1 ponto em linha
//3 ponto em curva
//129 fim parcial de linha
using System; //131 fim parcial de curva
using System.Collections.Generic; //161 fim de linha
using System.Linq; //163 fim de curva
using System.Text; if (types[i] == 0) {
using System.Threading.Tasks; start = points[i];
using Autodesk.DesignScript.Runtime; }
using Autodesk.DesignScript.Geometry; // Algumas letras precisam ser fechadas e outras não
using Autodesk.Revit.DB; if (types[i] > 100) {
using Revit.Elements; if (!points[i].IsAlmostEqualTo(start)) {
using RevitServices.Persistence; lines.Add(Line.ByStartPointEndPoint(points[i], start));
using Revit.GeometryConversion; }
using System.Drawing; } else {
using System.Drawing.Drawing2D; lines.Add(Line.ByStartPointEndPoint(points[i], points[i +
1]));
namespace DynamoUnchained.ZeroTouch }
{ }
public static class DynamoPersonalizado{ // Descartar os pontos
foreach (var point in points) {
public static Autodesk.DesignScript.Geometry.Curve point.Dispose();
GetWallBaseline(Revit.Elements.Wall wall) { }
//get Revit Wall return lines;
var revitWall = wall.InternalElement; }
//revit API }
var locationCurve = revitWall.Location as LocationCurve;
//convert to Dynamo and return it
return locationCurve.Curve.ToProtoType(); }
} }

Página 115
Página 116

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
/// <summary>
/// Text to Wall gera paredes Revit baseado na entrada de um texto para
orientar as curvas
/// </summary>
/// <param name="text">Texto para converter em linhas base Wall</param>
/// <param name="height"> Altura da Parede</param>
/// <param name="level"> Nivel da Parede</param>
/// <param name="wallType"> Tipo de Parede</param>
/// <param name="size"> Tamanho da Fonte</param>
/// <returns></returns>
public static IEnumerable<Revit.Elements.Wall> TextToWall(string text, double
height, Revit.Elements.Level level, Revit.Elements.WallType wallType, int size = 25) {
// Primeiro checar as entradas
if (level == null) {
throw new ArgumentNullException("level");
}

if (wallType == null) {
throw new ArgumentNullException("wallType");
}

var walls = new List<Revit.Elements.Wall>();


var lines = DynamoPersonalizado.TextToLines(text, size);

// Criação e modificação de elementos devem estar dentro de uma transação


TransactionManager.Instance.EnsureInTransaction(Document);

foreach (var curve in lines) {


if (curve == null) {
throw new ArgumentNullException("curve");
}
using System; try {
using System.Collections.Generic; var wall = Autodesk.Revit.DB.Wall.Create(Document,
using System.Linq; curve.ToRevitType(), wallType.InternalElement.Id, level.InternalElement.Id, height,
using System.Drawing; 0.0, false, false);
using System.Drawing.Drawing2D; walls.Add(wall.ToDSType(false) as Revit.Elements.Wall);
using Autodesk.Revit.DB; //Revit API } catch (Exception ex) {
using Revit.Elements; //Dynamo Revit Elements throw new ArgumentException(ex.Message);
using RevitServices.Persistence; }
using RevitServices.Transactions;
using Revit.GeometryConversion; }
using Autodesk.DesignScript.Runtime;
TransactionManager.Instance.TransactionTaskDone();
namespace DynamoUnchained.ZeroTouch {
public static class DynamoPersonalizado { return walls;
public static Autodesk.DesignScript.Geometry.Curve }
GetWallBaseline(Revit.Elements.Wall wall) {
// Pegar Revit Wall internal static Autodesk.Revit.DB.Document Document {
var revitWall = wall.InternalElement; get { return DocumentManager.Instance.CurrentDBDocument; }
// Revit API }
var locationCurve = revitWall.Location as LocationCurve;
// Converte para Dynamo e o retorna /// <summary>
return locationCurve.Curve.ToProtoType(); /// Converte uma string em uma lista de segmentos
} /// </summary>
/// <param name="text"> String para converter</param>
/// <param name="size"> Tamanho do texto</param>
/// <returns></returns>
[IsVisibleInDynamoLibrary(false)]
public static IEnumerable<Autodesk.DesignScript.Geometry.Line>
TextToLines(string text, int size) {

Página 117
Página 118

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
List<Autodesk.DesignScript.Geometry.Line> lines = new
List<Autodesk.DesignScript.Geometry.Line>();

//using System.Drawing para conversão em pontos da fonte


using (Font font = new System.Drawing.Font("Arial", size,
FontStyle.Regular))
using (GraphicsPath gp = new GraphicsPath())
using (StringFormat sf = new StringFormat()) {
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;

gp.AddString(text, font.FontFamily, (int)font.Style, font.Size, new


PointF(0, 0), sf);

// Converte pontos da fonte para pontos Dynamo


var points = gp.PathPoints.Select(p =>
Autodesk.DesignScript.Geometry.Point.ByCoordinates(p.X, -p.Y, 0)).ToList();
var types = gp.PathTypes;

Autodesk.DesignScript.Geometry.Point start = null;


// Cria linhas
for (var i = 0; i < types.Count(); i++) {
//Types:
//0 início da forma
//1 ponto em linha
//3 ponto em curva
//129 parcial final de linha
//131 parcial final de curva
//161 final de linha
//163 final de curva
if (types[i] == 0) {
start = points[i];
}
// Algumas letras precisam ser fechadas e outras não
if (types[i] > 100) {
if (!points[i].IsAlmostEqualTo(start)) {

lines.Add(Autodesk.DesignScript.Geometry.Line.ByStartPointEndPoint(points[i], start));
}
} else {

lines.Add(Autodesk.DesignScript.Geometry.Line.ByStartPointEndPoint(points[i], points[i
+ 1]));
}
}
// Descartar pontos
foreach (var point in points) {
point.Dispose();
}
return lines;
}
}

}
}

Página 119
Página 120

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
<Window x:Class="WPFApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPFApp"
mc:Ignorable="d"
Title="MainWindow" SizeToContent="WidthAndHeight">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<CheckBox Grid.Row="0" Margin="5" Name="EnabledCheckBox" Content="Enabled"
HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Slider Grid.Row="1" Margin="5" Name="ValueSlider" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="100"/>
<Button Grid.Row="2" Margin="5" Content="Click me!" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="75" Click="Button_Click"/>
</Grid>
</Window>

Página 121
Página 122

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<CheckBox Grid.Row="0" Margin="5" Name="EnabledCheckBox" Content="Enabled"
HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Slider Grid.Row="1" Margin="5" Name="ValueSlider" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="100"/>
<Button Grid.Row="2" Margin="5" Content="Click me!" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="75" Click="Button_Click"
IsEnabled="{Binding ElementName=EnabledCheckBox, Path=IsChecked}"/>
</Grid>
</Window>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WPFApp {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}

private void Button_Click(object sender, RoutedEventArgs e) {


MessageBox.Show("Value is " + ValueSlider.Value);
}
}
}

<Window x:Class="WPFApp.MainWindow" <UserControl x:Class="WPFApp.MyCustomControl"


xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFApp" xmlns:local="clr-namespace:WPFApp"
mc:Ignorable="d" mc:Ignorable="d"
Title="MainWindow" SizeToContent="WidthAndHeight"> d:DesignHeight="450" d:DesignWidth="800">

Página 123
Página 124

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
<Grid> <Grid Margin="10">
<Grid.RowDefinitions> <local:MyCustomControl/>
<RowDefinition Height="Auto"/> </Grid>
<RowDefinition Height="Auto"/> </Window>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<CheckBox Grid.Row="0" Margin="5" Name="EnabledCheckBox" Content="Enabled"
HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Slider Grid.Row="1" Margin="5" Name="ValueSlider" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="100"/>
<Button Grid.Row="2" Margin="5" Content="Click me!" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="75" Click="Button_Click"
using System;
IsEnabled="{Binding ElementName=EnabledCheckBox, Path=IsChecked}"/>
</Grid> using System.Collections.Generic;
using System.Linq;
</UserControl>
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System;
using System.Windows.Input;
using System.Collections.Generic;
using System.Windows.Media;
using System.Linq;
using System.Windows.Media.Imaging;
using System.Text;
using System.Windows.Navigation;
using System.Threading.Tasks;
using System.Windows.Shapes;
using System.Windows;
using System.Windows.Controls;
namespace WPFApp {
using System.Windows.Data;
/// <summary>
using System.Windows.Documents;
/// Interaction logic for MainWindow.xaml
using System.Windows.Input;
/// </summary>
using System.Windows.Media;
public partial class MainWindow : Window {
using System.Windows.Media.Imaging;
public MainWindow() {
using System.Windows.Navigation;
InitializeComponent();
using System.Windows.Shapes;
}
}
namespace WPFApp {
}
/// <summary>
/// Interaction logic for MyCustomControl.xaml
/// </summary>
public partial class MyCustomControl : UserControl {
public MyCustomControl() {
InitializeComponent();
}

private void Button_Click(object sender, RoutedEventArgs e) {


MessageBox.Show("Value is " + ValueSlider.Value);
}
}
}

<Window x:Class="WPFApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPFApp"
mc:Ignorable="d"
Title="MainWindow" SizeToContent="WidthAndHeight">

Página 125
Página 126

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
/* dynamo directives */
using Dynamo.Graph.Nodes;
{
namespace DynamoUnchained.ExplicitNode {
"license": "",
[NodeName("HelloUI")]
"file_hash": null,
[NodeDescription("Sample Explicit Node")]
"name": "Dynamo Unchained - ExplicitNode",
[NodeCategory("Dynamo Unchained.Explicit Node")]
"version": "1.0.0",
[IsDesignScriptCompatible]
"description": "ExplicitNode sample node for the Dynamo Unchained workshop",
public class HelloUI : NodeModel {
"group": "",
public HelloUI() {
"keywords": null,
"dependencies": [],
}
"contents": "",
}
"engine_version": "1.3.0.0",
}
"engine": "dynamo",
"engine_metadata": "",
"site_url": "",
"repository_url": "",
"contains_binaries": true,
"node_libraries": [
"DynamoUnchained.ExplicitNode, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null"
]
}

Página 127
Página 128

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
/* dynamo directives */
using Dynamo.Controls;
using Dynamo.Wpf;

namespace DynamoUnchained.ExplicitNode {
public class HelloUINodeView : INodeViewCustomization<HelloUI> {
public void CustomizeView(HelloUI model, NodeView nodeView) {
var ui = new MyCustomControl();
nodeView.inputGrid.Children.Add(ui);
ui.DataContext = model;
}

public void Dispose() {


}
}
}

Página 129
Página 130

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
using Autodesk.DesignScript.Runtime;
namespace DynamoUnchained.ExplicitNode.Functions {
[IsVisibleInDynamoLibrary(false)]
public static class Functions {
public static double MultiplyTwoNumbers(double a, double b) {
return a * b;
}
}
}

Página 131
Página 132

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
new Func<double, double,
double>(Functions.Functions.MultiplyTwoNumbers),
new List<AssociativeNode> { inputAstNodes[0], sliderValue });

return new[] {
AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), functionCall) };
}
}
}

<UserControl x:Class="DynamoUnchained.ExplicitNode.MyCustomControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
using System; xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
using System.Collections.Generic; xmlns:local="clr-namespace:DynamoUnchained.ExplicitNode"
/* dynamo directives */ mc:Ignorable="d"
using Dynamo.Graph.Nodes; d:DesignHeight="450" d:DesignWidth="800">
using ProtoCore.AST.AssociativeAST; <Grid>
<Grid.RowDefinitions>
namespace DynamoUnchained.ExplicitNode { <RowDefinition Height="Auto"/>
[NodeName("HelloUI")] <RowDefinition Height="Auto"/>
[NodeDescription("Sample Explicit Node")] <RowDefinition Height="Auto"/>
[NodeCategory("DynamoUnchained")] </Grid.RowDefinitions>
[InPortNames("A")] <CheckBox Grid.Row="0" Margin="5" Name="EnabledCheckBox" Content="Enabled"
[InPortTypes("double")] HorizontalAlignment="Left" VerticalAlignment="Top"/>
[InPortDescriptions("Number A")] <Slider
[OutPortNames("Output")] Name="ValueSlider"
[OutPortTypes("double")] Grid.Row="1"
[OutPortDescriptions("Product of two numbers")] Width="100"
[IsDesignScriptCompatible] Margin="5"
public class HelloUI : NodeModel { HorizontalAlignment="Left"
public HelloUI() { VerticalAlignment="Top"
RegisterAllPorts(); IsSnapToTickEnabled="True"
} TickFrequency="1"
Value="{Binding SliderValue}"/>
private double _sliderValue; <Button Grid.Row="2" Margin="5" Content="Click me!" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="75" Click="Button_Click"
public double SliderValue { IsEnabled="{Binding ElementName=EnabledCheckBox, Path=IsChecked}"/>
get { return _sliderValue; } </Grid>
set { </UserControl>
_sliderValue = value;
RaisePropertyChanged("SliderValue");
OnNodeModified(false);
}
}

public override IEnumerable<AssociativeNode>


BuildOutputAst(List<AssociativeNode> inputAstNodes) {
if (!HasConnectedInput(0)) {
return new[] { {
AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), "license": "",
AstFactory.BuildNullNode()) }; "file_hash": null,
} "name": "Dynamo Unchained - ExplicitNode",
var sliderValue = AstFactory.BuildDoubleNode(SliderValue); "version": "1.0.0",
var functionCall = "description": "ExplicitNode sample node for the Dynamo Unchained workshop",
AstFactory.BuildFunctionCall( "group": "",
"keywords": null,

Página 133
Página 134

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
"dependencies": [],
"contents": "",
"engine_version": "1.3.0.0",
"engine": "dynamo",
"engine_metadata": "",
"site_url": "",
"repository_url": "",
"contains_binaries": true,
"node_libraries": [
"DynamoUnchained.ExplicitNode, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null",
"DynamoUnchained.ExplicitNode.Functions, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null"
]
}

Página 135
Página 136

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 137
Página 138

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
<Window x:Class="WpfToCSV.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfToCSV"
mc:Ignorable="d"
Title="Creating CSV" Height="170" Width="330">
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="Nível" FontWeight="Bold" Margin="5" Grid.Column="1"
Grid.Row="0"/>
<TextBlock Text="Material" FontWeight="Bold" Margin="5" Grid.Column="2"
Grid.Row="0"/>
<!---->
<TextBlock Text="Janela:" FontWeight="Bold" Margin="5" Grid.Column="0"
Grid.Row="1"/>
<TextBlock Text="Porta:" FontWeight="Bold" Margin="5" Grid.Column="0"
Grid.Row="2"/>
<!---->
<TextBox Name="txtJanelaNivel" Width="100" Margin="5" Grid.Column="1"
Grid.Row="1"/>
<TextBox Name="txtJanelaMaterial" Width="100" Margin="5" Grid.Column="2"
Grid.Row="1"/>
<!---->
<TextBox Name="txtPortaNivel" Width="100" Margin="5" Grid.Column="1"
Grid.Row="2"/>
<TextBox Name="txtPortaMaterial" Width="100" Margin="5" Grid.Column="2"
Grid.Row="2"/>
</Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Name="btnLimpar" Width="51" Margin="5"
Click="BtnLimpar_Click">_Limpar</Button>
<Button Name="btnCSV" Width="51" Margin="5"
Click="BtnCSV_Click">_CSV</Button>
<Button Name="btnExit" Width="51" Margin="5,5,37,5"
Click="BtnExit_Click">Sai_r</Button>
</StackPanel>

Página 139
Página 140

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
</StackPanel> //InitialDirectory = @"..\..\DataBase\",
</Window> //InitialDirectory = @"D\Temp\",
//InitialDirectory = "D\\Temp\\",
//InitialDirectory =
System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Directory.GetCurrentDirectory()
), "..\\..\\DataBase\\"),
InitialDirectory = System.IO.Path.GetFullPath(CombinedPath),
using System; Filter = "Rtf documents|*.rtf|Txt files (*.txt)|*.txt|Csv files
using System.Collections.Generic; (*.csv)|*.csv|All files (*.*)|*.*",
using System.ComponentModel; FilterIndex = 3,
using System.Data; RestoreDirectory = true
using System.Drawing; };
using System.Linq; saveFileDialog.ShowDialog();
using System.Text; if (saveFileDialog.FileName == "") {
using System.Threading.Tasks; MessageBox.Show("Arquivo Inválido", "Salvar Como",
using System.Windows; MessageBoxButton.OK);
using System.Windows.Controls; } else {
using System.Windows.Data; ArquivoName = saveFileDialog.FileName;
using System.Windows.Documents; using (StreamWriter writer = new StreamWriter(ArquivoName)) {
using System.Windows.Input; writer.WriteLine("Elemento;Nivel;Material");
using System.Windows.Media; writer.WriteLine("Porta:;{0};{1}", txtPortaNivel.Text,
using System.Windows.Media.Imaging; txtPortaMaterial.Text);
using System.Windows.Navigation; writer.WriteLine("Janela:;{0};{1}", txtJanelaNivel.Text,
using System.Windows.Shapes; txtJanelaMaterial.Text);
using System.IO; }
using Microsoft.Win32; MessageBox.Show("Arquivo Salvo com Sucesso!", "Salvar!",
MessageBoxButton.OK);
namespace WpfToCSV { }
/// <summary>
/// Interaction logic for MainWindow.xaml } catch (Exception ex) {
/// </summary> MessageBox.Show(ex.ToString());
public partial class MainWindow : Window { }
}
// Variáveis globais: }
string arquivoNome; }
public string ArquivoName { get { return arquivoNome;} set { arquivoNome =
value; } }

public MainWindow() {
InitializeComponent();
ArquivoName = "";
}

private void BtnExit_Click(object sender, RoutedEventArgs e) {


this.Close();
}

private void BtnLimpar_Click(object sender, RoutedEventArgs e) {


txtJanelaMaterial.Text = "";
txtJanelaNivel.Text = "";
txtPortaMaterial.Text = "";
txtPortaNivel.Text = "";
// Tip: to get value as number var = Convert.ToDouble(txtField.Text)
}

private void BtnCSV_Click(object sender, RoutedEventArgs e) {


try {
string CombinedPath =
System.IO.Path.Combine(Directory.GetCurrentDirectory(), "..\\..\\DataBase");
SaveFileDialog saveFileDialog = new SaveFileDialog {
Title = "Salvar CSV",
//Alternativas

Página 141
Página 142

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 143
Página 144

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
<Window x:Class="WpfApp_Excel_20190326.Forms.FrmStartUp"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp_Excel_20190326.Forms"
mc:Ignorable="d"
Title="Exemplos de Interação com o Excel" Height="150" Width="450">
<StackPanel>
<!-- Main Menu -->
<Menu Height="21">
<MenuItem Header="_File">
<MenuItem Name="mnuExit" Header="E_xit" Click="Exit"/>
</MenuItem>
</Menu>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"
Margin="5,33,5,5">
<Button Name="btnAddPicture" Width="70" Margin="2,9,3,5"
Click="ReadAddPicture_Click">Add Picture</Button>
<Button Name="btnAddSheet" Width="70" Margin="2,9,3,5"
Click="ReadAddSheet_Click">Add Sheet</Button>
<Button Name="btnReadAllFile" Width="70" Margin="2,9,3,5"
Click="ReadAllFile_Click">Read All File</Button>
<Button Name="btnOpenFile" Width="70" Margin="2,9,3,5"
Click="OpenFile_Click">Open File</Button>
<Button Name="btnCreateFile" Width="60" Margin="2,9,3,5"
Click="CreateFile_Click">Create File</Button>
<Button Name="btnExit" Width="50" Margin="2,9,3,5"
Click="Exit">E_xit</Button>
</StackPanel>
</StackPanel>
</Window>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Runtime.InteropServices;

Página 145
Página 146

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
using Excel = Microsoft.Office.Interop.Excel; xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

namespace WpfApp_Excel_20190326.Forms { MessageBox.Show(xlWorkSheet.get_Range("A1", "A1").Value2.ToString());


/// <summary>
/// Interaction logic for FrmStartUp.xaml xlWorkBook.Close(true, misValue, misValue);
/// </summary> xlApp.Quit();
public partial class FrmStartUp : Window {
public FrmStartUp() { releaseObject(xlWorkSheet);
InitializeComponent(); releaseObject(xlWorkBook);
} releaseObject(xlApp);
}
private void Exit(object sender, RoutedEventArgs e) {
this.Close(); private void releaseObject(object obj) {
} try {
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
private void CreateFile_Click(object sender, RoutedEventArgs e) { obj = null;
Excel.Application xlApp = new } catch (Exception ex) {
Microsoft.Office.Interop.Excel.Application(); obj = null;
MessageBox.Show("Unable to release the Object " + ex.ToString());
if (xlApp == null) { } finally {
MessageBox.Show("Excel is not properly installed!!"); GC.Collect();
return; }
} }
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet; private void ReadAllFile_Click(object sender, RoutedEventArgs e) {
object misValue = System.Reflection.Missing.Value; Excel.Application xlApp;
Excel.Workbook xlWorkBook;
xlWorkBook = xlApp.Workbooks.Add(misValue); Excel.Worksheet xlWorkSheet;
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); Excel.Range range;

xlWorkSheet.Cells[1, 1] = "ID"; string str;


xlWorkSheet.Cells[1, 2] = "Name"; int rCnt;
xlWorkSheet.Cells[2, 1] = "1"; int cCnt;
xlWorkSheet.Cells[2, 2] = "One"; int rw = 0;
xlWorkSheet.Cells[3, 1] = "2"; int cl = 0;
xlWorkSheet.Cells[3, 2] = "Two";
xlApp = new Excel.Application();
xlWorkBook.SaveAs("d:\\temp\\csharp-Excel.xls", xlWorkBook = xlApp.Workbooks.Open("d:\\temp\\csharp-Excel.xls", 0, true,
Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false,
Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, false, 0, true, 1, 0);
misValue, misValue, misValue); xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
xlWorkBook.Close(true, misValue, misValue);
xlApp.Quit(); range = xlWorkSheet.UsedRange;
rw = range.Rows.Count;
Marshal.ReleaseComObject(xlWorkSheet); cl = range.Columns.Count;
Marshal.ReleaseComObject(xlWorkBook);
Marshal.ReleaseComObject(xlApp); for (rCnt = 1; rCnt <= rw; rCnt++) {
for (cCnt = 1; cCnt <= cl; cCnt++) {
MessageBox.Show("Excel file created, you can find the file // Error if not string in Excel!
d:\\temp\\csharp-Excel.xls"); str = (string)(range.Cells[rCnt, cCnt] as Excel.Range).Value2;
} MessageBox.Show(str);
}
private void OpenFile_Click(object sender, RoutedEventArgs e) { }
Excel.Application xlApp;
Excel.Workbook xlWorkBook; xlWorkBook.Close(true, null, null);
Excel.Worksheet xlWorkSheet; xlApp.Quit();
object misValue = System.Reflection.Missing.Value;
Marshal.ReleaseComObject(xlWorkSheet);
xlApp = new Excel.Application(); Marshal.ReleaseComObject(xlWorkBook);
xlWorkBook = xlApp.Workbooks.Open("d:\\temp\\csharp-Excel.xls", 0, true, Marshal.ReleaseComObject(xlApp);
5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, }
false, 0, true, 1, 0);

Página 147
Página 148

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
private void ReadAddSheet_Click(object sender, RoutedEventArgs e) { xlApp.Quit();
Excel.Application xlApp = new
Microsoft.Office.Interop.Excel.Application(); releaseObject(xlApp);
releaseObject(xlWorkBook);
if (xlApp == null) { releaseObject(xlWorkSheet);
MessageBox.Show("Excel is not properly installed!");
return; MessageBox.Show("File created!");
} }

// Disable Excel overwrite prompt. Suppress prompts and alert messages }


while a macro is running. }
xlApp.DisplayAlerts = false;

string filePath = "d:\\temp\\csharp-Excel.xls";


Excel.Workbook xlWorkBook =
xlApp.Workbooks.Open(filePath,0,false,5,"","",false,Microsoft.Office.Interop.Excel.XlP
latform.xlWindows,"",true,false,0,true,false,false);
Excel.Sheets worksheets = xlWorkBook.Worksheets;

var xlNewSheet = (Excel.Worksheet)worksheets.Add(worksheets[1],


Type.Missing, Type.Missing, Type.Missing);
xlNewSheet.Name = "newsheet";
xlNewSheet.Cells[1, 1] = "New sheet content";

xlNewSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
xlNewSheet.Select();

xlWorkBook.Save();
xlWorkBook.Close();

releaseObject(xlNewSheet);
releaseObject(worksheets);
releaseObject(xlWorkBook);
releaseObject(xlApp);

MessageBox.Show("New Worksheet Created!");


}

private void ReadAddPicture_Click(object sender, RoutedEventArgs e) {


Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;

xlApp = new Excel.Application();


xlWorkBook = xlApp.Workbooks.Add(misValue);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

//add some text


xlWorkSheet.Cells[1, 1] = "Working with Excel!";
xlWorkSheet.Cells[2, 1] = "Adding picture in Excel File!";

// This picture must be in this path


xlWorkSheet.Shapes.AddPicture("d:\\temp\\eTtlipse logo 20180708.JPG",
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoCTrue, 50, 50, 300, 45);

xlWorkBook.SaveAs("d:\\temp\\csharp-Excel.xls",
Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue,
Excel.XlSaveAsAccessMode.xlExclusive,
misValue, misValue, misValue, misValue, misValue);
xlWorkBook.Close(true, misValue, misValue);

Página 149
Página 150

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
<id>2</id>
<roledescription>Developer</roledescription>
</role>
<role>
<id>3</id>
<roledescription>Marketing</roledescription>
</role>
<!--Salary section-->
<salary>
<idperson id="1" year="2001" salaryyear="10000,00" />
<idperson id="1" year="2005" salaryyear="15000,00" />
</salary>
</people>

<Window x:Class="LinqWithXML20180624.Forms.FrmStartUp"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LinqWithXML20180624.Forms"
xmlns:local_Lib="clr-namespace:LinqWithXML20180624.Library"
mc:Ignorable="d"
Title="Linq with XML" Height="450" Width="921">
<Window.Resources>
<local_Lib:People x:Key="LocalPeople"/>
</Window.Resources>
<?xml version="1.0" encoding="utf-8"?><people> <StackPanel>
<!--Person section-->
<!-- Main Menu -->
<person> <Menu Height="21" Margin="0,0,0,0">
<id>1</id> <MenuItem Header="_File">
<firstname>Edson</firstname>
<MenuItem Name="mnuExit" Header="E_xit" Click="Exit"/>
<lastname>Andrade</lastname> </MenuItem>
<idrole>1</idrole>
<MenuItem Header="_Help">
</person> <MenuItem Header="_About"/>
<person>
</MenuItem>
<id>2</id> </Menu>
<firstname>Rogerio</firstname> <StackPanel HorizontalAlignment="Center">
<lastname>Lima</lastname> <!-- Data Grid for XML -->
<idrole>2</idrole>
<TextBlock HorizontalAlignment="Center" Margin="5,9,5,0"
</person>
TextWrapping="Wrap" FontSize="12" FontWeight="Bold" Text="Data Table:"/>
<person> <DataGrid Name="dgrdXML" AutoGenerateColumns="True"
<id>3</id>
ItemsSource="{StaticResource LocalPeople}" AlternatingRowBackground="LightCyan">
<firstname>Joel</firstname> <!-- Data Grid -->
<lastname>Diniz</lastname>
</DataGrid>
<idrole>1</idrole> <!-- Output -->
</person> <TextBlock HorizontalAlignment="Center" Margin="5,9,5,0"
<person>
TextWrapping="Wrap" FontSize="12" FontWeight="Bold" Text="Output:"/>
<id>4</id> <RichTextBox Name="rtbOutput" HorizontalAlignment="Left" Height="150"
<firstname>Jade</firstname> Width="850" Margin="5,9,5,0">
<lastname>Diniz</lastname> <FlowDocument>
<idrole>2</idrole>
<Paragraph>
</person>
<Run Text="... output!"/>
<!--Role section-->
</Paragraph>
<role>
</FlowDocument>
<id>1</id> </RichTextBox>
<roledescription>Manager</roledescription> </StackPanel>
</role>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"
<role>

Página 151
Página 152

Margin="5,9,5,0">
eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
<Button x:Name="btnDeleteInXML" Width="105" Margin="3,9,5,5"
Click="BtnDeleteInXML_Click">Delete in XML File</Button> // Adding all person
<Button x:Name="btnUpDateInXML" Width="107" Margin="3,9,5,5" foreach (Person person in people) {
Click="BtnUpDateInXML_Click">UpDate in XML File</Button> line.Remove(0, line.Length);
<Button x:Name="btnAddInXML" Width="107" Margin="3,9,5,5" line.Append(person.ToString());
Click="BtnAddInXML_Click">Add in XML File</Button> line.Append("\n");paragraph.Inlines.Add(line.ToString());
<Button x:Name="btnAttRetryFromFile" Width="107" Margin="3,9,5,5" }
Click="BtnAttRetryFromFile_Click">Retry Att from File</Button>
<Button x:Name="btnElemRetryFromFile" Width="113" Margin="3,9,5,5" // UpDate the OutPut Document
Click="BtnElemRetryFromFile_Click">Retry Elem from File</Button> flowDoc.Blocks.Add(paragraph);
<Button x:Name="btnDocRetryFromFile" Width="107" Margin="3,9,5,5" rtbOutput.Document = flowDoc;
Click="BtnDocRetryFromFile_Click">_Retry Doc from File</Button>
<Button x:Name="btnApplyETlipseSample" Width="135" Margin="3,9,5,5" } catch (Exception ex) {
Click="BtnApplyETlipseSample_Click">_Apply Sample ETlipse</Button> MessageBox.Show(ex.ToString());
<Button Name="btnExit" Width="50" Margin="5,9,5,5" }
Click="Exit">E_xit</Button> }
</StackPanel>
</StackPanel> public FrmStartUp() {
</Window> InitializeComponent();
}

private void Exit(object sender, RoutedEventArgs e) {


this.Close();
}

private void BtnApplyETlipseSample_Click(object sender, RoutedEventArgs e) {


using System;
// Creating People
using System.Collections.Generic; List<Person> people = new List<Person> {
using System.IO;
new Person{ID=1, FirstName="Edson",LastName="Andrade", IDRole=1},
using System.Linq; new Person{ID=2, FirstName="Jade",LastName="Diniz", IDRole=2},
using System.Xml; new Person{ID=3, FirstName="Joel",LastName="Diniz", IDRole=1},
using System.Xml.Linq;
new Person{ID=4, FirstName="Rogerio",LastName="Lima", IDRole=2}
using System.Text; };
using System.Threading.Tasks;
using System.Windows; // Writing Results
using System.Windows.Controls;
WriteListPeople(people);
using System.Windows.Data;
using System.Windows.Documents; // Feed the DataGrid with people
using System.Windows.Input; dgrdXML.ItemsSource = people;
using System.Windows.Media;
using System.Windows.Media.Imaging;
// Find people with ID Role = 1
using System.Windows.Shapes;
var query = from q in people
using LinqWithXML20180624.Library; where q.IDRole == 1
select q;
namespace LinqWithXML20180624.Forms {
List<Person> selectedPeople;
/// <summary>
/// Lógica interna para FrmStartUp.xaml
selectedPeople = query.ToList<Person>();
/// </summary>
public partial class FrmStartUp : Window {
foreach (var p in selectedPeople) {
MessageBox.Show(p.ToString());
}
private void WriteListPeople(List<Person> people) {
try {
}
// Connection with the OutPut Document private void BtnDocRetryFromFile_Click(object sender, RoutedEventArgs e) {
FlowDocument flowDoc = new FlowDocument(); try {
Paragraph paragraph = new Paragraph();
paragraph.Inlines.Add(new Bold(new Run("Results:\n\n")));
// Connecting with the xml file
XDocument xml = XDocument.Load(@"..\..\DataBase\People.xml");
// Line to write
StringBuilder line = new StringBuilder();

Página 153
Página 154

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
// Query a specific data XmlReader reader = XmlReader.Create(@"..\..\DataBase\People.xml");
var query = from p in xml.Elements("people").Elements("person") XDocument xml = XDocument.Load(reader);
where (int)p.Element("id") == 3 reader.Close();
select p;
XElement idperson = xml.Descendants("idperson").Last();
string person; idperson.Add(new XElement("idperson",
new XAttribute("id",1),
// Interacting with each element new XAttribute("year",2006),
foreach (var record in query) { new XAttribute("salaryyear","160000,00")));
person = string.Format("Person: {0} {1}",
record.Element("firstname").Value, record.Element("lastname").Value); // para saída em String
MessageBox.Show(person); //StringWriter sw = new StringWriter();
} //XmlWriter w = XmlWriter.Create(sw);
//xml.Save(w);
} catch (Exception ex) { //w.Close();
MessageBox.Show(ex.ToString()); //MessageBox.Show(sw.ToString());
}
} XmlWriter writer = XmlWriter.Create(@"..\..\DataBase\People.xml");
xml.Save(writer);
private void BtnElemRetryFromFile_Click(object sender, RoutedEventArgs e) { writer.Close();
try { MessageBox.Show("Arquivo gravado com sucesso!");
XElement xml = XElement.Load(@"..\..\DataBase\People.xml");
} catch (Exception ex) {
var query = from p in xml.Elements("person") MessageBox.Show(ex.ToString());
where (int)p.Element("id") == 3 }
select p; }

string person; private void BtnUpDateInXML_Click(object sender, RoutedEventArgs e) {


try {
foreach (var record in query) { XmlReader reader = XmlReader.Create(@"..\..\DataBase\People.xml");
person = string.Format("Person: {0} {1}", XElement xml = XElement.Load(reader);
record.Element("firstname"), record.Element("lastname")); reader.Close();
MessageBox.Show(person);
} // Alterando Element
} catch (Exception ex) { XElement role = xml.Descendants("role").First();
MessageBox.Show(ex.ToString()); MessageBox.Show(role.ToString());
}
} role.SetElementValue("roledescription", "Manager");
MessageBox.Show(role.ToString());
private void BtnAttRetryFromFile_Click(object sender, RoutedEventArgs e) {
try { // Alterando Attribute
XElement xml = XElement.Load(@"..\..\DataBase\People.xml"); role = xml.Descendants("idperson").First();
MessageBox.Show(role.ToString());
var query = from s in xml.Elements("salary").Elements("idperson")
where (int)s.Attribute("year") == 2004 role.SetAttributeValue("year", "2001");
select s; MessageBox.Show(role.ToString());

string salary; // Gravando o arquivo


XmlWriter writer = XmlWriter.Create(@"..\..\DataBase\People.xml");
foreach (var record in query) { xml.Save(writer);
salary = string.Format("Amount: {0}", writer.Close();
(string)record.Attribute("salaryyear")); MessageBox.Show("Arquivo gravado com sucesso!");
MessageBox.Show(salary);
} // Substituindo elemento completo
xml.Element("person").ReplaceNodes(new XElement("id", 5),
} catch (Exception ex) { new XElement("firstname", "J3di"),
MessageBox.Show(ex.ToString()); new XElement("lastname", "Jr"),
} new XElement("idrole", 1));
} } catch (Exception ex) {
MessageBox.Show(ex.ToString());
private void BtnAddInXML_Click(object sender, RoutedEventArgs e) { }
try {

Página 155
Página 156

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
} namespace LinqWithXML20180624.Library{
class Person{
private void BtnDeleteInXML_Click(object sender, RoutedEventArgs e) {
try { int _id;
// Removendo um elemento public int ID {
XmlReader reader = XmlReader.Create(@"..\..\DataBase\People.xml"); get { return _id; }
XElement xml = XElement.Load(reader); set { _id = value; }
reader.Close(); }
xml.Descendants("idperson").First().Remove();
xml.Elements("role").Remove(); int _idRole;
// Gravando o arquivo public int IDRole {
XmlWriter writer = XmlWriter.Create(@"..\..\DataBase\People.xml"); get { return _idRole; }
xml.Save(writer); set { _idRole = value; }
writer.Close(); }
MessageBox.Show("Arquivo gravado com sucesso!");
} catch (Exception ex) { string _lastName;
MessageBox.Show(ex.ToString()); public string LastName {
} get { return _lastName; }
} set { _lastName = value; }
}

} string _firstName;
} public string FirstName {
get { return _firstName; }
set { _firstName = value; }
}

public override string ToString() {


return "Person " + ID.ToString() + " - " + FirstName + " " + LastName +
".";
}
using System;
using System.Collections.Generic; }
using System.Linq;
}
using System.Text;
using System.Threading.Tasks;

namespace LinqWithXML20180624.Library {
class People : List<Person> {
public People() {
using System;
this.Add(new Person() { ID = 1, FirstName = "Edson", LastName = "Andrade",
using System.Collections.Generic;
IDRole = 1 });
using System.Linq;
this.Add(new Person() { ID = 2, FirstName = "Jade", LastName = "Diniz",
using System.Text;
IDRole = 2 });
using System.Threading.Tasks;
this.Add(new Person() { ID = 3, FirstName = "Joel", LastName = "Diniz",
IDRole = 1 });
namespace LinqWithXML20180624.Library{
}
class Role{
}
}
int _id;
public int ID {
get { return _id; }
set { _id = value; }
}

string _roleDescription;
public string RoleDescription {
using System; get { return _roleDescription; }
using System.Collections.Generic; set { _roleDescription = value; }
using System.Linq; }
using System.Text;
using System.Threading.Tasks; }

Página 157
Página 158

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
<Application.Resources>

</Application.Resources>
} </Application>

using System;
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using System.Text;
using System.Data;
using System.Threading.Tasks;
using System.Linq;
using System.Threading.Tasks;
namespace LinqWithXML20180624.Library{
using System.Windows;
class Salary{
namespace LinqWithXML20180624 {
int _idPerson;
/// <summary>
public int IDPerson {
/// Interação lógica para App.xaml
get { return _idPerson; }
/// </summary>
set { _idPerson = value; }
public partial class App : Application {
}
void App_Startup(object sender, StartupEventArgs e) {
int _year;
// Open a window
public int Year {
Forms.FrmStartUp frmStartUp = new Forms.FrmStartUp();
get { return _year; }
frmStartUp.Show();
set { _year = value; }
}
//MainWindow window = new MainWindow();
//window.Show();
double _salary;
}
public double SalaryYear {
}
get { return _salary; }
}
set { _salary = value; }
}

}
}

<?xml version="1.0" encoding="utf-8" ?>


<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>

<Application x:Class="LinqWithXML20180624.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:LinqWithXML20180624"
Startup="App_Startup">

Página 159
Página 160

<!--StartupUri="MainWindow.xaml"-->
eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 161
Página 162

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 163
Página 164

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MVVMwithWPFProject.Model {
public class Employee {

private int iD;


/// <summary>
/// Identification number of the employee
/// </summary>
public int ID {
get { return iD; }
set { iD = value; }
}

private string firstName;


/// <summary>
/// First name of the employee
/// </summary>
public string FirstName {
get { return firstName; }
set { firstName = value; }
}

Página 165
Página 166

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
private string lastName; LastName = lastName;
/// <summary> BaseSalary = baseSalary;
/// Last name of the employee DaysWorked = daysWorked;
/// </summary> ReceiveBonusPerDayWorked = receiveBonusPerDayWorked;
public string LastName { BonusPerDayWorked = bonusPerDayWorked;
get { return lastName; } }
set { lastName = value; } }
} }

private double baseSalary;


/// <summary>
/// Base monthly salary of the employee. Minimal to be received
/// </summary>
public double BaseSalary { <Window x:Class="MVVMwithWPFProject.MainWindow"
get { return baseSalary; } xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
set { baseSalary = value; } xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
} xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
private int daysWorked; xmlns:local="clr-namespace:MVVMwithWPFProject"
/// <summary> xmlns:NamespaceVM="clr-namespace:MVVMwithWPFProject.ViewModel"
/// Days worked in current month mc:Ignorable="d"
/// </summary> Title="MVVM with WPF Application" Height="450" Width="500"
public int DaysWorked { Icon="/WpfAppICommandProject;component/SupportContent/Files/TLLogo-B-Color-
get { return daysWorked; } 100W_QD.png">
set { daysWorked = value; } <Window.Background>
} <ImageBrush
ImageSource="/WpfAppICommandProject;component/SupportContent/Files/TL00-04 BG W.jpg"/>
private bool receiveBonusPerDayWorked; </Window.Background>
/// <summary> <Window.Resources>
/// Receive bonus per day worked? <NamespaceVM:EmployeeViewModel x:Key="employeeViewModel"/>
/// </summary> <NamespaceVM:ValueConverterIntDaysToString
public bool ReceiveBonusPerDayWorked { x:Key="valueConverterIntDayToString"/>
get { return receiveBonusPerDayWorked; } </Window.Resources>
set { receiveBonusPerDayWorked = value; }
} <Grid x:Name="grdEmployees" DataContext="{Binding employeeViewModel}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
private double bonusPerDayWorked; <ColumnDefinition Width="Auto"/>
/// <summary> </Grid.ColumnDefinitions>
/// Bonus per day worked so (Total Salary) = (Days Worked) * (Bonus per Day <Grid.RowDefinitions>
Worked) + (Base Salary) <RowDefinition Height="*"/>
/// </summary> </Grid.RowDefinitions>
public double BonusPerDayWorked {
get { return bonusPerDayWorked; } <ListView ItemsSource="{Binding Employees}"
set { bonusPerDayWorked = value; } SelectedItem="{Binding SelectedEmployee, Mode=TwoWay,
} UpdateSourceTrigger=PropertyChanged}"
SelectionMode="Single"
private double totalSalary; Name="lstEmployees" Grid.Column="0" Grid.Row="0" Margin="5">
<ListView.View>
public double TotalSalary { <GridView x:Name="gvEmployees">
get { return totalSalary; } <GridViewColumn Header="ID" DisplayMemberBinding="{Binding ID}"/>
set { totalSalary = value; } <GridViewColumn Header="First Name" DisplayMemberBinding="{Binding
} FirstName}"/>
<GridViewColumn Header="Last Name" DisplayMemberBinding="{Binding
LastName}"/>
public Employee() { <GridViewColumn Header="Base Salary (R$)"
} DisplayMemberBinding="{Binding BaseSalary}"/>
<GridViewColumn Header="Bonus?">
public Employee(int iD, string firstName, string lastName, double baseSalary, <GridViewColumn.CellTemplate>
int daysWorked, bool receiveBonusPerDayWorked, double bonusPerDayWorked) { <DataTemplate>
ID = iD; <TextBlock Text="{Binding ReceiveBonusPerDayWorked}">
FirstName = firstName; <TextBlock.Style>

Página 167
Página 168

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
<Style TargetType="TextBlock"> <!---->
<Style.Triggers> <TextBlock Text="Total Salary" Margin="5"/>
<DataTrigger Binding="{Binding <TextBox x:Name="txtTotalSalary" Text="{Binding
ReceiveBonusPerDayWorked}" Value="False"> SelectedEmployee.TotalSalary, Mode=TwoWay,
<Setter Property="Foreground" StringFormat={}R$ {0:0.00}}" Margin="5,0,5,0"/>
Value="Red" /> </StackPanel>
</DataTrigger>
<DataTrigger Binding="{Binding </Grid>
ReceiveBonusPerDayWorked}" Value="True"> </Window>
<Setter Property="Foreground"
Value="Blue" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style> using System;
</TextBlock> using System.Collections.Generic;
</DataTemplate> using System.Collections.ObjectModel;
</GridViewColumn.CellTemplate> using System.Linq;
</GridViewColumn> using System.Text;
</GridView> using System.Threading.Tasks;
</ListView.View> using System.Windows;
</ListView> using System.Windows.Controls;
using System.Windows.Data;
<StackPanel Grid.Row="0" Grid.Column="1"> using System.Windows.Documents;
<TextBlock Text="Selected Employee" HorizontalAlignment="Center" using System.Windows.Input;
Margin="5" FontWeight="Bold"/> using System.Windows.Media;
<!----> using System.Windows.Media.Imaging;
<TextBlock Text="Name" Margin="5"/> using System.Windows.Navigation;
<!-- Optional: using System.Windows.Shapes;
<TextBox x:Name="txtName" Text="{Binding using MVVMwithWPFProject.Model;
ElementName=lstEmployees,Path=SelectedItem.FirstName}" Margin="5,0,5,0"/> using MVVMwithWPFProject.ViewModel;
-->
<TextBox x:Name="txtFirstName" Text="{Binding SelectedEmployee.FirstName}" namespace MVVMwithWPFProject {
Margin="5,0,5,0"/> /// <summary>
<!----> /// Interaction logic for MainWindow.xaml
<TextBlock Text="Last Name" Margin="5"/> /// </summary>
<TextBox x:Name="txtLastName" Text="{Binding SelectedEmployee.LastName}" public partial class MainWindow : Window {
Margin="5,0,5,0"/> private EmployeeViewModel employeeViewModel;
<!----> public MainWindow() {
<TextBlock Text="Base Salary" Margin="5"/>
<TextBox x:Name="txtBaseSalary" Text="{Binding InitializeComponent();
SelectedEmployee.BaseSalary,
StringFormat={}R$ {0:0.00}}" Margin="5,0,5,0"/> employeeViewModel = new EmployeeViewModel();
<!---->
<TextBlock Text="Days Worked" Margin="5"/> // Adding itens just to test
<TextBox x:Name="txtDaysWorked" Text="{Binding employeeViewModel.DefaultEmployees();
SelectedEmployee.DaysWorked, grdEmployees.DataContext = employeeViewModel;
Converter={StaticResource valueConverterIntDayToString}}" }
Margin="5,0,5,0"/> }
<!----> }
<TextBlock Text="Bonus per Day Worked" Margin="5"/>
<TextBox x:Name="txtBonusPerDayWorked" Text="{Binding
SelectedEmployee.BonusPerDayWorked,
StringFormat={}R$ {0:0.00}}" Margin="5,0,5,0"/>
<!---->
<Separator Margin="5,18,5,15"/> using MVVMwithWPFProject.ViewModel;
<!----> using System;
<Button x:Name="btnTotalSalary" Margin="5" Command="{Binding using System.Collections.Generic;
CalculateSalaryCommand}" using System.Linq;
CommandParameter="{Binding SelectedEmployee.FirstName}"> using System.Text;
_Compute Total Salary using System.Threading.Tasks;
</Button> using System.Windows.Input;

Página 169
Página 170

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
using System.Windows.Markup; /// Selected employee from the collection of employees
/// </summary>
namespace WpfAppICommandProject.ViewModel.Command { public Employee SelectedEmployee {
public class CalculateSalaryCommand : ICommand { get { return selectedEmployee; }
set {
public EmployeeViewModel EmployeeViewModel { get; set; } selectedEmployee = value;
OnPropertyChanged("SelectedEmployee");
public event EventHandler CanExecuteChanged { }
add { CommandManager.RequerySuggested += value; } }
remove { CommandManager.RequerySuggested -= value; }
} public EmployeeViewModel() {
//SelectedEmployee = new Employee(1, "Joel", "Diniz", 5000, 20, true,
public CalculateSalaryCommand(EmployeeViewModel employeeViewModel) { 100f);
EmployeeViewModel = employeeViewModel; CalculateSalaryCommand = new CalculateSalaryCommand(this);
} }

public bool CanExecute(object parameter) { /// <summary>


string selectedEmployeeName = parameter as string; /// Default controctor to include employees to test
/// </summary>
if (string.IsNullOrWhiteSpace(selectedEmployeeName)) public void DefaultEmployees() {
return false; employees = new ObservableCollection<Employee>(){
return true; new Employee(1, "Joel", "Diniz", 5000, 20, true, 100f),
} new Employee(2, "Edson", "Andrade", 10000, 10, true, 100f),
new Employee(3, "Jade", "Diniz", 1000, 0, false, 0f)
public void Execute(object parameter) { };
this.EmployeeViewModel.CalculateSalary(); this.Employees = employees;
} }
}
} public CalculateSalaryCommand CalculateSalaryCommand { get; set; }

public void CalculateSalary() {

if (SelectedEmployee != null) {

using System; // (Total Salary) = (Days Worked) * (Bonus per Day Worked) + (Base
using System.Collections.Generic; Salary)
using System.Collections.ObjectModel; SelectedEmployee.TotalSalary = (SelectedEmployee.DaysWorked *
using System.ComponentModel; SelectedEmployee.BonusPerDayWorked)+SelectedEmployee.BaseSalary;
using System.Linq; this.SelectedEmployee = SelectedEmployee;
using System.Text;
using System.Threading.Tasks; // Teste if this employee receives bonus
using System.Windows; if (!SelectedEmployee.ReceiveBonusPerDayWorked) {
using MVVMwithWPFProject.Model; MessageBox.Show("This employee does not receive bonus!");
using WpfAppICommandProject.ViewModel.Command; }

namespace MVVMwithWPFProject.ViewModel { } else {


public class EmployeeViewModel : INotifyPropertyChanged { MessageBox.Show("No employee selected!");
}
private ObservableCollection<Employee> employees;
/// <summary> }
/// Collection of employees
/// </summary> public event PropertyChangedEventHandler PropertyChanged;
public ObservableCollection<Employee> Employees { private void OnPropertyChanged(string propertyName) {
get { return employees; } PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
set { }
employees = value; }
OnPropertyChanged("Employees"); }
}
}

private Employee selectedEmployee;


/// <summary>

Página 171
Página 172

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace MVVMwithWPFProject.ViewModel {
/// <summary>
/// Converts the days, that are int, to string format
/// </summary>
public class ValueConverterIntDaysToString : IValueConverter {
public object Convert(object value, Type targetType, object parameter,
CultureInfo culture) {
int inputAsInt = int.Parse(value.ToString());
if (inputAsInt > 0) {
return inputAsInt.ToString() + " days";
} else {
return inputAsInt.ToString() + " day";
}
}

public object ConvertBack(object value, Type targetType, object parameter,


CultureInfo culture) {
var input = value as string;
int output;
if (int.TryParse(input, out output))
return output;
else
return DependencyProperty.UnsetValue;
}
}
}

<Application x:Class="MVVMwithWPFProject.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MVVMwithWPFProject"
StartupUri="View/MainWindowView.xaml">
<Application.Resources>

</Application.Resources>
</Application>

Página 173
Página 174

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 175
Página 176

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 177
Página 178

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
[Transaction(TransactionMode.Manual)]
public class OlaRevit : IExternalCommand { // Classe que irá dar origem à dll para
uso no Revit.
public Result Execute(ExternalCommandData commandData, ref string message,
ElementSet elements) { // Método de entrada que implemnta a interface necessária da
API.
try {
TaskDialog.Show("Revit", "Olá Revit!"); // Caixa de diálogo que será
executada se tudo der certo.
return Result.Succeeded; // Retorno que tudo ocorreu bem.
} catch (Exception ex) { // Tratamento de exceção.
message = ex.Message;
TaskDialog.Show("Error!",message);
return Result.Failed; // Retorno de erro.
//throw; // Código a ser comentado.
}
//throw new NotImplementedException(); // Código a ser comentado.
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI.Selection;

namespace TreinaOlaRevit20180731 { // NameSpace.

Página 179
Página 180

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<RevitAddIns>
<AddIn Type="Command">
<Name>SampleApplication</Name>
<Assembly>C:\Temp\RevitPlugins\ TreinaOlaRevit20180731.dll</Assembly> (Arquivo e
Local onde copiaremos nossa dll, resultado do arquivo copilado)
<AddInId>BC05297E-11B0-4CCC-A0F4-35AFC0DD12E7</AddInId> (Código único de Id do
Plugin, que pode ser gerado no Visual Studio)
<FullClassName> TreinaOlaRevit20180731.OlaRevit</FullClassName> (NameSpace e nome
da classe que criamos)
<VendorId>ETlipse</VendorId>
<VendorDescription>Edson Andrade, Rogerio Lima, Joel Diniz</VendorDescription>
</AddIn>
</RevitAddIns>

Página 181
Página 182

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 183
Página 184

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 185
Página 186

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<RevitAddIns>
<AddIn Type="Application">
<Name>SampleApplication</Name>
<Assembly>C:\Temp\RevitPlugins\RevitAPIGuide2014_AddPanel_20180708.dll</Assembly>
<AddInId>BC05297E-11B0-4CCC-A0F4-35AFC0DD12E7</AddInId>
<FullClassName>RevitAPIGuide2014_AddPanel_20180708.CsAddPanel</FullClassName>
using System; <VendorId>ETlipse</VendorId>
using System.Collections.Generic; <VendorDescription>Edson Andrade, Rogerio Lima, Joel Diniz</VendorDescription>
using System.Linq; </AddIn>
using System.Text; </RevitAddIns>
using System.Threading.Tasks;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI.Selection;
using System.Windows.Media.Imaging;

namespace RevitAPIGuide2014_AddPanel_20180708{

[Transaction(TransactionMode.Manual)]
public class CsAddPanel : Autodesk.Revit.UI.IExternalApplication {

Result IExternalApplication.OnShutdown(UIControlledApplication application) {

return Result.Succeeded;
}

Result IExternalApplication.OnStartup(UIControlledApplication application) {

// Add new ribbon panel


RibbonPanel ribbonPanel = application.CreateRibbonPanel("NewRibbonPanel");

// Create a push button in the ribbon panel "NewRibbonPanel"


// the add-in application "Helloworld" will be triggered when button is
pushed

PushButton pushButton = ribbonPanel.AddItem(new


PushButtonData("Helloworld", "Helloworld",
@"C:\Temp\RevitPlugins\RevitAPIGuid2014_20180702.dll",
"RevitAPIGuid2014_20180702.HelloWorld")) as PushButton;

// Set the large image shown on button


Uri uriImage = new Uri(@"D:\Temp\Temp_32x32.png");
BitmapImage largeImage = new BitmapImage(uriImage);
pushButton.LargeImage = largeImage;

return Result.Succeeded;
}

Página 187
Página 188

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 189
Página 190

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 191
Página 192

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
}

} catch (Exception e) {
message = e.Message;
return Result.Failed;
}
return Result.Succeeded;
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.Attributes;
using System;
using Autodesk.Revit.UI.Selection;
using System.Collections.Generic;
using System.Linq;
namespace WpfAppRevitAPI20180619 {
using System.Text;
using System.Threading.Tasks;
[Transaction(TransactionMode.Manual)]
using Autodesk.Revit.DB;
class PickElement : IExternalCommand {
using Autodesk.Revit.UI;
public Result Execute(ExternalCommandData commandData, ref string message,
using Autodesk.Revit.UI.Selection;
ElementSet elements) {
using Autodesk.Revit.Attributes;
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
namespace RvtAPIG14_RetrieveSelElement_20180711{
Document doc = uiDoc.Document;
Selection sel = uiDoc.Selection;
[Transaction(TransactionMode.Manual)]
public class Document_Selection : IExternalCommand {
Element selectedElement =
Result IExternalCommand.Execute(ExternalCommandData commandData, ref string
doc.GetElement(sel.PickObject(ObjectType.Element, "Select object!"));
message, ElementSet elements) {
try {
string elementInfo = "Category name: "+ selectedElement.Category.Name +
// Select some element in Revit before invoking this command.
"\nName: " + selectedElement.Name;
// Get the handle of the current document.
TaskDialog.Show("Object information: ", elementInfo);
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document currentDoc = uiDoc.Document;
return Result.Succeeded;
}
// Get the element selection of current document.
}
Selection selection = uiDoc.Selection;
}
ICollection<ElementId> selectedIds = selection.GetElementIds();

if (selectedIds.Count == 0) {
// If no elements selected.
TaskDialog.Show("Revit", "You haven't selected any elements.");
} else {
String info = "Ids of selected elements in the document are: ";
foreach (ElementId elemId in selectedIds) {
info += "\n\t" + elemId.IntegerValue;
}
TaskDialog.Show("Revit", info);

Página 193
Página 194

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 195
Página 196

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
<Window x:Class="RevitCommand.HelloWPF"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:RevitCommand"
mc:Ignorable="d"
Title="Hello WPF" Height="300" Width="300">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button x:Name="btnMessage" Width="100" Height="33" Margin="5, 9, 5, 5"
Click="btnMessage_Click">Message</Button>
</StackPanel>
</Window>
<Window x:Class="RevitCommand.HelloWPF"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:RevitCommand"
mc:Ignorable="d"
Title="Hello WPF" Height="300" Width="300">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button x:Name="btnMessage" Width="100" Height="33" Margin="5, 9, 5, 5"
Click="btnMessage_Click">Message</Button>
</StackPanel>
</Window>

Página 197
Página 198

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace RevitCommand {
/// <summary>
/// Interaction logic for HelloWPF.xaml
/// </summary>
public partial class HelloWPF : Window, IDisposable {
public HelloWPF() { using System;
InitializeComponent(); using System.Collections.Generic;
} using System.Linq;
using System.Text;
public void Dispose() { using System.Threading.Tasks;
this.Close(); using Autodesk.Revit.ApplicationServices;
} using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
private void btnMessage_Click(object sender, RoutedEventArgs e) { using Autodesk.Revit.Attributes;
MessageBox.Show("Revit API by eTlipse!", "Ola Revit com WPF!"); using Autodesk.Revit.UI.Selection;
}
}
} namespace RevitCommand {
[Transaction(TransactionMode.Manual)]
class RevitWithWPF : IExternalCommand {
public Result Execute(ExternalCommandData commandData, ref string message,
ElementSet elements) {
HelloWPF helloWPF = new HelloWPF();
helloWPF.Show();

return Result.Succeeded;

}
}

Página 199
Página 200

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
}

using System; using System;


using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Autodesk.Revit.DB; using System.Diagnostics;
using Autodesk.Revit.UI; using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes; using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI.Selection; using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace WpfAppRevitAPI20180619 { using Autodesk.Revit.UI.Selection;

[Transaction(TransactionMode.Manual)] namespace BIMRevitAPI20181017 {


class MoveElement : IExternalCommand {
public Result Execute(ExternalCommandData commandData, ref string message, [Transaction(TransactionMode.Manual)]
ElementSet elements) { class BIMRevitAPI_20181017 : IExternalCommand {

UIDocument uiDoc = commandData.Application.ActiveUIDocument; // Plugin entrance


Document doc = uiDoc.Document; public Result Execute(ExternalCommandData commandData, ref string message,
Selection sel = uiDoc.Selection; ElementSet elements) {

Element selectedElement = try {


doc.GetElement(sel.PickObject(ObjectType.Element, "Select element like column!")); // Connecting Application, Document, etc...
UIApplication uiApp = commandData.Application;
LocationPoint selectedElementLocation = selectedElement.Location as UIDocument uiDoc = uiApp.ActiveUIDocument;
LocationPoint; Application app = uiApp.Application;
Document doc = uiDoc.Document;
// Tip 1: CTRL + K + S for involve the code to dispose! Than using! Selection sel = uiDoc.Selection;
// Tip 2: CTRL + K + D to organize the code!
Element e = SelectElement(uiDoc, doc);
using (Transaction trn = new Transaction(doc, "Move element like Parameter parameter = e.LookupParameter("Comentários");
column!")) {
trn.Start(); using (Transaction t = new Transaction(doc, "Parameter")) {
selectedElementLocation.Move(XYZ.BasisX.Multiply(5)); t.Start("Param");
trn.Commit(); try {
} parameter.Set("Comments Column");
return Result.Succeeded; } catch (Exception ex) {
} message = ex.Message;
} TaskDialog.Show("Error!",message);
} }
t.Commit();
}

} catch (Exception ex) {


message = ex.Message;
TaskDialog.Show("Error!",message);
return Result.Failed;
}
return Result.Succeeded;
}

Página 201
Página 202

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
// Select Element
public Element SelectElement(UIDocument uiDoc, Document doc) { namespace BIMRevitAPI20181017 {
Reference reference = uiDoc.Selection.PickObject(ObjectType.Element);
Element element = uiDoc.Document.GetElement(reference); [Transaction(TransactionMode.Manual)]
return element; class BIMRevitAPI_20181017 : IExternalCommand {
}
// Plugin entrance
// Get Parameter Value public Result Execute(ExternalCommandData commandData, ref string message,
public string GetParameterValue(Parameter parameter) { ElementSet elements) {
switch (parameter.StorageType) {
case StorageType.None: try {
return parameter.AsValueString(); // Connecting Application, Document, etc...
case StorageType.Integer: UIApplication uiApp = commandData.Application;
// Get value with unit, AsInteger() can get value without unit UIDocument uiDoc = uiApp.ActiveUIDocument;
return parameter.AsValueString(); Application app = uiApp.Application;
case StorageType.Double: Document doc = uiDoc.Document;
// Get value with unit, AsDouble() can get value without unit Selection sel = uiDoc.Selection;
return parameter.AsValueString();
case StorageType.String: Element e = SelectElement(uiDoc, doc);
return parameter.AsValueString(); Parameter parameter =
case StorageType.ElementId: e.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET);
return parameter.AsElementId().IntegerValue.ToString();
default: using (Transaction t = new Transaction(doc, "Param")) {
return ""; t.Start("Param");
} try {
} parameter.Set(-5); // 5 feet - Revit trabalha internamente com
feet - 1 feet = 0,3048 meters
} } catch (Exception ex) {
message = ex.Message;
} TaskDialog.Show("Error!",message);
}
t.Commit();
TaskDialog.Show("New Value", GetParameterValue(parameter));
}

} catch (Exception ex) {


message = ex.Message;
TaskDialog.Show("Error!",message);
return Result.Failed;
}
return Result.Succeeded;
}

// Select Element
public Element SelectElement(UIDocument uiDoc, Document doc) {
Reference reference = uiDoc.Selection.PickObject(ObjectType.Element);
Element element = uiDoc.Document.GetElement(reference);
// Atenção - Revit trabalha internamente com pés (feet). 1 feet = 0,3048 meters! return element;
}

// Get Parameter Value


using System; public string GetParameterValue(Parameter parameter) {
using System.Collections.Generic; switch (parameter.StorageType) {
using System.Linq; case StorageType.None:
using System.Text; return parameter.AsValueString();
using System.Threading.Tasks; case StorageType.Integer:
using System.Diagnostics; // Get value with unit, AsInteger() can get value without unit
using Autodesk.Revit.ApplicationServices; return parameter.AsValueString();
using Autodesk.Revit.Attributes; case StorageType.Double:
using Autodesk.Revit.DB; // Get value with unit, AsDouble() can get value without unit
using Autodesk.Revit.UI; return parameter.AsValueString();
using Autodesk.Revit.UI.Selection; case StorageType.String:

Página 203
Página 204

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
return parameter.AsValueString(); } else {
case StorageType.ElementId: // Interação com o Excel
return parameter.AsElementId().IntegerValue.ToString(); Excel.Application xlApp = new
default: Microsoft.Office.Interop.Excel.Application();
return ""; if (xlApp == null) {
} MessageBox.Show("Excel is not properly installed!!");
} return Result.Failed;
}
} Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
} object misValue = System.Reflection.Missing.Value;
xlWorkBook = xlApp.Workbooks.Add(misValue);
xlWorkSheet =
(Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

// Interação com o Revit


String info = "IDs of selected elements in the document are:";
int x = 1;
int y = 1;
xlWorkSheet.Cells[x, y] = info;
x = x + 1;
foreach (ElementId item in elementIds) {
//info += "\n\t" + item.IntegerValue;
xlWorkSheet.Cells[x, 1] = item.IntegerValue;
x = x + 1;
}
// TaskDialog.Show("Revit", info);

// Saving Excel File


using System;
xlWorkBook.SaveAs("d:\\temp\\Revit-Excel.xls",
using System.Collections.Generic;
Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue,
using System.Linq;
Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue,
using System.Text;
misValue, misValue, misValue);
using System.Threading.Tasks; xlWorkBook.Close(true, misValue, misValue);
using Autodesk.Revit.UI;
xlApp.Quit();
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;
// Cuidando da memória!
using Autodesk.Revit.UI.Selection;
Marshal.ReleaseComObject(xlWorkSheet);
using Autodesk.Revit.ApplicationServices;
Marshal.ReleaseComObject(xlWorkBook);
using Excel = Microsoft.Office.Interop.Excel;
Marshal.ReleaseComObject(xlApp);
using System.Windows;
using System.Runtime.InteropServices;
MessageBox.Show("Excel file created, you can find the file
d:\\temp\\Revit-Excel.xls");
namespace RevitToExcel20190417 {
}
}
[Transaction(TransactionMode.Manual)]
class RevitToExcel20190417 : IExternalCommand {
return Result.Succeeded;
public Result Execute(ExternalCommandData commandData, ref string message,
ElementSet elements) {
} catch (Exception ex) {
try {
TaskDialog.Show("Error!", ex.Message);
UIApplication uiApp = commandData.Application;
return Result.Failed;
UIDocument uiDoc = uiApp.ActiveUIDocument;
}
Autodesk.Revit.ApplicationServices.Application app =
}
uiApp.Application; }
Document doc = uiDoc.Document;
Selection sel = uiDoc.Selection;
}
ICollection<ElementId> elementIds = sel.GetElementIds();

using (Transaction t = new Transaction(doc, "IDs")) {


if (elementIds.Count == 0) {
// If no element selected
TaskDialog.Show("Revit", "You haven't selected any element!");

Página 205
Página 206

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
}
TaskDialog.Show("Revit!", prompt);
return Result.Succeeded;
} catch (Exception ex) {
// In case of error.
TaskDialog.Show("Error!", ex.Message);
return Result.Failed;
}
}
}

// Usando o atalho WhereElementIsNotElementType() nos permite encontrar apenas


instâncias de determinada categoria.

using System;
using System.Collections.Generic; using System;
using System.Linq; using System.Collections.Generic;
using System.Text; using System.Linq;
using System.Threading.Tasks; using System.Text;
using Autodesk.Revit.ApplicationServices; using System.Threading.Tasks;
using Autodesk.Revit.UI; using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.DB; using Autodesk.Revit.UI;
using Autodesk.Revit.Attributes; using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection; using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI.Selection;
namespace Temp20190501 {
namespace Temp20190501 {
[Transaction(TransactionMode.Manual)]
class Temp20190501 : IExternalCommand { [Transaction(TransactionMode.Manual)]
public Result Execute(ExternalCommandData commandData, ref string message, class Temp20190501 : IExternalCommand {
ElementSet elements) { /// <summary>
// Estabelecendo conexoes. /// Commando para Revit usando sua API.
UIApplication uiApp = commandData.Application; /// </summary>
UIDocument uiDoc = uiApp.ActiveUIDocument; /// <param name="commandData"></param>
Application app = uiApp.Application; /// <param name="message"></param>
Document doc = uiDoc.Document; /// <param name="elements"></param>
Selection sel = uiDoc.Selection; /// <returns></returns>
public Result Execute(ExternalCommandData commandData, ref string message,
try { ElementSet elements) {
// Find all wall instances in the document by using category filter. // Estabelecendo conexoes.
ElementCategoryFilter filter = new UIApplication uiApp = commandData.Application;
ElementCategoryFilter(BuiltInCategory.OST_Walls); UIDocument uiDoc = uiApp.ActiveUIDocument;
// Apply the filter to the elements in the active document. Application app = uiApp.Application;
//Use shortcut WhereElementIsNotElementType() to find wall instances Document doc = uiDoc.Document;
only. Selection sel = uiDoc.Selection;
FilteredElementCollector collector = new
FilteredElementCollector(doc); try {
IList<Element> walls = /* Criar um filtro ElementParameter para encontrar rooms com área
collector.WherePasses(filter).WhereElementIsNotElementType().ToElements(); superiores a um dado valor
String prompt = "The walls in the current document are:\n"; * Criar um filtro usando provider e evaluator
foreach (Element e in walls) { */
prompt = prompt + e.Name + "\n"; BuiltInParameter areaParam = BuiltInParameter.ROOM_AREA;

Página 207
Página 208

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
// Provider using System;
ParameterValueProvider pvp = new ParameterValueProvider(new using System.Collections.Generic;
ElementId((int)areaParam)); using System.Linq;
// Evaluator using System.Text;
FilterNumericRuleEvaluator fnrv = new FilterNumericGreater(); using System.Threading.Tasks;
// Rule value using Autodesk.Revit.ApplicationServices;
double ruleValue = 100.0f; // Filtrar rooms com area superior a este using Autodesk.Revit.UI;
valor. using Autodesk.Revit.DB;
// Rule using Autodesk.Revit.Attributes;
FilterRule fRule = new FilterDoubleRule(pvp, fnrv, ruleValue, 1E-6); using Autodesk.Revit.UI.Selection;

// Criar um filtro ElementParameter namespace RevitAPI20190820 {


ElementParameterFilter filter = new ElementParameterFilter(fRule);
[Transaction(TransactionMode.Manual)]
// Aplicar o filtro para os elementos do documento ativo. class RevitAPI : IExternalCommand {
FilteredElementCollector collector = new public Result Execute(ExternalCommandData commandData, ref string message,
FilteredElementCollector(doc); ElementSet elements) {
IList<Element> rooms = collector.WherePasses(filter).ToElements();
String prompt = "Rooms com área > 100 no documento ativo:\n"; // Estabelecendo as conexoes
foreach (Element element in rooms) { UIApplication uiApp = commandData.Application;
prompt = prompt + element.Name + "\n"; UIDocument uiDoc = uiApp.ActiveUIDocument;
} Application app = uiApp.Application;
Document doc = uiDoc.Document;
// Encontrar rooms com areas menor que ou igual a 100. Selection sel = uiDoc.Selection;
fnrv = new FilterNumericLessOrEqual();
fRule = new FilterDoubleRule(pvp, fnrv, ruleValue, 1E-6); try {
ElementParameterFilter lessOrEqualFilter = new // Encontrar todas as instancias de portas no projeto encontrando
ElementParameterFilter(fRule, false); todos os elementos que
collector = new FilteredElementCollector(doc); // pertencem a categoria porta e sao familia de instancia
IList<Element> lessOrEqualFounds = ElementClassFilter familyInstanceFilter = new
collector.WherePasses(lessOrEqualFilter).ToElements(); ElementClassFilter(typeof(FamilyInstance));
prompt = prompt + "\n Rooms com área <= 100 no documento ativo:\n";
foreach (Element element in lessOrEqualFounds) { // Criar uma categoria filtro para portas
prompt = prompt + element.Name + "\n"; ElementCategoryFilter doorsCategoryFilter = new
} ElementCategoryFilter(BuiltInCategory.OST_Doors);
TaskDialog.Show("Revit API!", prompt);
// Criar a logica e filtro para Door FamilyInstance
return Result.Succeeded; LogicalAndFilter doorInstancesFilter = new
} catch (Exception ex) { LogicalAndFilter(familyInstanceFilter, doorsCategoryFilter);
// Em caso de erro ...
TaskDialog.Show("Error!", ex.Message); // Aplicar o filtro para os elementos ativos no documento
return Result.Failed; FilteredElementCollector collector = new
} FilteredElementCollector(doc);
} IList<Element> doors =
} collector.WherePasses(doorInstancesFilter).ToElements();

} // Listar as portas
String prompt = "Portas:\n";
foreach (Element element in doors) {
prompt = prompt + "ID - " + element.Id + " / Nome - " +
element.Name + "\n";
}
TaskDialog.Show("Revit API", prompt);

return Result.Succeeded;
} catch (Exception ex) {
message = ex.Message;
TaskDialog.Show("Error!", message);
return Result.Failed;
}
}
}

Página 209
Página 210

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
TaskDialog.Show("Revit API", prompt);
break;
} }
}
return Result.Succeeded;
} catch (Exception ex) {
message = ex.Message;
TaskDialog.Show("Error!", message);
return Result.Failed;
}
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.DB.Architecture;

namespace RevitAPI20190820 {

[Transaction(TransactionMode.Manual)] using System;


class RevitAPI : IExternalCommand { using System.Collections.Generic;
public Result Execute(ExternalCommandData commandData, ref string message, using System.Linq;
ElementSet elements) { using System.Text;
using System.Threading.Tasks;
// Estabelecendo as conexoes using Autodesk.Revit.ApplicationServices;
UIApplication uiApp = commandData.Application; using Autodesk.Revit.UI;
UIDocument uiDoc = uiApp.ActiveUIDocument; using Autodesk.Revit.DB;
Application app = uiApp.Application; using Autodesk.Revit.Attributes;
Document doc = uiDoc.Document; using Autodesk.Revit.UI.Selection;
Selection sel = uiDoc.Selection;
namespace RevitAPI20190820 {
try {
// Usar filtro para encontrar todos os rooms do documento [Transaction(TransactionMode.Manual)]
RoomFilter filter = new RoomFilter(); class RevitAPI : IExternalCommand {
public Result Execute(ExternalCommandData commandData, ref string message,
// Aplicar o filtro para os elementos no documento ativo ElementSet elements) {
FilteredElementCollector collector = new
FilteredElementCollector(doc); // Estabelecendo as conexoes
collector.WherePasses(filter); UIApplication uiApp = commandData.Application;
UIDocument uiDoc = uiApp.ActiveUIDocument;
// Obter resultado como ElementId Interator Application app = uiApp.Application;
FilteredElementIdIterator roomIdItr = Document doc = uiDoc.Document;
collector.GetElementIdIterator(); Selection sel = uiDoc.Selection;
roomIdItr.Reset();
while (roomIdItr.MoveNext()){ try {
ElementId roomId = roomIdItr.Current; // Usar ElementClassFilter para encontrar instancias de familias cujo
// Quando o room for menor que 50 nome seja 10" Coluna
Room room = doc.GetElement(roomId) as Room; ElementClassFilter filter = new
if (room.Area < 50.0) { ElementClassFilter(typeof(FamilyInstance));
String prompt = "Room e muito pequeno: id = " +
roomId.ToString(); // Aplicar o filtro para os eleentos no documento ativo

Página 211
Página 212

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
FilteredElementCollector collector = new namespace RevitAPI20190820 {
FilteredElementCollector(doc);
collector.WherePasses(filter); [Transaction(TransactionMode.Manual)]
class RevitAPI : IExternalCommand {
// Usar Linq para encontrar a instancia de familia cujo nome seja 10" public Result Execute(ExternalCommandData commandData, ref string message,
Coluna ElementSet elements) {
var query = from element in collector
where element.Name == "10\" Coluna" // Estabelecendo as conexoes
select element; UIApplication uiApp = commandData.Application;
// Fazer um cast do elemento encontrado para instancia de familia UIDocument uiDoc = uiApp.ActiveUIDocument;
// essa conversao é segura para FamilyInstance porque foi usado Application app = uiApp.Application;
ElementClassFilter para FamilyInsance Document doc = uiDoc.Document;
List<FamilyInstance> familyInstances = Selection sel = uiDoc.Selection;
query.Cast<FamilyInstance>().ToList<FamilyInstance>();
String prompt = "Faily Instances:\n"; try {
foreach (FamilyInstance instance in familyInstances) { // Pegar os elementos selecionados no documento atual
prompt = prompt + instance.Id.ToString() + "\n"; IList<Reference> references = sel.PickObjects(ObjectType.Element);
}
TaskDialog.Show("Revit API", prompt); // Mostra quantidade de elementos selecionados. Eh preciso acionar os
return Result.Succeeded; botoes Finish ou Cancel para finalizar a selecao
} catch (Exception ex) { TaskDialog.Show("Revit API!", "Numero de elementos selecionados: " +
message = ex.Message; references.Count.ToString());
TaskDialog.Show("Error!", message);
return Result.Failed; // Criar uma nova selecao de elementos para receber os elementos
} especificos de interesse da selecao mais ampla
} IList<Element> collection = new List<Element>();
}
// Adicionamos apenas Walls aa colecao
foreach (Reference reference in references) {
} Element element = doc.GetElement(reference);
if (element is Wall) {
collection.Add(element);
}
}

// Informa o resultado da selecao


if (collection.Count != 0) {
TaskDialog.Show("Revit API!", "Total de paredes selecionadas " +
collection.Count.ToString());
} else {
TaskDialog.Show("Revit API!", "Nenhuma parede selecionada!");
}

return Result.Succeeded;

} catch (Exception ex) {


message = ex.Message;
TaskDialog.Show("Error!", message);

return Result.Failed;
}
using System; }
using System.Collections.Generic; }
using System.Linq;
using System.Text;
using System.Threading.Tasks; }
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI.Selection;

Página 213
Página 214

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Autodesk.Revit.ApplicationServices; using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.UI; using Autodesk.Revit.UI;
using Autodesk.Revit.DB; using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes; using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI.Selection; using Autodesk.Revit.UI.Selection;

namespace RevitAPI20190820 { namespace RevitAPI20190820 {

[Transaction(TransactionMode.Manual)] [Transaction(TransactionMode.Manual)]
class RevitAPI : IExternalCommand { class RevitAPI : IExternalCommand {
public Result Execute(ExternalCommandData commandData, ref string message, public Result Execute(ExternalCommandData commandData, ref string message,
ElementSet elements) { ElementSet elements) {

// Estabelecendo as conexoes // Estabelecendo as conexoes


UIApplication uiApp = commandData.Application; UIApplication uiApp = commandData.Application;
UIDocument uiDoc = uiApp.ActiveUIDocument; UIDocument uiDoc = uiApp.ActiveUIDocument;
Application app = uiApp.Application; Application app = uiApp.Application;
Document doc = uiDoc.Document; Document doc = uiDoc.Document;
Selection sel = uiDoc.Selection; Selection sel = uiDoc.Selection;

try { try {
// Selecione alguns elementos antes da execucao // Adquirindo os elementos selecionados no documento corrente
ICollection<ElementId> selectedIds = sel.GetElementIds();
ICollection<ElementId> selectedIds = sel.GetElementIds();
// Exibe o numero corrente de elementos selecionados
if (0 == selectedIds.Count) { TaskDialog.Show("Revit API!", "Numero de elementos selecionados: " +
// Se nenhuma elemento for selecionado selectedIds.Count.ToString());
TaskDialog.Show("Revit", "Voce nao selecionou nenhum elemento.");
} else { // Entrar na selecao e filtrar apenas as paredes
String info = "Os Ids dos elementos selecionados no docuento sao: ICollection<ElementId> selectedWallIds = new List<ElementId>();
";
foreach (ElementId id in selectedIds) { foreach (ElementId id in selectedIds) {
info += "\n\t" + id.IntegerValue; Element element = doc.GetElement(id);
} if (element is Wall) {
selectedWallIds.Add(id);
TaskDialog.Show("Revit API", info); }
} }

} catch (Exception ex) { // Estabelece o conjunto de elementos criados como o conjunto de


message = ex.Message; selecao corrente
TaskDialog.Show("Error!", message); sel.SetElementIds(selectedWallIds);
return Result.Failed;
} // Apresenta algumas informacoes ao usuario
return Result.Succeeded; if (0 != selectedWallIds.Count) {
} TaskDialog.Show("Revit API!", selectedWallIds.Count.ToString() + "
} Paredes foram selecionadas!");
} else {
TaskDialog.Show("Revit API!", "Nenhuma parede foi selecionada!");
} }

} catch (Exception ex) {


message = ex.Message;
TaskDialog.Show("Error!", message);
return Result.Failed;
}
return Result.Succeeded;
}

Página 215
Página 216

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
} string prompt = string.Format("{0} elementos foram adicionados aa
selecao!", newSelectionCount - selectionCount);
TaskDialog.Show("Revit API!", prompt);
} }

return Result.Succeeded;

} catch (Exception ex) {


message = ex.Message;
TaskDialog.Show("Error!", message);

return Result.Failed;
}
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; using System;
using System.Threading.Tasks; using System.Collections.Generic;
using Autodesk.Revit.ApplicationServices; using System.Linq;
using Autodesk.Revit.UI; using System.Text;
using Autodesk.Revit.DB; using System.Threading.Tasks;
using Autodesk.Revit.Attributes; using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.UI.Selection; using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
namespace RevitAPI20190820 { using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI.Selection;
[Transaction(TransactionMode.Manual)]
class RevitAPI : IExternalCommand { namespace RevitAPI20190820 {
public Result Execute(ExternalCommandData commandData, ref string message,
ElementSet elements) { [Transaction(TransactionMode.Manual)]
class RevitAPI : IExternalCommand {
// Estabelecendo as conexoes public Result Execute(ExternalCommandData commandData, ref string message,
UIApplication uiApp = commandData.Application; ElementSet elements) {
UIDocument uiDoc = uiApp.ActiveUIDocument;
Application app = uiApp.Application; // Estabelecendo as conexoes
Document doc = uiDoc.Document; UIApplication uiApp = commandData.Application;
Selection sel = uiDoc.Selection; UIDocument uiDoc = uiApp.ActiveUIDocument;
Application app = uiApp.Application;
try { Document doc = uiDoc.Document;
// Seleciona apenas um elemento do Revit Selection sel = uiDoc.Selection;
int selectionCount = 0;
Reference hasPickOne = sel.PickObject(ObjectType.Element); try {
if (hasPickOne != null) { // Snap point
selectionCount = 1; ObjectSnapTypes snapTypes = ObjectSnapTypes.Endpoints |
TaskDialog.Show("Revit API!", "Um elemento foi adicionado aa ObjectSnapTypes.Intersections;
selecao!"); XYZ point = sel.PickPoint(snapTypes, "Selecione um ponto final ou de
} interseccao!");

// Seleciona elementos do Revit string strCoords = "Ponto selecionado eh " + point.ToString();


IList<Element> hasPickSome = sel.PickElementsByRectangle("Selecao com
retangulo."); TaskDialog.Show("Revit API!", strCoords);
if (hasPickSome.Count > 0) {
int newSelectionCount = hasPickSome.Count;

Página 217
Página 218

} catch (Exception ex) {

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
message = ex.Message; info += elem.Name + "\n";
TaskDialog.Show("Error!", message); }
return Result.Failed; TaskDialog.Show("Revit", info);
}
return Result.Succeeded; return Result.Succeeded;
} } catch (Exception ex) {
} TaskDialog.Show("Revit API sample fail: ", ex.Message);
return Result.Failed;
}
} }
}
}

using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Structure;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace RevitCommand {
[Transaction(TransactionMode.Manual)]
class RevitWithWPF : IExternalCommand {
public Result Execute(ExternalCommandData commandData, ref string message,
ElementSet elements) {
using Autodesk.Revit.ApplicationServices;
// Estabelecendo conexoes using Autodesk.Revit.Attributes;
UIDocument uiDoc = commandData.Application.ActiveUIDocument; using Autodesk.Revit.DB;
Document doc = uiDoc.Document; using Autodesk.Revit.UI;
Selection sel = uiDoc.Selection; using Autodesk.Revit.UI.Selection;
IList<Element> elems = sel.PickElementsByRectangle(); using System;
using System.Collections.Generic;
try { using System.Linq;
string info = "Elementos selecionados:\n"; using System.Text;
foreach (Element elem in elems) { using System.Threading.Tasks;
info += elem.Name + "\n";
} namespace RvtAPI_Temp_Prj_20191016 {
TaskDialog.Show("Revit", info);
[Transaction(TransactionMode.Manual)]
info = "Niveis no documento:\n"; public class ParameterInfo : IExternalCommand {
FilteredElementCollector collector = new public Result Execute(ExternalCommandData commandData, ref string message,
FilteredElementCollector(doc); ElementSet elements) {
ICollection<Element> collection =
collector.OfClass(typeof(Level)).ToElements(); // Estabelecendo as conexoes
foreach (Element elem in collection) { UIApplication uiApp = commandData.Application;

Página 219
Página 220

// nao precisa checar se elem eh nulo UIDocument uiDoc = uiApp.ActiveUIDocument;

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Application app = uiApp.Application; }
Document doc = uiDoc.Document; break;
Selection sel = uiDoc.Selection; default:
defName = "Parametro inesperado!";
try { break;
// Selecionar elemento }
Element element = doc.GetElement(sel.PickObject(ObjectType.Element, return defName;
"Selecione um elemento!")); }
}
// String que recebera os parametros }
StringBuilder st = new StringBuilder();
st.AppendLine("Mostrar parametros do elemento selecionado:\n");

// Interagir com os parametros do elemento


foreach (Parameter para in element.Parameters) {
st.AppendLine(GetParameterInformation(para, doc));
}

// Retornar informacoes
TaskDialog.Show("Revit API - eTlipse!", st.ToString());

return Result.Succeeded;
using Autodesk.Revit.ApplicationServices;
} catch (Exception ex) { using Autodesk.Revit.Attributes;
message = ex.Message; using Autodesk.Revit.DB;
TaskDialog.Show("Revit API - Error!", message); using Autodesk.Revit.UI;
return Result.Failed; using Autodesk.Revit.UI.Selection;
} using System;
} using System.Collections.Generic;
string GetParameterInformation(Parameter para, Document document) { using System.Linq;
string defName = para.Definition.Name + "\t -> \t"; using System.Text;
// Usar diferentes metodos para adquirir os dados dos parametros de acordo using System.Threading.Tasks;
com o tipo armazenado
switch (para.StorageType) { namespace RvtAPI_Temp_Prj_20191016 {
case StorageType.None:
defName = "Parametro inesperado!"; [Transaction(TransactionMode.Manual)]
break; public class ParameterInfo : IExternalCommand {
case StorageType.Integer: public Result Execute(ExternalCommandData commandData, ref string message,
if (ParameterType.YesNo == para.Definition.ParameterType) { ElementSet elements) {
if (para.AsInteger() == 0) {
defName += " : " + "False"; // Estabelecendo as conexoes
} else { UIApplication uiApp = commandData.Application;
defName += " : " + "True"; UIDocument uiDoc = uiApp.ActiveUIDocument;
} Application app = uiApp.Application;
} else { Document doc = uiDoc.Document;
defName += " : " + para.AsInteger().ToString(); Selection sel = uiDoc.Selection;
}
break; try {
case StorageType.Double: // Selecionar elemento
// Converter o numero em Metro Element element = doc.GetElement(sel.PickObject(ObjectType.Element,
defName += para.AsValueString(); "Selecione um elemento!"));
break;
case StorageType.String: // String que recebera os dados do parametro
defName += " : " + para.AsValueString(); string prompt = "Parametro :\n";
break;
case StorageType.ElementId: // Encontrar parametro
// Encontrar o nome do elemento Parameter elementParameter = FindParameter(element);
ElementId id = para.AsElementId(); prompt += elementParameter.AsValueString();
if (id.IntegerValue >= 0) {
defName += " : " + document.GetElement(id).Name; // Exibir informacoes
} else { TaskDialog.Show("Revit API - eTlipse!", prompt);
defName += " : " + id.IntegerValue.ToString();

Página 221
Página 222

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
return Result.Succeeded;
// String que recebera os dados do parametro
} catch (Exception ex) { string prompt = "Valor do parametro :\n";
message = ex.Message;
TaskDialog.Show("Revit API - Error!", message); // Encontrar parametro
return Result.Failed; Parameter elementParameter = FindBuiltInParameter(element);
} prompt += elementParameter.AsValueString();
}
public Parameter FindParameter(Element element) { // Exibir informacoes
Parameter foundParameter = null; TaskDialog.Show("Revit API - eTlipse!", prompt);
// Encontrar o primeiro parametro que mede comprimento
foreach (Parameter parameter in element.Parameters) { return Result.Succeeded;
if (parameter.Definition.ParameterType == ParameterType.Length) {
foundParameter = parameter; } catch (Exception ex) {
break; message = ex.Message;
} TaskDialog.Show("Revit API - Error!", message);
} return Result.Failed;
return foundParameter; }
} }
} public Parameter FindBuiltInParameter(Wall wall) {
} // Usar WALL_BASE_OFFSET parametrId para acessar o parâmetro base offeset
da parede
BuiltInParameter paraIndex = BuiltInParameter.WALL_BASE_OFFSET;
Parameter parameter = wall.get_Parameter(paraIndex);
return parameter;
}
}
}

using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RvtAPI_Temp_Prj_20191016 { using Autodesk.Revit.ApplicationServices;


using Autodesk.Revit.Attributes;
[Transaction(TransactionMode.Manual)] using Autodesk.Revit.DB;
public class ParameterInfo : IExternalCommand { using Autodesk.Revit.UI;
public Result Execute(ExternalCommandData commandData, ref string message, using Autodesk.Revit.UI.Selection;
ElementSet elements) { using System;
using System.Collections.Generic;
// Estabelecendo as conexoes using System.Linq;
UIApplication uiApp = commandData.Application; using System.Text;
UIDocument uiDoc = uiApp.ActiveUIDocument; using System.Threading.Tasks;
Application app = uiApp.Application;
Document doc = uiDoc.Document; namespace RvtAPI_Temp_Prj_20191016 {
Selection sel = uiDoc.Selection;
[Transaction(TransactionMode.Manual)]
try { public class ParameterInfo : IExternalCommand {
// Selecionar parede public Result Execute(ExternalCommandData commandData, ref string message,
Wall element = doc.GetElement(sel.PickObject(ObjectType.Element, ElementSet elements) {
"Selecione uma parede!")) as Wall;

Página 223
Página 224

// Estabelecendo as conexoes
eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
UIApplication uiApp = commandData.Application; }
UIDocument uiDoc = uiApp.ActiveUIDocument; return result;
Application app = uiApp.Application; }
Document doc = uiDoc.Document;
Selection sel = uiDoc.Selection; }
}
try {
// Selecionar parede
Wall wall = doc.GetElement(sel.PickObject(ObjectType.Element,
"Selecione uma parede!")) as Wall;
// Usar WALL_BASE_OFFSET parametrId para acessar o parâmetro base
offeset da parede
BuiltInParameter paraIndex = BuiltInParameter.WALL_BASE_OFFSET;
Parameter parameter = wall.get_Parameter(paraIndex);
bool valueChanged = false;
double newValue = 0.3;

// Parametro original a testar


TaskDialog.Show("Revit API - eTlipse!", "Valor original do parametro :
\t" + parameter.AsValueString());
using System;
// Fazer o teste e alterar o valor, se teste der verdadeiro using System.Collections.Generic;
valueChanged = SetParameter(doc, parameter, newValue); using System.Linq;
using System.Text;
if (valueChanged) { using System.Threading.Tasks;
// Parametro modificado using Autodesk.Revit.ApplicationServices;
TaskDialog.Show("Revit API - eTlipse!", "Novo valor do parametro : using Autodesk.Revit.UI;
\t" + parameter.AsValueString()); using Autodesk.Revit.DB;
} using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI.Selection;
return Result.Succeeded;

} catch (Exception ex) { namespace RevitCommand {


message = ex.Message; [Transaction(TransactionMode.Manual)]
TaskDialog.Show("Revit API - Error!", message); class RevitWithWPF : IExternalCommand {
return Result.Failed; public Result Execute(ExternalCommandData commandData, ref string message,
} ElementSet elements) {
}
// Estabelecendo conexoes
public bool SetParameter(Document doc, Parameter parameter, double value) { UIDocument uiDoc = commandData.Application.ActiveUIDocument;
bool result = false; Document doc = uiDoc.Document;
Selection sel = uiDoc.Selection;
using (Transaction transaction = new Transaction(doc, "Testar
StorageType")) { try {
transaction.Start(); // Selecionar uma parede
// Se o parametro eh apenas leitura, nao eh possivel alterar o valor Wall wall = doc.GetElement(sel.PickObject(ObjectType.Element,
if (null != parameter && !parameter.IsReadOnly) { "Selecione uma parede!")) as Wall;
StorageType parameterType = parameter.StorageType;
if (StorageType.Double != parameterType) { // Acessar o parametro base offset da parede
// Os valores sao diferentes e nao devemos alterar o valor BuiltInParameter paramBaseIdex = BuiltInParameter.WALL_BASE_OFFSET;
transaction.RollBack(); Parameter paramBase = wall.get_Parameter(paramBaseIdex);
throw new Exception("O tipo gravado e o valor do parametro sao
diferentes!"); // Acessar o parametro area da parede
} else { BuiltInParameter paraAreaIdex = BuiltInParameter.HOST_AREA_COMPUTED;
// Se nao sao diferentes estabelecemos o resultado para Parameter paramArea = wall.get_Parameter(paraAreaIdex);
verdadeiro
// Converter o valor de metro para unidade interna // Recuperando o parametro area como string
result = parameter.Set(UnitUtils.ConvertToInternalUnits(value, TaskDialog.Show("Revit API sample!", "Area Parameter: " +
DisplayUnitType.DUT_METERS)); paramArea.AsValueString());
transaction.Commit();
} // Definindo novo valor para base offset
} using (Transaction transaction = new Transaction(doc, "Setar novo

Página 225
Página 226

valor de base offset.")) {


eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
transaction.Start(); using System.Linq;
if (!paramBase.IsReadOnly) { using System.Text;
paramBase.SetValueString("0.3"); using System.Threading.Tasks;
} using Autodesk.Revit.ApplicationServices;
transaction.Commit(); using Autodesk.Revit.UI;
} using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI.Selection;
return Result.Succeeded; using System.Windows;
} catch (Exception ex) {
TaskDialog.Show("Revit API sample fail: ", ex.Message); namespace RevitCommand {
return Result.Failed; [Transaction(TransactionMode.Manual)]
} class RevitWithWPF : IExternalCommand {
} public Result Execute(ExternalCommandData commandData, ref string message,
} ElementSet elements) {
}
// Estabelecendo conexoes
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
Selection sel = uiDoc.Selection;

try {
// Selecionar uma parede
FamilyInstance opening =
doc.GetElement(sel.PickObject(ObjectType.Element, "Selecione uma abertura!")) as
FamilyInstance;

// Pegar os parametros da altura original da soleira e do topo da


abertura
Parameter sillPara =
opening.get_Parameter(BuiltInParameter.INSTANCE_SILL_HEIGHT_PARAM);
Parameter headPara =
opening.get_Parameter(BuiltInParameter.INSTANCE_HEAD_HEIGHT_PARAM);
double sillHeight = sillPara.AsDouble();
double origHeadHeight = headPara.AsDouble();

// Mudando apenas a altura da soleira


using (Transaction transaction = new Transaction(doc, "Setar novo
valor de altura da soleira.")) {
transaction.Start();
sillPara.Set(sillHeight + 2.0);
transaction.Commit();
}

// A altura do topo eh recalculada


double newHeadHeight = headPara.AsDouble();
MessageBox.Show("Antiga altura do topo: " + origHeadHeight + "; nova
altura do topo: " + newHeadHeight);

return Result.Succeeded;
} catch (Exception ex) {
TaskDialog.Show("Revit API sample fail: ", ex.Message);
return Result.Failed;
}
}
}
}

using System;

Página 227
Página 228

using System.Collections.Generic;

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
// Estabelecendo conexoes

UIDocument uiDoc = commandData.Application.ActiveUIDocument;

Document doc = uiDoc.Document;

Selection sel = uiDoc.Selection;

try {

// Selecionar um pilar

FamilyInstance column =
doc.GetElement(sel.PickObject(ObjectType.Element, "Selecione um pilar!"))

as FamilyInstance;

// Adquirir a localizacao atual do pilar

LocationPoint columnLocation = column.Location as LocationPoint;

XYZ oldPlace = columnLocation.Point;

// Usando transacao para mover o pilar

using (Transaction transactionPilar = new Transaction(doc, "Mover


pilar.")) {

transactionPilar.Start();

using Autodesk.Revit.ApplicationServices;

using Autodesk.Revit.Attributes; // Mover o pilar para um novo local

using Autodesk.Revit.DB; XYZ newPlace = new XYZ(5, 10, 10);

using Autodesk.Revit.UI; ElementTransformUtils.MoveElement(doc, column.Id, newPlace);

using Autodesk.Revit.UI.Selection; transactionPilar.Commit();

using System; }

using System.Collections.Generic;

using System.Linq;

using System.Text; // Verificar a nova posicao do pilar

using System.Threading.Tasks; columnLocation = column.Location as LocationPoint;

using System.Windows; XYZ newActual = columnLocation.Point;

namespace RevitCommand { string info = "Posicao original X: " + oldPlace.X.ToString() + "\nNova


posicao X: " + newActual.X.ToString();
[Transaction(TransactionMode.Manual)]
TaskDialog.Show("Revit API!", info);
class RevitWithWPF : IExternalCommand {

public Result Execute(ExternalCommandData commandData, ref string message,


ElementSet elements) { // Selecionar um pilar para mover com Point

Página 229
Página 230

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
column = doc.GetElement(sel.PickObject(ObjectType.Element, "Selecione // Mover parede usando Curve
um pilar.")) as FamilyInstance;
using (Transaction transactionParedeCurve = new Transaction(doc, "Mover
parede com Curve.")) {
// Mover pilar usando Point transactionParedeCurve.Start();
using (Transaction transactionPilarPoint = new Transaction(doc, "Mover LocationCurve wallLine = wall.Location as LocationCurve;
pilar com Point.")) {
XYZ p1 = XYZ.Zero;
transactionPilarPoint.Start();
XYZ p2 = new XYZ(10, 20, 0);
LocationPoint columnPoint = column.Location as LocationPoint;
Line newWallLine = Line.CreateBound(p1, p2);
if (null != columnPoint) {

XYZ newLocation = new XYZ(10, 20, 0);


// Alterar a linha da parede para a nova linha

wallLine.Curve = newWallLine;
// Mover o pilar para a nova posicao
transactionParedeCurve.Commit();
columnPoint.Point = newLocation;
}
}

transactionPilarPoint.Commit();
TaskDialog.Show("Revit API!", "Parede movida usando Curve!");
}

TaskDialog.Show("Revit API!", "Pilar movido usando Point!");


return Result.Succeeded;

// Selecionar uma parede para mover com Location


} catch (Exception ex) {
Wall wall = doc.GetElement(sel.PickObject(ObjectType.Element,
"Selecione uma parede com Location.")) as Wall; TaskDialog.Show("Revit API sample fail: ", ex.Message);

return Result.Failed;

// Mover parede usando Location }

using (Transaction transactionParedeLocation = new Transaction(doc, }


"Mover parede.")) {
}
transactionParedeLocation.Start();
}
LocationCurve wallLine = wall.Location as LocationCurve;

XYZ translationVec = new XYZ(5, 15, 0);

wallLine.Move(translationVec);

transactionParedeLocation.Commit();

TaskDialog.Show("Revit API!", "Parede movida usando Location!");

// Selecionar uma parede para mover com Curve

wall = doc.GetElement(sel.PickObject(ObjectType.Element, "Selecione uma


parede.")) as Wall;

Página 231
Página 232

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
// O eixo deve ser uma bound line
Line axis = Line.CreateBound(point1, point2);

// Usando transacao para girar o pilar


using (Transaction transactionRotateColumn = new Transaction(document,
"Rotacionar pilar.")) {
transactionRotateColumn.Start();

using Autodesk.Revit.ApplicationServices; // Movemos o pilar antes para o ponto base apenas para melhor
using Autodesk.Revit.Attributes; visualiza
using Autodesk.Revit.DB;
using Autodesk.Revit.UI; // Mover nao faz parte da rotacao e nao eh necessario
using Autodesk.Revit.UI.Selection; LocationPoint locationPoint = element.Location as LocationPoint;
using System; locationPoint.Point = point1;
using System.Collections.Generic;
using System.Linq; // Fazer a rotacao em torno do eixo do elemento
using System.Text; ElementTransformUtils.RotateElement(document, element.Id, axis,
using System.Threading.Tasks; Math.PI / 3.0);
using System.Windows; transactionRotateColumn.Commit();
}
namespace RevitCommand {
[Transaction(TransactionMode.Manual)] }
class RevitWithWPF : IExternalCommand {
public Result Execute(ExternalCommandData commandData, ref string message, /// <summary>
ElementSet elements) { /// Rotacionar uma parede baseado no LocationCurve.
/// </summary>
// Estabelecendo conexoes /// <param name="document"></param>
UIDocument uiDoc = commandData.Application.ActiveUIDocument; /// <param name="element"></param>
Document doc = uiDoc.Document; /// <returns></returns>
Selection sel = uiDoc.Selection; bool LocationRotateByCurve(Document document, Element element) {
bool rotated = false;
try {
// Rotacionar o elemento via sua LocationCurve
// Selecionar um elemento. Neste caso tipo parede para ter uma linha using (Transaction transactionLocationRotate = new Transaction(document,
base! "Rotacionar por LocationCurve.")) {
Element element = doc.GetElement(sel.PickObject(ObjectType.Element, transactionLocationRotate.Start();
"Selecionar um elemento!")); LocationCurve curve = element.Location as LocationCurve;
if (null != curve) {
// Rotacionar um pilar baseado em seu eixo Curve line = curve.Curve;
//RotateColumn(doc, element); XYZ aa = line.GetEndPoint(0);
XYZ cc = new XYZ(aa.X, aa.Y, aa.Z + 10);
// Rotacionar elemento baseado em LocationCurve Line axis = Line.CreateBound(aa, cc);
//LocationRotateByCurve(doc, element); rotated = curve.Rotate(axis, Math.PI / 2.0);
}
// Rotacionar elemento baseado em LocationPoint transactionLocationRotate.Commit();
LocationRotateByPoint(doc, element); }
return rotated;
return Result.Succeeded; }
} catch (Exception ex) {
TaskDialog.Show("Revit API sample fail: ", ex.Message); /// <summary>
return Result.Failed; /// Rotacionar uma parede baseado no LocationPoint.
} /// </summary>
} /// <param name="document"></param>
/// <param name="element"></param>
/// <summary> /// <returns></returns>
/// Rotaciona um pilar baseado em seu eixo. bool LocationRotateByPoint(Document document, Element element) {
/// </summary> bool rotate = false;
/// <param name="document"></param>
/// <param name="element"></param> // Rotacionar o elemento via LocationPoint
public void RotateColumn(Document document, Element element) { using (Transaction transactionLocationPoint = new Transaction(document,
XYZ point1 = new XYZ(10, 20, 0); "Rotacionar por LocationPoint.")) {
XYZ point2 = new XYZ(10, 20, 30); transactionLocationPoint.Start();

Página 233
Página 234

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
LocationPoint location = element.Location as LocationPoint; return Result.Succeeded;
if (null != location) { } catch (Exception ex) {
XYZ aa = location.Point; TaskDialog.Show("Revit API sample fail: ", ex.Message);
XYZ cc = new XYZ(aa.X, aa.Y, aa.Z + 10); return Result.Failed;
Line axis = Line.CreateBound(aa, cc); }
rotate = location.Rotate(axis, Math.PI / 2.0); }
}
transactionLocationPoint.Commit(); /// <summary>
} /// Mirror wall
return rotate; /// </summary>
} /// <param name="document"></param>
/// <param name="wall"></param>
} public void MirrorWall(Document document, Wall wall) {
}
Reference reference = HostObjectUtils.GetSideFaces(wall,
ShellLayerType.Exterior).First();

// Get one of the wall's major side faces


Face face = wall.GetGeometryObjectFromReference(reference) as Face;

UV bboxMin = face.GetBoundingBox().Min;
// Create a plane based on this side face with an offset of 10 in the x &
y directions

Plane plane = Plane.CreateByNormalAndOrigin(face.ComputeNormal(bboxMin),


face.Evaluate(bboxMin).Add(new XYZ(10, 10, 0)));

// Using Transaction to mirror


using (Transaction transactionMirrorWall = new Transaction(document,
"Mirror wall")) {
using Autodesk.Revit.ApplicationServices; transactionMirrorWall.Start();
using Autodesk.Revit.Attributes; ElementTransformUtils.MirrorElement(document, wall.Id, plane);
using Autodesk.Revit.DB; transactionMirrorWall.Commit();
}
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
}
using System;
using System.Collections.Generic;
}
using System.Linq;
using System.Text; }
using System.Threading.Tasks;
using System.Windows;

namespace RevitCommand {
[Transaction(TransactionMode.Manual)]
class RevitWithWPF : IExternalCommand {
public Result Execute(ExternalCommandData commandData, ref string message,
ElementSet elements) {

// Establishing connections
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
Selection sel = uiDoc.Selection;

try {

// Select an element. In this case, a wall


Wall wall = doc.GetElement(sel.PickObject(ObjectType.Element, "Select
a wall!")) as Wall;

// Mirror wall
MirrorWall(doc, wall);
using Autodesk.Revit.ApplicationServices;

Página 235
Página 236

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB; transactionDeleteElements.Commit();
using Autodesk.Revit.UI; }
using Autodesk.Revit.UI.Selection;
using System; // Select elements not deleted
using System.Collections.Generic; allElements = collector.WhereElementIsNotElementType()
using System.Linq; .WhereElementIsViewIndependent()
using System.Text; .ToElements();
using System.Threading.Tasks;
using System.Windows; // Grouping elements just to show how to group elements. Not necessary
to delete
namespace RevitCommand { using (Transaction transactionGroupingElements = new Transaction(doc,
[Transaction(TransactionMode.Manual)] "Gruping elements")) {
class RevitWithWPF : IExternalCommand { transactionGroupingElements.Start();
public Result Execute(ExternalCommandData commandData, ref string message,
ElementSet elements) { Group group = null;

// Establishing connections ICollection<ElementId> selectedElementsID = new List<ElementId>();


UIDocument uiDoc = commandData.Application.ActiveUIDocument; foreach (Element element in allElements) {
Document doc = uiDoc.Document; selectedElementsID.Add(element.Id);
Selection sel = uiDoc.Selection; }

try { if (selectedElementsID.Count > 0) {


// Group all selected elements
FilteredElementCollector collector = new FilteredElementCollector(doc, group = doc.Create.NewGroup(selectedElementsID);
doc.ActiveView.Id); }
IList<Element> allElements = collector.WhereElementIsNotElementType()
.WhereElementIsViewIndependent() // Change the default group name to a new name "MyGroup"
.ToElements(); group.GroupType.Name = "MyGroup";
TaskDialog.Show("Revit API", "Total elements: " + allElements.Count);
// Count elements grouped
// Select an element int totalElement = 0;
Element oneElement = doc.GetElement(sel.PickObject(ObjectType.Element, IList<ElementId> memberIds = group.GetMemberIds();
"Select an element!")); foreach (ElementId id in memberIds) {
totalElement += 1;
// Deleting one element }
DeleteElement(doc, oneElement); TaskDialog.Show("Revit API", "Total elements grouped: " +
totalElement.ToString());
// Delete all the selected elements via the set of element ids
// Using Transaction to delete elements transactionGroupingElements.Commit();
using (Transaction transactionDeleteElements = new Transaction(doc, }
"Delete elements")) {
transactionDeleteElements.Start(); return Result.Succeeded;
IList<Element> elementsToDelete = sel.PickElementsByRectangle();
TaskDialog.Show("Revit API", "Total elements to delete: " + } catch (Exception ex) {
elementsToDelete.Count); TaskDialog.Show("Revit API sample fail: ", ex.Message);
ICollection<ElementId> idSelection = sel.GetElementIds(); return Result.Failed;
idSelection.Clear(); }
foreach (Element elem in elementsToDelete) { }
ElementId id = elem.Id;
idSelection.Add(id); /// <summary>
} /// Delete an element via its ID
/// </summary>
ICollection<ElementId> deletedIdSet = doc.Delete(idSelection); /// <param name="document"></param>
/// <param name="element"></param>
if (0 == deletedIdSet.Count) { public void DeleteElement(Document document, Element element) {
throw new Exception("Deleting the selected elements in Revit
failed."); ElementId elementId = element.Id;
} else {
TaskDialog.Show("Revit API", "The selected elements has been // Using Transaction to delete
removed."); using (Transaction transactionDeleteElement = new Transaction(document,
} "Delete element")) {

Página 237
Página 238

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
transactionDeleteElement.Start(); using System.Text;
using System.Threading.Tasks;
ICollection<ElementId> deleteIdSet = document.Delete(elementId); using System.Windows;

if (0 == deleteIdSet.Count) { namespace RevitCommand {


throw new Exception("Deleting the selected element in Revit [Transaction(TransactionMode.Manual)]
failed."); class RevitWithWPF : IExternalCommand {
} public Result Execute(ExternalCommandData commandData, ref string message,
ElementSet elements) {
String prompt = "The selected element has been removed and ";
prompt += deleteIdSet.Count - 1; // Establishing connections
prompt += " more depentent elements have also been removed."; UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
// Give the user some information Selection sel = uiDoc.Selection;
TaskDialog.Show("Revit API", prompt);
try {
transactionDeleteElement.Commit();
} CountElements(doc);

} return Result.Succeeded;

} } catch (Exception ex) {


} TaskDialog.Show("Revit API sample fail: ", ex.Message);
return Result.Failed;
}
}

/// <summary>
/// Count elements (walls) in the active view
/// </summary>
/// <param name="document"></param>
public void CountElements(Document document) {

StringBuilder message = new StringBuilder();

FilteredElementCollector viewCollector = new


FilteredElementCollector(document, document.ActiveView.Id);
viewCollector.OfCategory(BuiltInCategory.OST_Walls);

message.AppendLine("Wall category elements within view: " +


viewCollector.ToElementIds().Count);

FilteredElementCollector docCollector = new


FilteredElementCollector(document);
docCollector.OfCategory(BuiltInCategory.OST_Walls);
message.AppendLine("Wall category elements within document: " +
docCollector.ToElementIds().Count);

TaskDialog.Show("Revit API", message.ToString());


}

}
}

using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System;
using System.Collections.Generic;

Página 239
Página 240

using System.Linq;

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
prompt += "a floor view.";
break;
case ViewType.EngineeringPlan:
prompt += "an engeneering view.";
break;
case ViewType.AreaPlan:
prompt += "an area view.";
break;
case ViewType.CeilingPlan:
prompt += "a ceiling view.";
break;
using Autodesk.Revit.ApplicationServices;
case ViewType.Elevation:
using Autodesk.Revit.Attributes;
prompt += "an elevation view.";
using Autodesk.Revit.DB;
using Autodesk.Revit.UI; break;
using Autodesk.Revit.UI.Selection; case ViewType.Section:
prompt += "a section view.";
using System;
break;
using System.Collections.Generic;
case ViewType.Detail:
using System.Linq;
using System.Text; prompt += "a detail view.";
break;
using System.Threading.Tasks;
case ViewType.ThreeD:
using System.Windows;
prompt += "a threeD view.";
break;
namespace RevitCommand {
[Transaction(TransactionMode.Manual)] case ViewType.Schedule:
prompt += "a schedule view.";
class RevitWithWPF : IExternalCommand {
break;
public Result Execute(ExternalCommandData commandData, ref string message,
case ViewType.DraftingView:
ElementSet elements) {
prompt += "a drafting view.";
// Establishing connections break;
case ViewType.DrawingSheet:
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
prompt += "a drawing sheet view.";
Document doc = uiDoc.Document;
break;
Selection sel = uiDoc.Selection;
case ViewType.Legend:
prompt += "a legend view.";
try {
break;
case ViewType.Report:
View activeView = doc.ActiveView;
prompt += "a report view.";
break;
GetViewType(activeView);
case ViewType.ProjectBrowser:
GetViewFamily(doc, activeView);
prompt += "a project browser view.";
break;
return Result.Succeeded;
case ViewType.SystemBrowser:
prompt += "a system browser view.";
} catch (Exception ex) {
break;
TaskDialog.Show("Revit API sample fail: ", ex.Message);
case ViewType.CostReport:
return Result.Failed;
prompt += "a cost report view.";
}
} break;
case ViewType.LoadsReport:
/// <summary> prompt += "a loads report view.";
break;
/// Determing the view type
case ViewType.PresureLossReport:
/// </summary>
prompt += "a presure loss view.";
/// <param name="view"></param>
break;
public void GetViewType(View view) {
case ViewType.PanelSchedule:
prompt += "a panel schedule view.";
// Get the view type of the given view and format the prompt string
break;
String prompt = "The view is ";
case ViewType.ColumnSchedule:
prompt += "a columns schedule view.";
switch (view.ViewType) {
case ViewType.Undefined: break;
case ViewType.Walkthrough:
prompt += "undefined.";
prompt += "a walkthrough view.";
break;
case ViewType.FloorPlan: break;

Página 241
Página 242

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
case ViewType.Rendering: [Transaction(TransactionMode.Manual)]
prompt += "a rendering view."; class RevitWithWPF : IExternalCommand {
break; public Result Execute(ExternalCommandData commandData, ref string message,
case ViewType.SystemsAnalysisReport: ElementSet elements) {
prompt += "a systems analysis report view.";
break; // Establishing connections
case ViewType.Internal: UIDocument uiDoc = commandData.Application.ActiveUIDocument;
prompt += "an internal view."; Document doc = uiDoc.Document;
break; Selection sel = uiDoc.Selection;
default:
prompt += "undefined."; try {
break;
} using (Transaction transactionCreatingView = new Transaction(doc,
// Give the user some information "Creating Perspective 3D View")) {
MessageBox.Show(prompt, "Revit API", MessageBoxButton.OK); transactionCreatingView.Start();
}
// Find a 3D view type
public void GetViewFamily(Document doc, View view) { IEnumerable<ViewFamilyType> viewFamilyTypes = from elem in new
ViewFamily viewFamily = ViewFamily.Invalid; FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType))
let type = elem as
ElementId viewTypeId = view.GetTypeId(); ViewFamilyType
if (viewTypeId.IntegerValue > 1) { // Some views may not have a where
ViewFamilyType type.ViewFamily == ViewFamily.ThreeDimensional
ViewFamilyType viewFamilyType = doc.GetElement(viewTypeId) as select type;
ViewFamilyType;
viewFamily = viewFamilyType.ViewFamily; // Create a new Perspective View3D
} View3D view3D = View3D.CreatePerspective(doc,
viewFamilyTypes.First().Id);
// Give the user some information if (null != view3D) {
MessageBox.Show(viewFamily.ToString(), "Revit API", MessageBoxButton.OK); // By default, the 3D view uses a default orientation
} // Change the orientation by creating and setting a
ViewOrientation3D
XYZ eye = new XYZ(0, -100, 10);
} XYZ up = new XYZ(0, 0, 1);
} XYZ forward = new XYZ(0, 1, 0);
ViewOrientation3D newViewOrientation3D = new
ViewOrientation3D(eye, up, forward);
view3D.SetOrientation(newViewOrientation3D);

// Turn off the far clip plane with standard parameter API
Parameter farClip =
view3D.get_Parameter(BuiltInParameter.VIEWER_BOUND_ACTIVE_FAR); // BuiltInParameter
Enumeration "Far Clip Active"
farClip.Set(0);
}

transactionCreatingView.Commit();
}

return Result.Succeeded;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes; } catch (Exception ex) {
using Autodesk.Revit.DB; TaskDialog.Show("Revit API sample fail: ", ex.Message);
using Autodesk.Revit.UI; return Result.Failed;
using Autodesk.Revit.UI.Selection; }
using System; }
using System.Collections.Generic;
using System.Linq; }
using System.Text; }
using System.Threading.Tasks;
using System.Windows;

Página 243
Página 244

namespace RevitCommand {

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
transactionCreatingView.Commit();
}
using Autodesk.Revit.ApplicationServices;
return Result.Succeeded;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
} catch (Exception ex) {
using Autodesk.Revit.UI;
TaskDialog.Show("Revit API sample fail: ", ex.Message);
using Autodesk.Revit.UI.Selection;
return Result.Failed;
using System;
}
using System.Collections.Generic;
}
using System.Linq;
using System.Text;
}
using System.Threading.Tasks;
}
using System.Windows;

namespace RevitCommand {
[Transaction(TransactionMode.Manual)]
class RevitWithWPF : IExternalCommand {
public Result Execute(ExternalCommandData commandData, ref string message,
ElementSet elements) {

// Establishing connections
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
Selection sel = uiDoc.Selection;

try {

using (Transaction transactionCreatingView = new Transaction(doc, using Autodesk.Revit.Attributes;


"Creating an Isometric 3D View")) { using Autodesk.Revit.DB;
transactionCreatingView.Start(); using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
// Find a 3D view type using System;
IEnumerable<ViewFamilyType> viewFamilyTypes = from elem in new using System.Collections.Generic;
FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType)) using System.Linq;
let type = elem as
ViewFamilyType namespace RevitCommand {
where [Transaction(TransactionMode.Manual)]
type.ViewFamily == ViewFamily.ThreeDimensional class RevitWithWPF : IExternalCommand {
select type; public Result Execute(ExternalCommandData commandData, ref string message,
ElementSet elements) {
// Create a new Isometric View3D
View3D view3D = View3D.CreateIsometric(doc, // Establishing connections
viewFamilyTypes.First().Id); UIDocument uiDoc = commandData.Application.ActiveUIDocument;
if (null != view3D) { Document doc = uiDoc.Document;
// By default, the 3D view uses a default orientation Selection sel = uiDoc.Selection;
// Change the orientation by creating and setting a
ViewOrientation3D try {
XYZ eye = new XYZ(10, 10, 10);
XYZ up = new XYZ(0, 0, 1); using (Transaction transactionCreatingFloorAndCeilingPlan = new
XYZ forward = new XYZ(0, 1, 0); Transaction(doc, "Creating a Floor and Ceiling Plan")) {
ViewOrientation3D newViewOrientation3D = new transactionCreatingFloorAndCeilingPlan.Start();
ViewOrientation3D(eye, up, forward);
view3D.SetOrientation(newViewOrientation3D); // Find a floor view type
IEnumerable<ViewFamilyType> viewFamilyTypes = from elem in new
// Turn off the far clip plane with standard parameter API FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType))
Parameter farClip = let type = elem as
view3D.get_Parameter(BuiltInParameter.VIEWER_BOUND_ACTIVE_FAR); // BuiltInParameter ViewFamilyType
Enumeration "Far Clip Active" where
farClip.Set(0); type.ViewFamily == ViewFamily.FloorPlan
select type;
}

Página 245
Página 246

// Create a Level and Floor Plan based on it

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
double elevation = 10.0;
Level level1 = Level.Create(doc, elevation);
ViewPlan floorView = ViewPlan.Create(doc,
viewFamilyTypes.First().Id, level1.Id);

ViewRange(doc, floorView);

// Create another Level and a Ceiling Plan based on it


// Find a ceiling plan view type
viewFamilyTypes = from elem in new
FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType))
let type = elem as ViewFamilyType using Autodesk.Revit.Attributes;
where type.ViewFamily == ViewFamily.CeilingPlan using Autodesk.Revit.DB;
select type; using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI;
elevation += 10.0; using Autodesk.Revit.UI.Selection;
Level level2 = Level.Create(doc, elevation); using System;
ViewPlan ceilingView = ViewPlan.Create(doc, using System.Collections.Generic;
viewFamilyTypes.First().Id, level2.Id); using System.Linq;

transactionCreatingFloorAndCeilingPlan.Commit(); namespace RevitCommand {


} [Transaction(TransactionMode.Manual)]
class RevitWithWPF : IExternalCommand {
return Result.Succeeded; public Result Execute(ExternalCommandData commandData, ref string message,
ElementSet elements) {
} catch (Exception ex) {
TaskDialog.Show("Revit API sample fail!", ex.Message); // Establishing connections
return Result.Failed; UIDocument uiDoc = commandData.Application.ActiveUIDocument;
} Document doc = uiDoc.Document;
} Selection sel = uiDoc.Selection;

/// <summary> using (Transaction transactionViewFilters = new Transaction(doc, "View


/// Getting information on the view range Filters")) {
/// </summary> transactionViewFilters.Start();
private void ViewRange(Document doc, View view) { try {
if (view is ViewPlan) {
ViewPlan viewPlan = view as ViewPlan; // Applying a filter to a view
PlanViewRange viewRange = viewPlan.GetViewRange(); CreateViewFilter(doc, doc.ActiveView);

ElementId topClipPlane = transactionViewFilters.Commit();


viewRange.GetLevelId(PlanViewPlane.TopClipPlane);
double dOffset = viewRange.GetOffset(PlanViewPlane.TopClipPlane); return Result.Succeeded;

if (topClipPlane.IntegerValue>0) { } catch (Exception ex) {


Element levelAbove = doc.GetElement(topClipPlane); TaskDialog.Show("Revit API sample fail!", ex.Message);
TaskDialog.Show(view.Name, "Top Clip Plane: " + levelAbove.Name + transactionViewFilters.RollBack();
"\r\nTop Offset: " + dOffset + "ft"); return Result.Failed;
} }
} }
} }

} /// <summary>
} /// Applying a filter to a view
/// </summary>
/// <param name="doc"></param>
/// <param name="view"></param>
public static void CreateViewFilter(Document doc, View view) {
List<ElementId> categories = new List<ElementId>();
categories.Add(new ElementId(BuiltInCategory.OST_Walls));
List<FilterRule> filterRules = new List<FilterRule>();

// Create filter element associated to the input categories

Página 247
Página 248

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
ParameterFilterElement parameterFilterElement = IList<IList<Autodesk.Revit.DB.BoundarySegment>> segments =
ParameterFilterElement.Create(doc, "Example view filter", categories); room.GetBoundarySegments(new SpatialElementBoundaryOptions());

// Criterion 1 - wall type Function is "Exterior" if (null != segments) // The room may not be bound
ElementId exteriorParamId = new {
ElementId(BuiltInParameter.FUNCTION_PARAM); foreach (IList<Autodesk.Revit.DB.BoundarySegment> segmentList in
segments) {
filterRules.Add(ParameterFilterRuleFactory.CreateEqualsRule(exteriorParamId, CurveLoop loop = new CurveLoop();
(int)WallFunction.Exterior)); foreach (Autodesk.Revit.DB.BoundarySegment boundarySegment in
segmentList) {
// Criterion 2 - wall height > some number loop.Append(boundarySegment.GetCurve());
ElementId lengthId = new ElementId(BuiltInParameter.CURVE_ELEM_LENGTH); }

filterRules.Add(ParameterFilterRuleFactory.CreateGreaterOrEqualRule(lengthId, 28.0, ViewCropRegionShapeManager vcrShapeMgr =


0.0001)); view.GetCropRegionShapeManager();
vcrShapeMgr.SetCropShape(loop);
// Criterion 3 - custom shared parameter value matches string pattern break; // If more than one set of boundary segments for room,
// Get the id for the shared parameter - the ElementId is not hardcoded, crop around the first one
so we need to get an instance of this type to find it }
Guid spGuid = new Guid("96b00b61-7f5a-4f36-a828-5cd07890a02a"); }
FilteredElementCollector collector = new FilteredElementCollector(doc); }
collector.OfClass(typeof(Wall)); }
Wall wall = collector.FirstElement() as Wall;

if (wall != null) {
Parameter sharedParam = wall.get_Parameter(spGuid); }
ElementId sharedParamId = sharedParam.Id;
}

filterRules.Add(ParameterFilterRuleFactory.CreateBeginsWithRule(sharedParamId, "15.",
true));
}

// Depreciated ParameterFilterElement.SetRules
// ElementFilter elemFilter =
CreateElementFilterFromFilterRules(filterRules);
List<ElementFilter> elemFilters = new List<ElementFilter>();
foreach (FilterRule filterRule in filterRules) {
ElementParameterFilter elemParamFilter = new
ElementParameterFilter(filterRule);
elemFilters.Add(elemParamFilter);
}

LogicalAndFilter elemFilter = new LogicalAndFilter(elemFilters);

parameterFilterElement.SetElementFilter(elemFilter);

// Apply filter to view


view.AddFilter(parameterFilterElement.Id);
view.SetFilterVisibility(parameterFilterElement.Id, false);
}

/// <summary>
/// Cropping a view
/// </summary>
/// <param name="room"></param>
/// <param name="view"></param>
public void CropAroundRoom(Room room, View view) {
if (view != null) {

Página 249
Página 250

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
/// Showing the Section Box
/// </summary>
private void ShowHideSection(View3D view3D) {
using Autodesk.Revit.ApplicationServices;
foreach (Parameter p in view3D.Parameters) {
using Autodesk.Revit.Attributes;
// Get Section Box parameter
using Autodesk.Revit.DB;
if (p.Definition.Name.Equals("Section Box")) {
using Autodesk.Revit.UI;
// Show Section Box
using Autodesk.Revit.UI.Selection;
p.Set(1);
using System;
// Hide Section Box
using System.Collections.Generic;
// p.Set(0);
using System.Linq;
break;
using System.Text;
}
using System.Threading.Tasks;
}
using System.Windows;
}
namespace RevitCommand {
/// <summary>
[Transaction(TransactionMode.Manual)]
/// Expanding and Hiding the Section Box
class RevitWithWPF : IExternalCommand {
/// </summary>
public Result Execute(ExternalCommandData commandData, ref string message,
/// <param name="view"></param>
ElementSet elements) {
private void ExpandSectionBox(View3D view) {
// The original section box
// Establishing connections
BoundingBoxXYZ sectionBox = view.GetSectionBox();
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
// Expand the section box
Selection sel = uiDoc.Selection;
XYZ deltaXYZ = sectionBox.Max - sectionBox.Min;
sectionBox.Max += deltaXYZ / 2;
try {
sectionBox.Min -= deltaXYZ / 2;
using (Transaction transaction3DViewsSectionBox = new Transaction(doc,
// After reseting the section box, it will be show in the view
"Working with 3D Views Section Box")) {
// It only works when the Section Box check box is checked in
transaction3DViewsSectionBox.Start();
// View property dialog
view.SetSectionBox(sectionBox);
// Find a 3D view type
IEnumerable<ViewFamilyType> viewFamilyTypes = from elem in new
// To deactivate the section box
FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType))
// view.IsSectionBoxActive = false;
let type = elem as
ViewFamilyType
}
where
type.ViewFamily == ViewFamily.ThreeDimensional
private void ConvertMaxMintoWCS(View3D view, out XYZ max, out XYZ min) {
select type;
BoundingBoxXYZ sectionbox = view.GetSectionBox();
Transform transform = sectionbox.Transform;
// Create a new Isometric View3D
max = transform.OfPoint(sectionbox.Max);
View3D view3D = View3D.CreateIsometric(doc,
min = transform.OfPoint(sectionbox.Min);
viewFamilyTypes.First().Id);
}
// Showing the Section Box
}
ShowHideSection(view3D);
}
// Expanding and Hiding the Section Box
ExpandSectionBox(view3D);

transaction3DViewsSectionBox.Commit();
}

return Result.Succeeded;

} catch (Exception ex) {


TaskDialog.Show("Revit API sample fail!", ex.Message);
return Result.Failed;
}
}

/// <summary>

Página 251
Página 252

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
transform.Origin = origin;
transform.BasisX = normal;
transform.BasisY = XYZ.BasisZ;

// Can use this simplification because wall´s "up" is vertical


// For a non-vertical situation (such as section through a sloped
floor the surface normal would be need)
transform.BasisZ = normal.CrossProduct(XYZ.BasisZ);

BoundingBoxXYZ sectionBox = new BoundingBoxXYZ {


using Autodesk.Revit.Attributes; Transform = transform,
using Autodesk.Revit.DB; Min = new XYZ(-10, 0, 0),
using Autodesk.Revit.UI; Max = new XYZ(10, 12, 5)
using Autodesk.Revit.UI.Selection; };
using System; // Min & max x values (-10 & 10) define the sector line length on
using System.Collections.Generic; each side of the wall
using System.Linq; // Max Y (12) is the height to the section box
// Max Z (5) is the far clip offset
namespace RevitCommand {
[Transaction(TransactionMode.Manual)] // Create a new view section
class RevitWithWPF : IExternalCommand { ViewSection viewSection = ViewSection.CreateSection(doc,
public Result Execute(ExternalCommandData commandData, ref string message, viewFamilyTypes.First().Id, sectionBox);
ElementSet elements) {
// Create callout
// Establishing connections CreateCalloutView(doc,doc.ActiveView);
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
Selection sel = uiDoc.Selection; transactionCreatingSectionView.Commit();
}
try {
return Result.Succeeded;
using (Transaction transactionCreatingSectionView = new
Transaction(doc, "Creating Section View")) { } catch (Exception ex) {
transactionCreatingSectionView.Start(); TaskDialog.Show("Revit API sample fail!", ex.Message);
return Result.Failed;
// Find a floor view type }
IEnumerable<ViewFamilyType> viewFamilyTypes = from elem in new }
FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType))
let type = elem as /// <summary>
ViewFamilyType /// Creating a Elevation View
where /// </summary>
type.ViewFamily == ViewFamily.Section private ViewSection CreateElevationView(Document doc, FamilyInstance beam) {
select type;
// Select wall to intereact with // Find an elevation view type
Wall wall = doc.GetElement(sel.PickObject(ObjectType.Element, IEnumerable<ViewFamilyType> viewFamilyTypes = from elem in new
"Select one wall!")) as Wall; FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType))
let type = elem as
// Create a boundingBoxXYZ instance centered on wall ViewFamilyType
LocationCurve lc = wall.Location as LocationCurve; where type.ViewFamily ==
Transform curveTransform = lc.Curve.ComputeDerivatives(0.5, true); ViewFamily.Elevation
// Using 0.5 and "true" (to specify that the parameter is select type;
normalized)
// places the transform´s origin at the center of the location LocationCurve lc = beam.Location as LocationCurve;
curve) XYZ xyz = lc.Curve.GetEndPoint(0);
ElevationMarker marker = ElevationMarker.CreateElevationMarker(doc,
XYZ origin = curveTransform.Origin; // Mid point of the location viewFamilyTypes.First().Id, xyz, 1);
curve ViewSection elevationView = marker.CreateElevation(doc, doc.ActiveView.Id,
XYZ viewDirection = curveTransform.BasisX.Normalize(); // Tangent 1);
vector along the location curve
XYZ normal = viewDirection.CrossProduct(XYZ.BasisZ).Normalize(); return elevationView;
// Location curve normal at mid point }
Transform transform = Transform.Identity;

Página 253
Página 254

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
using Autodesk.Revit.DB;
/// <summary> using Autodesk.Revit.UI;
/// Creating a callout and reference callout using Autodesk.Revit.UI.Selection;
/// </summary> using System;
public void CreateCalloutView(Document document, View parentView) { using System.Collections.Generic;
using System.Linq;
// Find a detail view
IEnumerable<ViewFamilyType> viewFamilyTypes = from elem in new namespace RevitCommand {
FilteredElementCollector(document).OfClass(typeof(ViewFamilyType)) [Transaction(TransactionMode.Manual)]
let type = elem as class RevitWithWPF : IExternalCommand {
ViewFamilyType public Result Execute(ExternalCommandData commandData, ref string message,
where type.ViewFamily == ElementSet elements) {
ViewFamily.Detail
select type; // Establishing connections
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
ElementId viewFamilyTypeId = viewFamilyTypes.First().Id; Document doc = uiDoc.Document;
XYZ point1 = new XYZ(2, 2, 2); Selection sel = uiDoc.Selection;
XYZ point2 = new XYZ(30, 30, 30);
ElementId parentViewId = parentView.Id; // a ViewPlan using (Transaction transactionCreatingSheetView = new Transaction(doc,
View view = ViewSection.CreateCallout(document, parentViewId, "Creating Sheet View")) {
viewFamilyTypeId, point1, point2); transactionCreatingSheetView.Start();
try {
ViewSection.CreateReferenceCallout(document, parentViewId, view.Id,
point1, point2);
}
// Find a 3D view type
IEnumerable<ViewFamilyType> viewFamilyTypes = from elem in new
FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType))
} let type = elem as
ViewFamilyType
} where
type.ViewFamily == ViewFamily.ThreeDimensional
select type;

// Create a new Isometric View3D


View3D view3D = View3D.CreatePerspective(doc,
viewFamilyTypes.First().Id);

CreateSheetView(doc, view3D);

transactionCreatingSheetView.Commit();

return Result.Succeeded;

} catch (Exception ex) {


TaskDialog.Show("Revit API sample fail!", ex.Message);
transactionCreatingSheetView.RollBack();
return Result.Failed;
}
}
}

/// <summary>
/// Creating a Sheet View
/// </summary>
private void CreateSheetView(Document document, View3D view3D) {

// Get an available title block from document


FilteredElementCollector familyList = new
FilteredElementCollector(document);
familyList.OfClass(typeof(FamilySymbol));
using Autodesk.Revit.Attributes;

Página 255
Página 256

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
familyList.OfCategory(BuiltInCategory.OST_TitleBlocks);

FamilySymbol fs = familyList.FirstElement() as FamilySymbol;

// Create a sheet view


ViewSheet viewSheet = ViewSheet.Create(document, fs.Id);
if (null == viewSheet) {
throw new Exception("Failed to create new ViewSheet.");
}
using Autodesk.Revit.Attributes;
// Add passed in view onto the center of the sheet using Autodesk.Revit.DB;
UV location = new UV((viewSheet.Outline.Max.U - viewSheet.Outline.Min.U) / using Autodesk.Revit.UI;
2, using Autodesk.Revit.UI.Selection;
(viewSheet.Outline.Max.V - viewSheet.Outline.Min.V) / using System;
2); using System.Collections.Generic;
using System.Linq;
//viewSheet.AddView(view3D, location);
Viewport.Create(document, viewSheet.Id, view3D.Id, new XYZ(location.U, namespace RevitCommand {
location.V, 0)); [Transaction(TransactionMode.Manual)]
class RevitWithWPF : IExternalCommand {
//// Add passed in view onto the center of the sheet public Result Execute(ExternalCommandData commandData, ref string message,
//if (Viewport.CanAddViewToSheet(document, viewSheet.Id, view3D.Id)) { ElementSet elements) {
// BoundingBoxUV sheetBox = viewSheet.Outline;
// double yPosition = (sheetBox.Max.V - sheetBox.Min.V) / 2 + // Establishing connections
sheetBox.Min.V; UIDocument uiDoc = commandData.Application.ActiveUIDocument;
// double xPosition = (sheetBox.Max.U - sheetBox.Min.U) / 2 + Document doc = uiDoc.Document;
sheetBox.Min.U; Selection sel = uiDoc.Selection;

// XYZ origin = new XYZ(xPosition, yPosition, 0); using (Transaction transactionCreatingSchedule = new Transaction(doc,
// Viewport viewport = Viewport.Create(document, viewSheet.Id, "Creating Schedule")) {
view3D.Id, origin); transactionCreatingSchedule.Start();
//} try {

// Print the sheet out // Creating a area schedule


if (viewSheet.CanBePrinted) { FilteredElementCollector collector1 = new
TaskDialog taskDialog = new TaskDialog("Revit"); FilteredElementCollector(doc);
taskDialog.MainContent = "Print the sheet?"; collector1.OfCategory(BuiltInCategory.OST_AreaSchemes);
TaskDialogCommonButtons buttons = TaskDialogCommonButtons.Yes | // Get first ElementId of AreaScheme
TaskDialogCommonButtons.No; ElementId areaShemeId = collector1.FirstElementId();
taskDialog.CommonButtons = buttons;
TaskDialogResult result = taskDialog.Show(); // If you want to create an area schedule, you must use
CreateSchedule method with three arguments
if (result == TaskDialogResult.Yes) { // The input of second argument must be ElementId of
viewSheet.Print(); BuiltInCategory.OST_Areas category and
} // the input of third argument must be ElementId of areaScheme
} ViewSchedule areaSchedule = ViewSchedule.CreateSchedule(doc, new
ElementId(BuiltInCategory.OST_Areas), areaShemeId);
}
// Creating a note block schedule
ViewSchedule noteBlockSchedule = null;
} //Get first ElementId of a Note Block family.
ICollection<ElementId> noteblockFamilies =
} ViewSchedule.GetValidFamiliesForNoteBlock(doc);
ElementId symbolId = noteblockFamilies.First<ElementId>();
if (!symbolId.Equals(ElementId.InvalidElementId)) {
//Create a note-block view schedule.
noteBlockSchedule = ViewSchedule.CreateNoteBlock(doc,
symbolId);
}

// Add ViewSchedule to List


//FilteredElementCollector collectorSchedules = new

Página 257
Página 258

FilteredElementCollector(doc);

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
//IList<Element> collectionSchedules = /// <param name="schedule"></param>
collectorSchedules.OfClass(typeof(ViewSchedule)).ToElements(); public void FormatLengthFields(ViewSchedule schedule) {
List<ViewSchedule> schedules = new List<ViewSchedule> { int nFields = schedule.Definition.GetFieldCount();
areaSchedule, noteBlockSchedule }; for (int n = 0; n < nFields; n++) {
ScheduleField field = schedule.Definition.GetField(n);
// Add fields to view schedule if (field.UnitType == UnitType.UT_Length) {
AddFieldToSchedule(schedules); FormatOptions formatOpts = new FormatOptions();
formatOpts.UseDefault = false;
transactionCreatingSchedule.Commit(); formatOpts.DisplayUnits =
DisplayUnitType.DUT_FEET_FRACTIONAL_INCHES;
return Result.Succeeded; field.SetFormatOptions(formatOpts);
}
} catch (Exception ex) { }
TaskDialog.Show("Revit API sample fail!", ex.Message); }
transactionCreatingSchedule.RollBack();
return Result.Failed; /// <summary>
} /// Gruping headers
} /// Group columns of related data and remove redundant text from column
} headings
/// </summary>
// Create Schedule to a category /// <param name="colSchedule"></param>
//public ViewSchedule viewSchedule.CreateSchedule(Document document, ElementId /// <param name="startIndex"></param>
categoryId); /// <param name="groupText"></param>
public void GroupRelatedData(ViewSchedule colSchedule, int startIndex, int
endIndex, string groupText) {
/// <summary> colSchedule.GroupHeaders(0, startIndex, 0, endIndex, groupText);
/// Add fields to view schedule
/// </summary> // If column heading has groupText in it, remove it
/// <param name="schedules"> List of view schedule </param> // (i.e. if groupText is "Top" and field heading is "Top Level",
public void AddFieldToSchedule(List<ViewSchedule> schedules) { // change the heading to just "Level"
IList<SchedulableField> schedulableFields = null; for (int index = startIndex; index < endIndex; index++) {
ScheduleField field = colSchedule.Definition.GetField(index);
foreach (ViewSchedule vs in schedules) { field.ColumnHeading = field.ColumnHeading.Replace(groupText, "");
// Get all schedulable fields from view schedule definitions }
schedulableFields = vs.Definition.GetSchedulableFields(); }

foreach (SchedulableField sf in schedulableFields) { /// <summary>


bool fieldAlreadyAdded = false; /// Inserting a row
// Get all schedule field ids /// </summary>
IList<ScheduleFieldId> ids = vs.Definition.GetFieldOrder(); /// <param name="schedule"></param>
foreach (ScheduleFieldId id in ids) { public void CreateSubtitle(ViewSchedule schedule) {
// If the GetSchedulableField() method of gotten schedule TableData colTableData = schedule.GetTableData();
field returns same schedulable field,
// it means the field is already added to the view schedule TableSectionData tsd = colTableData.GetSectionData(SectionType.Header);
if (vs.Definition.GetField(id).GetSchedulableField() == sf) { tsd.InsertRow(tsd.FirstRowNumber + 1);
fieldAlreadyAdded = true; tsd.SetCellText(tsd.FirstRowNumber + 1, tsd.FirstColumnNumber, "Schedule
break; of column top and base levels with offsets");
} }
}
/// <summary>
// If schedulable field does not exist in view schedule, add it /// Formatting cells
if (fieldAlreadyAdded == false) { /// </summary>
vs.Definition.AddField(sf); /// <param name="colSchedule"></param>
} public void FormatSubtitle(ViewSchedule colSchedule) {
} TableData colTableData = colSchedule.GetTableData();
}
} TableSectionData tsd = colTableData.GetSectionData(SectionType.Header);
// Subtitle is second row, first column
/// <summary> if (tsd.AllowOverrideCellStyle(tsd.FirstRowNumber + 1,
/// Formatting a field tsd.FirstColumnNumber)) {
/// Format lenght to display in feet and inches format TableCellStyle tcs = new TableCellStyle();
/// </summary>

Página 259
Página 260

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
TableCellStyleOverrideOptions options = new Document document = uiDoc.Document;
TableCellStyleOverrideOptions(); Selection sel = uiDoc.Selection;
options.FontSize = true;
options.Bold = true; using (Transaction transactionResetSlabShapes = new Transaction(document,
tcs.SetCellStyleOverrideOptions(options); "Reset Slab Shapes")) {
tcs.IsFontBold = true; transactionResetSlabShapes.Start();
tcs.TextSize = 10; try {
tsd.SetCellStyle(tsd.FirstRowNumber + 1, tsd.FirstColumnNumber, tcs);
} // Reverting a slab's shape
} ResetSlabShapes(document);

transactionResetSlabShapes.Commit();
}
return Result.Succeeded;
}
} catch (Exception ex) {
TaskDialog.Show("Revit API sample fail!", ex.Message);
transactionResetSlabShapes.RollBack();
return Result.Failed;
}
}
}

///// <summary>
///// New Slab with Slope
///// </summary>
///// <param name="profile"></param>
///// <param name="level"></param>
///// <param name="slopeArrow"></param>
///// <param name="slope"></param>
///// <param name="isStrutural"></param>
///// <returns></returns>
//public Floor NewSlab(CurveArrArray profile, Level level, Line slopeArrow,
double slope, bool isStrutural);

/// <summary>
/// Reverting a slab's shape
/// </summary>
/// <param name="document"></param>
private void ResetSlabShapes(Document document) {
UIDocument uidoc = new UIDocument(document);
ICollection<ElementId> selectedIds = uidoc.Selection.GetElementIds();
foreach (ElementId id in selectedIds) {
Floor floor = document.GetElement(id) as Floor;
if (floor != null) {
SlabShapeEditor slabShapeEditor = floor.SlabShapeEditor;
using Autodesk.Revit.Attributes; slabShapeEditor.ResetSlabShape();
using Autodesk.Revit.DB; }
using Autodesk.Revit.DB.Architecture; }
using Autodesk.Revit.UI; }
using Autodesk.Revit.UI.Selection;
using System;
using System.Collections.Generic;
using System.Linq; }

namespace RevitCommand { }
[Transaction(TransactionMode.Manual)]
class RevitWithWPF : IExternalCommand {
public Result Execute(ExternalCommandData commandData, ref string message,
ElementSet elements) {

// Establishing connections

Página 261
Página 262

UIDocument uiDoc = commandData.Application.ActiveUIDocument;


eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
ICollection<ElementId> selectedIds =
uiDoc.Selection.GetElementIds();
if (selectedIds.Count != 0) {
foreach (ElementId id in selectedIds) {
Element element = document.GetElement(id);
Wall wall = element as Wall;
if (wall != null) {
LocationCurve wallCurve = wall.Location as
LocationCurve;
footprint.Append(wallCurve.Curve);
continue;
}

ModelCurve modelCurve = element as ModelCurve;


using Autodesk.Revit.Attributes; if (modelCurve != null) {
using Autodesk.Revit.DB; footprint.Append(modelCurve.GeometryCurve);
using Autodesk.Revit.DB.Architecture; }
using Autodesk.Revit.UI; }
using Autodesk.Revit.UI.Selection;
using System; } else {
using System.Collections.Generic; throw new Exception("You should select a curve loop, or a wall
using System.Linq; loop, or loops combination " +
"\nof walls and curves to create a footprint roof.");
namespace RevitCommand { }
[Transaction(TransactionMode.Manual)]
class RevitWithWPF : IExternalCommand { ModelCurveArray footPrintToModelCurveMapping = new
public Result Execute(ExternalCommandData commandData, ref string message, ModelCurveArray();
ElementSet elements) { FootPrintRoof footprintRoof =
document.Create.NewFootPrintRoof(footprint, level, roofType, out
// Establishing connections footPrintToModelCurveMapping);
UIDocument uiDoc = commandData.Application.ActiveUIDocument; ModelCurveArrayIterator iterator =
Document document = uiDoc.Document; footPrintToModelCurveMapping.ForwardIterator();
Selection sel = uiDoc.Selection; iterator.Reset();
while (iterator.MoveNext()) {
using (Transaction transactionFootPrintRoof = new Transaction(document, ModelCurve modelCurve = iterator.Current as ModelCurve;
"Creating a FootPrint Roof")) { footprintRoof.set_DefinesSlope(modelCurve, true);
transactionFootPrintRoof.Start(); footprintRoof.set_SlopeAngle(modelCurve, 0.5);
try { }

// Before invoking this sample, select some walls to add a roof transactionFootPrintRoof.Commit();
over.
// Make sure there is a level named "Roof" in the document. return Result.Succeeded;

// find the Roof level } catch (Exception ex) {


FilteredElementCollector collector = new TaskDialog.Show("Revit API sample fail!", ex.Message);
FilteredElementCollector(document); transactionFootPrintRoof.RollBack();
collector.OfClass(typeof(Level)); return Result.Failed;
Level level = (from element in collector where element.Name == }
"Roof" select element).Cast<Level>().ElementAt(0); }
}
collector = new FilteredElementCollector(document);
collector.OfClass(typeof(RoofType)); /// <summary>
RoofType roofType = collector.FirstElement() as RoofType; /// Modifying a gutter
/// </summary>
// Get the handle of the application /// <param name="document"></param>
Autodesk.Revit.ApplicationServices.Application application = public void ModifyGutter(Document document) {
document.Application; // If the UiDocument and Selection are not available yet
UIDocument uidoc = new UIDocument(document);
// Define the footprint for the roof based on user selection
CurveArray footprint = application.Create.NewCurveArray(); // Not available anymore
// We already have the uiDoc but you need to do it if not done //ElementSet collection = uidoc.Selection.Elemements;
before

Página 263
Página 264

//UIDocument uidoc = new UIDocument(document);


eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
ICollection<ElementId> collection = uidoc.Selection.GetElementIds(); Wall wall =
if (collection.Count != 0) { document.GetElement(selection.PickObject(ObjectType.Element, "Select a Wall")) as
foreach (ElementId id in collection) { Wall;
Element element = document.GetElement(id);
if (element is Gutter) { GetWallLayerMaterial(document, wall);
Gutter gutter = element as Gutter;
// Convert degrees to rads: transactionLayerMaterial.Commit();
gutter.Angle = 45.00 * Math.PI / 180;
TaskDialog.Show("Revit", "Changed gutter angle"); return Result.Succeeded;
}
} } catch (Exception ex) {
TaskDialog.Show("Revit API sample fail!", ex.Message);
} transactionLayerMaterial.RollBack();
} return Result.Failed;
}
} }
}
}
/// <summary>
/// Getting the CompoundStrutureLayer Material
/// </summary>
/// <param name="document"></param>
/// <param name="wall"></param>
public void GetWallLayerMaterial(Document document, Wall wall) {

// Get WallType of wall


WallType aWallType = wall.WallType;

// Only Basic Wall has compoundStructure


if (WallKind.Basic == aWallType.Kind) {

// Get CompoundStruture
CompoundStructure comStruct = aWallType.GetCompoundStructure();
Categories allCategories = document.Settings.Categories;
using Autodesk.Revit.Attributes;
// Get the category OST_Walls default material;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture; // Use if that layer`s default Material is <By Category>
Category wallCategory =
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection; allCategories.get_Item(BuiltInCategory.OST_Walls);
using System; Material wallMaterial = wallCategory.Material;
using System.Collections.Generic;
using System.Linq; foreach (CompoundStructureLayer structLayer in comStruct.GetLayers())
{
Material layerMaterial =
namespace RevitCommand {
document.GetElement(structLayer.MaterialId) as Material;
[Transaction(TransactionMode.Manual)]
class RevitAPIWithCSharp : IExternalCommand {
public Result Execute(ExternalCommandData commandData, ref string message, // If CompoundStructureLayer`s Material is specified, use default
ElementSet elements) { // Material of its Category
if (null == layerMaterial) {
switch (structLayer.Function) {
// Establishing connections
UIDocument uiDocument = commandData.Application.ActiveUIDocument; case MaterialFunctionAssignment.None:
Document document = uiDocument.Document; layerMaterial =
Selection selection = uiDocument.Selection; allCategories.get_Item(BuiltInCategory.OST_WallsDefault).Material;
break;
using (Transaction transactionLayerMaterial = new Transaction(document, case MaterialFunctionAssignment.Structure:
"Getting the CompoundStrutureLayer Material")) { layerMaterial =
allCategories.get_Item(BuiltInCategory.OST_WallsStructure).Material;
transactionLayerMaterial.Start();
try { break;
case MaterialFunctionAssignment.Substrate:
// Slect a Wall layerMaterial =
allCategories.get_Item(BuiltInCategory.OST_WallsSubstrate).Material;
break;

Página 265
Página 266

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
case MaterialFunctionAssignment.Insulation: namespace RevitCommand {
layerMaterial = [Transaction(TransactionMode.Manual)]
allCategories.get_Item(BuiltInCategory.OST_WallsInsulation).Material; class RevitAPIWithCSharp : IExternalCommand {
break; public Result Execute(ExternalCommandData commandData, ref string message,
case MaterialFunctionAssignment.Finish1: ElementSet elements) {
layerMaterial =
allCategories.get_Item(BuiltInCategory.OST_WallsFinish1).Material; // Establishing connections
break; UIDocument uiDocument = commandData.Application.ActiveUIDocument;
case MaterialFunctionAssignment.Finish2: Document document = uiDocument.Document;
layerMaterial = Selection selection = uiDocument.Selection;
allCategories.get_Item(BuiltInCategory.OST_WallsFinish2).Material;
break; using (Transaction transactionOpening = new Transaction(document,
case MaterialFunctionAssignment.Membrane: "Retriving existing opening properties")) {
layerMaterial = transactionOpening.Start();
allCategories.get_Item(BuiltInCategory.OST_WallsMembrane).Material; try {
break;
case MaterialFunctionAssignment.StructuralDeck: // Slect a Opening
layerMaterial = Opening opening =
allCategories.get_Item(BuiltInCategory.OST_WallsSurfacePattern).Material; document.GetElement(selection.PickObject(ObjectType.Element, "Select a Opening")) as
break; Opening;
default:
// It is impossible to reach here GetInfo_Opening(opening);
break;
} transactionOpening.Commit();
if (null == layerMaterial) {
// CompoundsStructureLayer`s default Material is its return Result.Succeeded;
SubCategory
layerMaterial = wallMaterial; } catch (Exception ex) {
} TaskDialog.Show("Revit API sample fail!", ex.Message);
} transactionOpening.RollBack();
TaskDialog.Show("Revit", "Layer Material" + layerMaterial.Name); return Result.Failed;
} }
} }
}
}
/// <summary>
} /// Retriving existing opening properties
/// </summary>
} /// <param name="opening"></param>
private void GetInfo_Opening(Opening opening) {

string message = "Opening: ";

// Get the host element of this opening


message += "\nThe id of the opening's host is: " +
opening.Host.Id.IntegerValue;

// Get the informtation whether the opening has a rect boundary


// If the opening has a rect boundary, we can get the geometry information
from BoundaryRect property.
// Otherwise we should get the geometry information from BoundaryCurves
property
if (opening.IsRectBoundary) {
message += "\nThe opening has a rectangular boundary.";
using Autodesk.Revit.Attributes; // Array contains two XYZ objects: the max and min coords of boundary
using Autodesk.Revit.DB; IList<XYZ> boundaryRect = opening.BoundaryRect;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI; // Get the coordinate value of the Min coordinate point
using Autodesk.Revit.UI.Selection; XYZ point = opening.BoundaryRect[0];
using System; message += "\nMin coordinate point: (" + point.X + ", " + point.Y + ",
using System.Collections.Generic; " + point.Z + ")";
using System.Linq;

Página 267
Página 268

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
// Get the coordinate value pf the Max coordinate point Document document = uiDocument.Document;
point = opening.BoundaryRect[1]; Selection selection = uiDocument.Selection;
message += "\nMin coordinate point: (" + point.X + ", " + point.Y + ",
" + point.Z + ")"; using (Transaction transactionGetSubAndSuperComponents = new
} else { Transaction(document, "Getting SubComponents and SuperComponents from a
message += "\nThe opening doesn't have a rectangular boundary."; FamilyInstance")) {
// Get curve number transactionGetSubAndSuperComponents.Start();
int curves = opening.BoundaryCurves.Size; try {
message += "\nNumber of curves is: " + curves;
for (int i = 0; i < curves; i++) { // Select a FamilyInstance
Curve curve = opening.BoundaryCurves.get_Item(i); FamilyInstance familyInstance =
//Get curve start point document.GetElement(selection.PickObject(ObjectType.Element, "Select a
message += "\nCurve start point: " + FamilyInstance")) as FamilyInstance;
XYZToString(curve.GetEndPoint(0));
//Get curve end point GetSubAndSuperComponents(familyInstance);
message += "\n; Curve end point: " +
XYZToString(curve.GetEndPoint(1)); GetInfo_FamilyInstance(familyInstance);
}
} transactionGetSubAndSuperComponents.Commit();

TaskDialog.Show("Revit API", message); return Result.Succeeded;


}
} catch (Exception ex) {
// Output the point's three coordinates TaskDialog.Show("Revit API sample fail!", ex.Message);
string XYZToString(XYZ point) { transactionGetSubAndSuperComponents.RollBack();
return "(" + point.X + ", " + point.Y + ", " + point.Z + ")"; return Result.Failed;
} }
}
}
}
/// <summary>
} /// Getting SubComponents and SuperComponents from a FamilyInstance
/// </summary>
/// <param name="familyInstance"></param>
public void GetSubAndSuperComponents(FamilyInstance familyInstance) {
ICollection<ElementId> subElemSet = familyInstance.GetSubComponentIds();
if (subElemSet != null) {
string subElems = "";
foreach (ElementId ee in subElemSet) {
FamilyInstance f = familyInstance.Document.GetElement(ee) as
FamilyInstance;
subElems = subElems + f.Name + "\n";
}
TaskDialog.Show("Revit API", "Subcomponent count = " +
subElemSet.Count + "\n" + subElems);
using Autodesk.Revit.Attributes; }
using Autodesk.Revit.DB; FamilyInstance super = familyInstance.SuperComponent as FamilyInstance;
using Autodesk.Revit.DB.Architecture; if (super != null) {
using Autodesk.Revit.UI; TaskDialog.Show("Revit API", "Super component: " + super.Name);
using Autodesk.Revit.UI.Selection; }
using System; TaskDialog.Show("Revit API", "Host: " + familyInstance.Host);
using System.Collections.Generic; }
using System.Linq;
/// <summary>
namespace RevitCommand { /// Get FamilyInstance Info
[Transaction(TransactionMode.Manual)] /// </summary>
class RevitAPIWithCSharp : IExternalCommand { /// <param name="familyInstance"></param>
public Result Execute(ExternalCommandData commandData, ref string message, public void GetInfo_FamilyInstance(FamilyInstance familyInstance) {
ElementSet elements) { string message = "FamilyInstance : ";
// Get FamilyInstance AnalyticalModel type
// Establishing connections if (null != familyInstance.GetAnalyticalModel()) {
UIDocument uiDocument = commandData.Application.ActiveUIDocument;

Página 269
Página 270

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
message += "\nFamilyInstance AnalyticalModel is : " +
familyInstance.GetAnalyticalModel();
}
using Autodesk.Revit.Attributes;
using Autodesk.Revit.Creation;
// Get FamilyInstance host name
using Autodesk.Revit.DB;
if (familyInstance.Host != null) {
using Autodesk.Revit.DB.Architecture;
message += "\nFamilyInstance host name is : " +
using Autodesk.Revit.UI;
familyInstance.Host.Name;
using Autodesk.Revit.UI.Selection;
}
using System;
using System.Collections.Generic;
foreach (ElementId materialId in familyInstance.GetMaterialIds(false)) {
using System.Linq;
Material material = familyInstance.Document.GetElement(materialId) as
Material;
namespace RevitCommand {
message += "\nFamilyInstance e material : " + material.Name;
[Transaction(TransactionMode.Manual)]
}
class RevitAPIWithCSharp : IExternalCommand {
// Get FamilyInstance room name
public Result Execute(ExternalCommandData commandData, ref string message,
if (familyInstance.Room != null) {
ElementSet elements) {
message += "\nFamilyInstance room name is : " +
familyInstance.Room.Name;
// Establishing connections
}
UIDocument uiDocument = commandData.Application.ActiveUIDocument;
Autodesk.Revit.DB.Document document = uiDocument.Document;
// Get FamilyInstance structural type
Selection selection = uiDocument.Selection;
message += "\nFamilyInstance structural type is : " +
familyInstance.StructuralType;
using (Transaction transactionBatchCreateColumns = new
Transaction(document, "Batch creation family instances")) {
// Get FamilyInstance structural usage
transactionBatchCreateColumns.Start();
message += "\nFamilyInstance structural usage is : " +
try {
familyInstance.StructuralUsage;
// Find a level
TaskDialog.Show("Revit", message);
Level level =
}
document.GetElement(selection.PickObject(ObjectType.Element, "Select a level.")) as
Level;
}
BatchCreateColumns(document, level);
}
transactionBatchCreateColumns.Commit();

return Result.Succeeded;

} catch (Exception ex) {


TaskDialog.Show("Revit API sample fail!", ex.Message);
transactionBatchCreateColumns.RollBack();
return Result.Failed;
}
}
}

/// <summary>
/// Batch creation family instances
/// </summary>
/// <param name="document"></param>
/// <param name="level"></param>
/// <returns></returns>
public ICollection<ElementId> BatchCreateColumns(Autodesk.Revit.DB.Document
document, Level level) {

List<FamilyInstanceCreationData> fiCreationDatas = new


List<FamilyInstanceCreationData>();

ICollection<ElementId> elementSet = null;

// Try to get a FamilySymbol

Página 271
Página 272

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
FamilySymbol familySymbol = null; using System.Windows;
FilteredElementCollector collector = new
FilteredElementCollector(document); namespace RevitCommand {
ICollection<Element> collection = [Transaction(TransactionMode.Manual)]
collector.OfClass(typeof(FamilySymbol)).ToElements(); class RevitAPIWithCSharp : IExternalCommand {
foreach (Element e in collection) { public Result Execute(ExternalCommandData commandData, ref string message,
familySymbol = e as FamilySymbol; ElementSet elements) {
if (null != familySymbol.Category) {
if ("Structural columns" == familySymbol.Category.Name) { // Establishing connections
break; UIDocument uiDocument = commandData.Application.ActiveUIDocument;
} Document document = uiDocument.Document;
} Selection selection = uiDocument.Selection;
}
if (null != familySymbol) { using (Transaction transactionFamilySymbolInformation = new
// Create 5 FamilyInstanceCreationData items for batch creation Transaction(document, "Family symbol information")) {
for (int i = 0; i < 5; i++) { transactionFamilySymbolInformation.Start();
XYZ location = new XYZ(i * 10, 15, 0); try {
FamilyInstanceCreationData fiCreationData = new
FamilyInstanceCreationData(location, familySymbol, level, String fileName = @"C:\ProgramData\Autodesk\RVT
Autodesk.Revit.DB.Structure.StructuralType.Column); 2020\Libraries\Brazil\Mobiliário\Mesas\Mesa-Jantar redonda com cadeiras.rfa";
if (null != fiCreationData) {
fiCreationDatas.Add(fiCreationData); // Try to load family
} Family family = null;
} if (!document.LoadFamily(fileName, out family)) {
if (fiCreationDatas.Count > 0) { throw new Exception("Unable to load " + fileName);
// Create columns }
elementSet = document.Create.NewFamilyInstances2(fiCreationDatas);
} else {
throw new Exception("Batch creation failed."); StringBuilder textMessage = new StringBuilder("Selected element's
} family name is : " + family.Name);
} else {
throw new Exception("No column types found."); ISet<ElementId> familySymbolIds = family.GetFamilySymbolIds();
}
return elementSet; if (familySymbolIds.Count == 0) {
} textMessage.AppendLine("Contains no family symbols.");
} else {
} textMessage.AppendLine("The family symbols contained in this
family are : ");
}
// Get family symbols which is contained in this family
foreach (ElementId id in familySymbolIds) {
FamilySymbol familySymbol = family.Document.GetElement(id)
as FamilySymbol;
// Get family symbol name
textMessage.AppendLine("\nName: " + familySymbol.Name);
foreach (ElementId materialId in
familySymbol.GetMaterialIds(false)) {
Material material =
familySymbol.Document.GetElement(materialId) as Material;
textMessage.AppendLine("\nMaterial : " +
material.Name);
}
}
}
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB; TaskDialog.Show("Revit", textMessage.ToString());
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI; transactionFamilySymbolInformation.Commit();
using Autodesk.Revit.UI.Selection;
using System; return Result.Succeeded;
using System.Collections.Generic;
using System.Linq; } catch (Exception ex) {

Página 273
Página 274

using System.Text;

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
TaskDialog.Show("Revit API sample fail!", ex.Message); throw new Exception("Unable to load " + fileName);
transactionFamilySymbolInformation.RollBack(); }
return Result.Failed;
}
} StringBuilder textMessage = new StringBuilder("Selected element's
} family name is : " + family.Name);

ISet<ElementId> familySymbolIds = family.GetFamilySymbolIds();

} if (familySymbolIds.Count == 0) {
textMessage.AppendLine("Contains no family symbols.");
} } else {
textMessage.AppendLine("The family symbols contained in this
family are : ");

double x = -10.0, y = 0.0;

// Get family symbols which is contained in this family


foreach (ElementId id in familySymbolIds) {

FamilySymbol familySymbol = family.Document.GetElement(id)


as FamilySymbol;

// Get family symbol name


textMessage.AppendLine("\nName: " + familySymbol.Name);

XYZ location = new XYZ(x, y, 10.0);

using Autodesk.Revit.Attributes; // It is necessary to activate the symbol


using Autodesk.Revit.DB; if (!familySymbol.IsActive) {
using Autodesk.Revit.DB.Architecture; familySymbol.Activate();
using Autodesk.Revit.DB.Structure; }
using Autodesk.Revit.UI;
// Do not use the overloaded NewFamilyInstance() method
using Autodesk.Revit.UI.Selection;
using System; that contains
// the Level argument, otherwise Revit cannot show the
using System.Collections.Generic;
using System.Linq; instances
// correctly in 3D View, for the table is not level-based
using System.Text;
using System.Windows; component.
FamilyInstance instance =
document.Create.NewFamilyInstance(location, familySymbol,
namespace RevitCommand {
[Transaction(TransactionMode.Manual)] StructuralType.NonStructural);
class RevitAPIWithCSharp : IExternalCommand {
x += 10.0;
public Result Execute(ExternalCommandData commandData, ref string message,
}
ElementSet elements) {
}
// Establishing connections
UIDocument uiDocument = commandData.Application.ActiveUIDocument; TaskDialog.Show("Revit", textMessage.ToString());
Document document = uiDocument.Document;
transactionFamilySymbolInstance.Commit();
Selection selection = uiDocument.Selection;

using (Transaction transactionFamilySymbolInstance = new return Result.Succeeded;


Transaction(document, "Family symbol instance")) {
transactionFamilySymbolInstance.Start(); } catch (Exception ex) {
try { TaskDialog.Show("Revit API sample fail!", ex.Message);
transactionFamilySymbolInstance.RollBack();
return Result.Failed;
String fileName = @"C:\ProgramData\Autodesk\RVT
2020\Libraries\Brazil\Mobiliário\Mesas\Mesa-Jantar redonda com cadeiras.rfa"; }
}
// Try to load family }
Family family = null;
if (!document.LoadFamily(fileName, out family)) {

Página 275
Página 276

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
} // It is necessary to activate the symbol
if (!gotSymbol.IsActive) {
} gotSymbol.Activate();
}

// Look for a model line in the list of selected elements


ICollection<ElementId> selectedIds =
selection.GetElementIds();
ElementSet sel = new ElementSet();
foreach (ElementId id in selectedIds) {
Element element = document.GetElement(id);
sel.Insert(element);
}
ModelLine modelLine = null;
foreach (Element elem in sel) {
if (elem is ModelLine) {
modelLine = elem as ModelLine;
break;
}
using Autodesk.Revit.Attributes; }
using Autodesk.Revit.DB; if (null != modelLine) {
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.DB.Structure; // Create a new beam
instance =
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection; document.Create.NewFamilyInstance(modelLine.GeometryCurve, gotSymbol, level,
using System; StructuralType.Beam);
using System.Collections.Generic; } else {
using System.Linq; throw new Exception("Please select a model line before
using System.Text; invoking this command");
using System.Windows; }
} else {
namespace RevitCommand { throw new Exception("Couldn't load " + fileName);
}
[Transaction(TransactionMode.Manual)]
class RevitAPIWithCSharp : IExternalCommand {
transactionCreatingBeam.Commit();
public Result Execute(ExternalCommandData commandData, ref string message,
ElementSet elements) {
return Result.Succeeded;
// Establishing connections
UIDocument uiDocument = commandData.Application.ActiveUIDocument; } catch (Exception ex) {
TaskDialog.Show("Revit API sample fail!", ex.Message);
Document document = uiDocument.Document;
Selection selection = uiDocument.Selection; transactionCreatingBeam.RollBack();
return Result.Failed;
}
using (Transaction transactionCreatingBeam = new Transaction(document,
}
"Creating a beam")) {
}
transactionCreatingBeam.Start();
try {

// Get the active view's level for beam creation


}
Level level = document.ActiveView.GenLevel;

// Load a family symbol from file }


FamilySymbol gotSymbol = null;

String fileName = @"C:\ProgramData\Autodesk\RVT


2020\Libraries\Brazil\Framing estrutural\Aço\W-Flange extensa.rfa";

String name = "W1000X554";

FamilyInstance instance = null;

if (document.LoadFamilySymbol(fileName, name, out gotSymbol)) {

Página 277
Página 278

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
String fileName = @"C:\ProgramData\Autodesk\RVT
2020\Libraries\Brazil\Portas\Porta-Painel-Único.rfa";

Family family = null;


if (!document.LoadFamily(fileName, out family)) {
throw new Exception("Unload to load " + fileName);
}

// Get the active views's level for door creation


Level level = document.ActiveView.GenLevel;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB; double x = 0, y = 0, z = 0;
using Autodesk.Revit.DB.Architecture; ISet<ElementId> familySymbolIds = family.GetFamilySymbolIds();
using Autodesk.Revit.DB.Structure; foreach (ElementId id in familySymbolIds) {
using Autodesk.Revit.UI; FamilySymbol symbol = family.Document.GetElement(id) as FamilySymbol;
using Autodesk.Revit.UI.Selection;
using System; // It is necessary to activate the symbol
using System.Collections.Generic; if (!symbol.IsActive) {
using System.Linq; symbol.Activate();
using System.Text; }
using System.Windows;
XYZ location = new XYZ(x, y, z);
namespace RevitCommand { FamilyInstance instance = document.Create.NewFamilyInstance(location,
[Transaction(TransactionMode.Manual)] symbol, wall, level, StructuralType.NonStructural);
class RevitAPIWithCSharp : IExternalCommand { x += 10; y += 10; z += 1.5;
public Result Execute(ExternalCommandData commandData, ref string message,
ElementSet elements) { }
}
// Establishing connections
UIDocument uiDocument = commandData.Application.ActiveUIDocument;
Document document = uiDocument.Document;
Selection selection = uiDocument.Selection; }
using (Transaction transactionCreatingDoors = new Transaction(document, }
"Create doors in a wall")) {
transactionCreatingDoors.Start();
try {

Wall wall =
document.GetElement(selection.PickObject(ObjectType.Element, "Select a Wall")) as
Wall;

CreateDoorsInWall(document, wall);

transactionCreatingDoors.Commit();

return Result.Succeeded;

} catch (Exception ex) {


TaskDialog.Show("Revit API sample fail!", ex.Message); using Autodesk.Revit.Attributes;
transactionCreatingDoors.RollBack(); using Autodesk.Revit.DB;
return Result.Failed; using Autodesk.Revit.DB.Architecture;
} using Autodesk.Revit.DB.Structure;
} using Autodesk.Revit.UI;
} using Autodesk.Revit.UI.Selection;
using System;
/// <summary> using System.Collections.Generic;
/// Create doors in a wall using System.Linq;
/// </summary> using System.Text;
/// <param name="document"></param> using System.Windows;
/// <param name="wall"></param>
public void CreateDoorsInWall(Document document, Wall wall) { namespace RevitCommand {

Página 279
Página 280

[Transaction(TransactionMode.Manual)]

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
class RevitAPIWithCSharp : IExternalCommand { x += 10;
public Result Execute(ExternalCommandData commandData, ref string message, i++;
ElementSet elements) { }
} else {
// Establishing connections throw new Exception("Please open a model with at least one
UIDocument uiDocument = commandData.Application.ActiveUIDocument; floor element before invoking this command.");
Document document = uiDocument.Document; }
Selection selection = uiDocument.Selection;
transactionCreatingFamilyByDirection.Commit();
using (Transaction transactionCreatingFamilyByDirection = new
Transaction(document, "Creating family by direction")) { return Result.Succeeded;
transactionCreatingFamilyByDirection.Start();
try { } catch (Exception ex) {
TaskDialog.Show("Revit API sample fail!", ex.Message);
String fileName = @"C:\ProgramData\Autodesk\RVT transactionCreatingFamilyByDirection.RollBack();
2020\Libraries\Brazil\Mobiliário\Camas\Cama-Padrão.rfa"; return Result.Failed;
}
Family family = null; }
}
if (!document.LoadFamily(fileName, out family)) {
throw new Exception("Couldn't load " + family);
} }

FilteredElementCollector collector = new }


FilteredElementCollector(document);
Floor floor = collector.OfClass(typeof(Floor)).FirstElement() as
Floor;
if (floor != null) {

int x = -30, y = 0;
int i = 0;

ISet<ElementId> familySymbolIds = family.GetFamilySymbolIds();


foreach (ElementId id in familySymbolIds) {
FamilySymbol symbol = family.Document.GetElement(id) as
FamilySymbol;

// It is necessary to activate the symbol


if (!symbol.IsActive) {
symbol.Activate(); using Autodesk.Revit.Attributes;
} using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
XYZ location = new XYZ(x, y, 0); using Autodesk.Revit.DB.Structure;
XYZ direction = new XYZ(); using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
switch (i % 3) { using System;
case 0: using System.Collections.Generic;
direction = new XYZ(1, 1, 0); using System.Linq;
break; using System.Text;
case 1: using System.Windows;
direction = new XYZ(0, 1, 1);
break; namespace RevitCommand {
case 2: [Transaction(TransactionMode.Manual)]
direction = new XYZ(1, 0, 1); class RevitAPIWithCSharp : IExternalCommand {
break; public Result Execute(ExternalCommandData commandData, ref string message,
default: ElementSet elements) {
break;
} // Establishing connections
UIDocument uiDocument = commandData.Application.ActiveUIDocument;
FamilyInstance instance = Document document = uiDocument.Document;
document.Create.NewFamilyInstance(location, symbol, direction, floor, Selection selection = uiDocument.Selection;
StructuralType.NonStructural);

Página 281
Página 282

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
using (Transaction transactionFamilyDocument = new Transaction(document, /// <param name="document"></param>
"Working with family document")) { /// <param name="familyInstance"></param>
transactionFamilyDocument.Start(); public void GetLoadedSymbols(Document document, FamilyInstance familyInstance)
try { {
// Get family associated with this
// Create a new family document using template Family family = familyInstance.Symbol.Family;
string templateFileName = @"C:\ProgramData\Autodesk\RVT
2020\Family Templates\English\Metric Generic Model.rft"; // Get Family document for family
Document familyDoc = document.EditFamily(family);
Document familyDocument = if (null != familyDoc && familyDoc.IsFamilyDocument == true) {
commandData.Application.Application.NewFamilyDocument(templateFileName); string loadedFamilies = "FamilySymbols in " + family.Name + ":\n";
if (null == familyDocument) { FilteredElementCollector collector = new
throw new Exception("Cannot open family document"); FilteredElementCollector(document);
} ICollection<Element> collection =
collector.OfClass(typeof(FamilySymbol)).ToElements();
foreach (Element e in collection) {
string categoryName = FamilySymbol fs = e as FamilySymbol;
familyDocument.OwnerFamily.FamilyCategory.Name; loadedFamilies += "\t" + fs.Name + "\n";
}
StringBuilder textMessage = new StringBuilder("Family category TaskDialog.Show("Revit API", loadedFamilies);
name: " + categoryName); }
}
// Get the owner family of the family document
Family family = familyDocument.OwnerFamily;
Parameter parameter = }
family.get_Parameter(BuiltInParameter.FAMILY_WORK_PLANE_BASED);
}
// This parameter is a Yes/No parameter in UI, but an integer
value in API
// 1 for true and 0 for false
int isTrue = parameter.AsInteger();
// parameter.Set(1); // Set value to true

textMessage.AppendLine("\n\nFamily parameter: " +


parameter.Id.ToString());

TaskDialog.Show("Revit API", textMessage.ToString());

transactionFamilyDocument.Commit();

// Getting nested Family symbols in a Family

// Select a FamilyInstance
FamilyInstance familyInstance =
document.GetElement(selection.PickObject(ObjectType.Element, "Select a
FamilyInstance")) as FamilyInstance;

GetLoadedSymbols(document, familyInstance);

return Result.Succeeded;

} catch (Exception ex) {


TaskDialog.Show("Revit API sample fail!", ex.Message);
transactionFamilyDocument.RollBack();
return Result.Failed;
}
}
}

/// <summary>
/// Getting nested Family symbols in a Family
/// </summary>

Página 283
Página 284

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade
Página 285
Página 286

eTLipse - Computação, Engenharia e Responsabilidade Social Ltda. eTLipse - Computação, Engenharia e Responsabilidade Social Ltda.
www.etlipse.com | info@etlipse.com www.etlipse.com | info@etlipse.com
Desenvolvido por Joel Diniz e Edson Andrade Desenvolvido por Joel Diniz e Edson Andrade

Você também pode gostar