Add
Overloads
| Name | Description |
|---|---|
| Add(int index, string key, string val, bool recursive) | 지정된 개체에 속성을 추가 |
| Add(int index, Dictionary<string, string> property, bool recursive) | 지정된 개체에 복수개의 속성을 추가 |
| Add(List<int> index, Dictionary<string, string> property, bool recursive) | 복수개의 개체에 속성을 추가 |
| Add(string intput_VIZ, string output_VIZ, UserDefineAttributeCollection uda) | 지정된 파일에 속성을 추가 |
| Add(string key, string val, bool recursive) | 선택된 개체에 속성을 추가 |
Add(int index, string key, string val, bool recursive)
public void Add(int index, string key, string val, bool recursive)
지정된 개체에 속성을 추가
Parameters
| Name | Type | Description |
|---|---|---|
| index | int | 노드 인덱스 |
| key | string | 속성 키 |
| val | string | 속성 정보 |
| recursive | bool | 하위노드에 속성 추가 : True (하위 노드에 모두 추가) / False (지정된 개체에만 속성 추가) |
Add(int index, Dictionary<string, string> property, bool recursive)
public void Add(int index, Dictionary<string, string> property, bool recursive)
지정된 개체에 복수개의 속성을 추가
Parameters
| Name | Type | Description |
|---|---|---|
| index | int | 노드 인덱스 |
| property | Dictionary<string, string> | 속성 |
| recursive | bool | 하위노드에 속성 추가 : True (하위 노드에 모두 추가) / False (지정된 개체에만 속성 추가) |
Examples
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example()
{
int nodeIndex = 5;
Dictionary<string, string> property = new Dictionary<string, string>();
property.Add("TYPE", "PIPE");
property.Add("SYSTEM", "GENERAL SERVICE LINE");
property.Add("SERVICE", "GENERAL SERVICE LINE");
property.Add("PRESS", "3.00");
property.Add("TEMP", "32.00");
vizcore3d.Object3D.UDA.Add(
nodeIndex /* NODE INDEX */
, property /* UDA */
, false /* RECURSIVE */
);
}
Add(List<int> index, Dictionary<string, string> property, bool recursive)
public void Add(List<int> index, Dictionary<string, string> property, bool recursive)
복수개의 개체에 속성을 추가
Parameters
| Name | Type | Description |
|---|---|---|
| index | List<int> | 노드 인덱스 |
| property | Dictionary<string, string> | 속성 |
| recursive | bool | 하위노드에 속성 추가 : True (하위 노드에 모두 추가) / False (지정된 개체에만 속성 추가) |
Examples
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void Example()
{
List<int> node = new List<int>() { 4, 10, 20, 30 };
Dictionary<string, string> property = new Dictionary<string, string>();
property.Add("TYPE", "PIPE");
property.Add("SYSTEM", "GENERAL SERVICE LINE");
property.Add("SERVICE", "GENERAL SERVICE LINE");
property.Add("PRESS", "3.00");
property.Add("TEMP", "32.00");
vizcore3d.Object3D.UDA.Add(
node /* NODE INDEX */
, property /* UDA */
, false /* RECURSIVE */
);
}
Add(string intput_VIZ, string output_VIZ, UserDefineAttributeCollection uda)
public bool Add(string intput_VIZ, string output_VIZ, UserDefineAttributeCollection uda)
지정된 파일에 속성을 추가
Parameters
| Name | Type | Description |
|---|---|---|
| intput_VIZ | string | 원본 VIZ 파일 (경로 + 파일이름) |
| output_VIZ | string | 출력 VIZ 파일 (경로 + 파일이름) |
| uda | UserDefineAttributeCollection | 속성 |
Returns
| Type | Description |
|---|---|
| bool | 결과 |
Examples
// VIZCore3D.NET Control
private VIZCore3D.NET.VIZCore3DControl vizcore3d;
private void ExampleV1()
{
if (vizcore3d.Model.IsOpen() == false) return;
StringBuilder sb = new StringBuilder();
string path = vizcore3d.Model.Files[0];
sb.AppendLine(string.Format("File : {0}", path));
List<VIZCore3D.NET.Data.Node> nodes =
vizcore3d.Object3D.FromFilter(Data.Object3dFilter.ALL);
sb.AppendLine(string.Format("Count : {0}", nodes.Count));
VIZCore3D.NET.Data.UserDefineAttributeCollection udac =
new Data.UserDefineAttributeCollection();
foreach (VIZCore3D.NET.Data.Node node in nodes)
{
if (node.Index == 0) continue;
VIZCore3D.NET.Data.UserDefineAttributeItem uda =
new VIZCore3D.NET.Data.UserDefineAttributeItem();
uda.NodeId.Add(node.ID);
for (int i = 0; i < 10; i++)
{
string key = String.Empty;
string val = String.Empty;
switch (i)
{
case 0:
{
key = "NAME";
val = node.NodeName;
}
break;
case 1:
{
key = "ID";
val = node.ID.ToString();
}
break;
case 2:
{
key = "INDEX";
val = node.Index.ToString();
}
break;
case 3:
{
key = "PARENT";
val = node.ParentIndex.ToString();
}
break;
case 4:
{
key = "TYPE";
val = node.Kind.ToString();
}
break;
case 5:
{
key = "CHILD";
val = node.ChildCount.ToString();
}
break;
case 6:
{
key = "DEPTH";
val = node.Depth.ToString();
}
break;
case 7:
{
key = "UDA#1";
val = string.Format("{0}-{1}", node.ID, node.NodeName);
}
break;
case 8:
{
key = "UDA#2";
val = string.Format("{0}-{1}", node.Index, node.NodeName);
}
break;
case 9:
{
key = "UDA#3";
val = string.Format("{0}-{1}", node.ParentIndex, node.NodeName);
}
break;
default:
break;
}
if (uda.Property.ContainsKey(key) == false)
uda.Property.Add(key, val);
}
udac.Items.Add(uda);
}
string output = string.Format(
"{0}\\{1}_Attribute.viz"
, System.IO.Path.GetDirectoryName(path)
, System.IO.Path.GetFileNameWithoutExtension(path)
);
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
vizcore3d.Object3D.UDA.Add(
path /* INPUT VIZ */
, output /* OUTPUT VIZ */
, udac /* UDA Collection */
);
sw.Stop();
sb.AppendLine(
string.Format(
"ElapsedMilliseconds : {0:#,0}"
, sw.ElapsedMilliseconds
)
);
MessageBox.Show(sb.ToString(), "VIZCore3D.NET", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void ExampleV2()
{
string input = "C:\\MODEL\\BLOCK.viz";
string output = "C:\\MODEL\\BLOCK_ATTRIBUTE.viz";
VIZCore3D.NET.Data.UserDefineAttributeCollection uda =
new VIZCore3D.NET.Data.UserDefineAttributeCollection();
// Get Structure
VIZCore3D.NET.ShdCore.StructureManager stru =
new ShdCore.StructureManager(input);
List<VIZCore3D.NET.ShdCore.ModelTreeNode> nodes = stru.Roots;
foreach (VIZCore3D.NET.ShdCore.ModelTreeNode node in nodes)
{
// Filtering
if (node.NodeType != VIZCore3D.NET.ShdCore.ModelTreeNodeKind.ASSEMBLY) continue;
// Target ID
long id = node.EntityId;
// NEW Attribute
VIZCore3D.NET.Data.UserDefineAttributeItem item = new VIZCore3D.NET.Data.UserDefineAttributeItem();
item.NodeId.Add(Convert.ToInt32(id));
item.Property.Add("NAME", node.NodeName);
item.Property.Add("KIND", node.NodeType.ToString());
uda.Items.Add(item);
}
// Import Attribute
vizcore3d.Object3D.UDA.Add(input, output, uda);
}
Add(string key, string val, bool recursive)
public void Add(string key, string val, bool recursive)
선택된 개체에 속성을 추가
Parameters
| Name | Type | Description |
|---|---|---|
| key | string | 속성 키 |
| val | string | 속성 정보 |
| recursive | bool | 재귀적으로 추가 여부 |