개정판 9dab7146
dev issue #1240 : drawing 생성 / DB 구조 변경 / Signal Line moldeing / Autocad group method
Change-Id: I6fed8b5eedc971226fcddba31cea2cdbbdc0c8cf
DTI_PID/APIDConverter/AutoModeling.cs | ||
---|---|---|
63 | 63 |
acadApplication.ActiveDocument = acadDocument; |
64 | 64 |
acadDocument.SendCommand("QSAVE "); |
65 | 65 |
acadDocument.SendCommand("APPIDRun "); |
66 |
acadDocument.SendCommand("QSAVE "); |
|
66 | 67 |
Running = null; |
67 | 68 |
} |
68 | 69 |
} |
... | ... | |
75 | 76 |
} |
76 | 77 |
public void Run() |
77 | 78 |
{ |
78 |
test();
|
|
79 |
RunLineModeling();
|
|
79 | 80 |
} |
80 | 81 |
|
81 |
private string ReadDrawingLastLine() |
|
82 |
#region Run Method |
|
83 |
private void RunLineModeling() |
|
82 | 84 |
{ |
83 |
string sHandle = string.Empty; |
|
84 |
SqlConnection connection = null; |
|
85 |
try |
|
86 |
{ |
|
87 |
connection = new SqlConnection(); |
|
88 |
connection.ConnectionString = DB.Project_DB.GetAvevaConnectionString(); |
|
89 |
connection.Open(); |
|
90 |
|
|
91 |
string strQry = string.Format("Select Handle from Pipe Where id = (SELECT MAX(id) FROM Pipe WHERE DrawingId = '{0}')", "Test"); |
|
92 |
SqlCommand cmd = new SqlCommand(); |
|
93 |
cmd.Connection = connection; |
|
94 |
cmd.CommandText = strQry; |
|
95 |
cmd.CommandType = CommandType.Text; |
|
96 |
|
|
97 |
SqlDataAdapter da = new SqlDataAdapter(cmd); |
|
98 |
System.Data.DataTable dt = new System.Data.DataTable(); |
|
99 |
da.Fill(dt); |
|
100 |
if (dt.Rows.Count == 1) |
|
101 |
sHandle = dt.Rows[0][0].ToString(); |
|
102 |
|
|
103 |
dt.Dispose(); |
|
104 |
da.Dispose(); |
|
105 |
} |
|
106 |
catch (System.Exception) |
|
107 |
{ } |
|
108 |
finally |
|
85 |
foreach (var item in document.LINES) |
|
109 | 86 |
{ |
110 |
if (connection != null)
|
|
111 |
connection.Close(); |
|
87 |
LineModeling(item);
|
|
88 |
|
|
112 | 89 |
} |
90 |
} |
|
91 |
#endregion |
|
113 | 92 |
|
114 |
return sHandle; |
|
93 |
#region Modeling Method |
|
94 |
private void LineModeling(Model.Line line) |
|
95 |
{ |
|
96 |
List<string> points = new List<string>(); |
|
97 |
points.Add(line.Aveva.Start_X + "," + line.Aveva.Start_Y); |
|
98 |
points.Add(line.Aveva.End_X + "," + line.Aveva.End_Y); |
|
99 |
|
|
100 |
if (line.Aveva.Type == Model.Type.Pipe) |
|
101 |
line.Aveva.Handle = DrawPipe(line.Aveva.Name, points); |
|
102 |
else if (line.Aveva.Type == Model.Type.Signal) |
|
103 |
line.Aveva.Handle = DrawSignal(line.Aveva.Name, points); |
|
115 | 104 |
} |
105 |
#endregion |
|
116 | 106 |
|
117 | 107 |
#region Drawing Method |
118 |
private string DrawPipe(string style, List<string> coordinates)
|
|
108 |
private long DrawPipe(string style, List<string> coordinates)
|
|
119 | 109 |
{ |
120 |
GUIUtils.SetPipeStyle(style); |
|
121 |
|
|
122 |
string prevHandle = ReadDrawingLastLine(); |
|
110 |
List<long> prevHandles = GetAllGroupHandles(); |
|
123 | 111 |
|
112 |
GUIUtils.SetPipeStyle(style); |
|
124 | 113 |
Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; |
125 | 114 |
Editor editor = acDoc.Editor; |
126 | 115 |
List<object> commandParam = new List<object>(); |
... | ... | |
136 | 125 |
|
137 | 126 |
editor.Command(commandParam.ToArray()); |
138 | 127 |
|
139 |
string newHandle = ReadDrawingLastLine(); |
|
140 |
if (prevHandle == newHandle) |
|
141 |
return string.Empty; |
|
128 |
List<long> newHandles = GetAllGroupHandles(); |
|
129 |
List<long> otherHandles = new List<long>(); |
|
130 |
foreach (var item in newHandles) |
|
131 |
if (!prevHandles.Contains(item)) |
|
132 |
otherHandles.Add(item); |
|
142 | 133 |
|
143 |
return newHandle; |
|
134 |
if (otherHandles.Count == 1) |
|
135 |
return otherHandles[0]; |
|
136 |
else |
|
137 |
return 0; |
|
144 | 138 |
} |
145 |
private void DrawPipe(string style, List<string> coordinates, ObjectId objectId)
|
|
139 |
private long DrawPipe(string style, List<string> coordinates, ObjectId objectId)
|
|
146 | 140 |
{ |
141 |
List<long> prevHandles = GetAllGroupHandles(); |
|
147 | 142 |
GUIUtils.SetPipeStyle(style); |
148 | 143 |
|
149 | 144 |
Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; |
... | ... | |
164 | 159 |
commandParam.Add(null); |
165 | 160 |
|
166 | 161 |
editor.Command(commandParam.ToArray()); |
162 |
|
|
163 |
List<long> newHandles = GetAllGroupHandles(); |
|
164 |
List<long> otherHandles = new List<long>(); |
|
165 |
foreach (var item in newHandles) |
|
166 |
if (!prevHandles.Contains(item)) |
|
167 |
otherHandles.Add(item); |
|
168 |
|
|
169 |
if (otherHandles.Count == 1) |
|
170 |
return otherHandles[0]; |
|
171 |
else |
|
172 |
return 0; |
|
173 |
} |
|
174 |
|
|
175 |
private long DrawSignal(string style, List<string> coordinates) |
|
176 |
{ |
|
177 |
List<long> prevHandles = GetAllGroupHandles(); |
|
178 |
|
|
179 |
GUIUtils.SetPipeStyle(style); |
|
180 |
Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; |
|
181 |
Editor editor = acDoc.Editor; |
|
182 |
List<object> commandParam = new List<object>(); |
|
183 |
//command name |
|
184 |
commandParam.Add("VPESIGNAL"); |
|
185 |
//coordinate |
|
186 |
foreach (var item in coordinates) |
|
187 |
commandParam.Add(item); |
|
188 |
//enter |
|
189 |
commandParam.Add(null); |
|
190 |
|
|
191 |
editor.Command(commandParam.ToArray()); |
|
192 |
|
|
193 |
List<long> newHandles = GetAllGroupHandles(); |
|
194 |
List<long> otherHandles = new List<long>(); |
|
195 |
foreach (var item in newHandles) |
|
196 |
if (!prevHandles.Contains(item)) |
|
197 |
otherHandles.Add(item); |
|
198 |
|
|
199 |
if (otherHandles.Count == 1) |
|
200 |
return otherHandles[0]; |
|
201 |
else |
|
202 |
return 0; |
|
167 | 203 |
} |
168 | 204 |
private void InsertSymbol(string insertSymbolName, double x, double y) |
169 | 205 |
{ |
... | ... | |
188 | 224 |
} |
189 | 225 |
#endregion |
190 | 226 |
|
227 |
private List<long> GetAllGroupHandles() |
|
228 |
{ |
|
229 |
List<long> handles = new List<long>(); |
|
230 |
|
|
231 |
Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; |
|
232 |
Database acCurDb = acDoc.Database; |
|
233 |
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) |
|
234 |
{ |
|
235 |
DBDictionary gd = (DBDictionary)acTrans.GetObject(acCurDb.GroupDictionaryId, OpenMode.ForRead); |
|
236 |
foreach (var entry in gd) |
|
237 |
handles.Add(entry.Value.Handle.Value); |
|
238 |
acTrans.Commit(); |
|
239 |
} |
|
240 |
return handles; |
|
241 |
} |
|
242 |
|
|
243 |
private ObjectId GetFirstPolyLine(long groupHandle) |
|
244 |
{ |
|
245 |
ObjectId result = ObjectId.Null; |
|
246 |
|
|
247 |
Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; |
|
248 |
Database acCurDb = acDoc.Database; |
|
249 |
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) |
|
250 |
{ |
|
251 |
DBDictionary gd = (DBDictionary)acTrans.GetObject(acCurDb.GroupDictionaryId, OpenMode.ForRead); |
|
252 |
foreach (var entry in gd) |
|
253 |
{ |
|
254 |
if (entry.Value.Handle.Value == groupHandle) |
|
255 |
{ |
|
256 |
Autodesk.AutoCAD.DatabaseServices.Group group = acTrans.GetObject(entry.Value, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Group; |
|
257 |
foreach (var item in group.GetAllEntityIds()) |
|
258 |
{ |
|
259 |
if (acTrans.GetObject(item, OpenMode.ForRead).GetType() == typeof(Autodesk.AutoCAD.DatabaseServices.Polyline)) |
|
260 |
{ |
|
261 |
result = item; |
|
262 |
break; |
|
263 |
} |
|
264 |
} |
|
265 |
break; |
|
266 |
} |
|
267 |
} |
|
268 |
acTrans.Commit(); |
|
269 |
} |
|
270 |
|
|
271 |
return result; |
|
272 |
} |
|
273 |
|
|
191 | 274 |
#region Test Source |
192 | 275 |
public void test() |
193 | 276 |
{ |
194 | 277 |
//InitGUI(); |
278 |
//DrawSignal("SONIC", new List<string>() { "2,100", "100,100" }); |
|
195 | 279 |
|
196 | 280 |
DrawPipe("Main Pipe", new List<string>() { "2,100", "100,100" }); |
197 | 281 |
|
198 |
DrawPipe("Main Pipe", new List<string>() { "2,200", "100,200" }); |
|
282 |
//DrawPipe("Main Pipe", new List<string>() { "2,200", "100,200" });
|
|
199 | 283 |
|
200 |
DrawPipe("Sub Pipe", new List<string>() { "50,100", "50,200" }); |
|
284 |
//DrawPipe("Sub Pipe", new List<string>() { "50,100", "50,200" });
|
|
201 | 285 |
} |
202 |
|
|
203 |
public static void TEST() |
|
286 |
public static void TESTStatic() |
|
204 | 287 |
{ |
205 | 288 |
AutoModeling auto = new AutoModeling(null); |
206 | 289 |
auto.test(); |
DTI_PID/APIDConverter/DB/Project_DB.cs | ||
---|---|---|
75 | 75 |
|
76 | 76 |
if (dt.Select(string.Format("NAME = '{0}'", APID_SYMBOL_MAPPING_TABLE)).Length == 0) |
77 | 77 |
{ |
78 |
cmd.CommandText = string.Format("CREATE TABLE {0} (UID TEXT PRIMARY KEY, NAME TEXT, APID_SYMBOL TEXT)", APID_SYMBOL_MAPPING_TABLE); |
|
78 |
cmd.CommandText = string.Format("CREATE TABLE {0} (UID TEXT PRIMARY KEY, NAME TEXT, APID_SYMBOL TEXT, DATA1 TEXT)", APID_SYMBOL_MAPPING_TABLE);
|
|
79 | 79 |
cmd.ExecuteNonQuery(); |
80 | 80 |
} |
81 | 81 |
} |
... | ... | |
112 | 112 |
|
113 | 113 |
if (dt.Select(string.Format("NAME = '{0}'", APID_SYMBOL_MAPPING_TABLE)).Length == 0) |
114 | 114 |
{ |
115 |
cmd.CommandText = string.Format("CREATE TABLE {0} (UID varchar(255) PRIMARY KEY, NAME varchar(MAX), APID_SYMBOL varchar(MAX))", APID_SYMBOL_MAPPING_TABLE); |
|
115 |
cmd.CommandText = string.Format("CREATE TABLE {0} (UID varchar(255) PRIMARY KEY, NAME varchar(MAX), APID_SYMBOL varchar(MAX), DATA1 varchar(255))", APID_SYMBOL_MAPPING_TABLE);
|
|
116 | 116 |
cmd.ExecuteNonQuery(); |
117 | 117 |
} |
118 | 118 |
|
... | ... | |
149 | 149 |
using (SQLiteCommand cmd = connection.CreateCommand()) |
150 | 150 |
{ |
151 | 151 |
cmd.CommandText = string.Format(@" |
152 |
SELECT s.UID, s.Name, st.Type, sp.APID_SYMBOL FROM {1} as st, {0} as s |
|
152 |
SELECT s.UID, s.Name, st.Type, sp.APID_SYMBOL, sp.DATA1 FROM {1} as st, {0} as s
|
|
153 | 153 |
LEFT OUTER JOIN {2} as sp |
154 | 154 |
ON s.UID = SP.UID |
155 | 155 |
WHERE s.SymbolType_UID = st.UID |
... | ... | |
189 | 189 |
using (SqlCommand cmd = connection.CreateCommand()) |
190 | 190 |
{ |
191 | 191 |
cmd.CommandText = string.Format(@" |
192 |
SELECT CONVERT(VARCHAR(255), s.UID) AS UID, s.Name, st.Type, sp.APID_SYMBOL FROM {1} as st, {0} as s |
|
192 |
SELECT CONVERT(VARCHAR(255), s.UID) AS UID, s.Name, st.Type, sp.APID_SYMBOL, sp.DATA1 FROM {1} as st, {0} as s
|
|
193 | 193 |
LEFT OUTER JOIN {2} as sp |
194 | 194 |
ON CONVERT(VARCHAR(255), s.UID) = CONVERT(VARCHAR(255), SP.UID) |
195 | 195 |
WHERE s.SymbolType_UID = st.UID |
... | ... | |
228 | 228 |
using (SQLiteCommand cmd = connection.CreateCommand()) |
229 | 229 |
{ |
230 | 230 |
cmd.CommandText = string.Format(@" |
231 |
SELECT l.UID, l.Name, sp.APID_SYMBOL FROM {0} as l |
|
231 |
SELECT l.UID, l.Name, sp.APID_SYMBOL, sp.DATA1 FROM {0} as l
|
|
232 | 232 |
LEFT OUTER JOIN {1} as sp |
233 | 233 |
ON l.UID = SP.UID ;", LineTypes_TABLE, APID_SYMBOL_MAPPING_TABLE); |
234 | 234 |
using (SQLiteDataReader dr = cmd.ExecuteReader()) |
... | ... | |
257 | 257 |
using (SqlCommand cmd = connection.CreateCommand()) |
258 | 258 |
{ |
259 | 259 |
cmd.CommandText = string.Format(@" |
260 |
SELECT l.UID, l.Name, sp.APID_SYMBOL FROM {0} as l |
|
260 |
SELECT l.UID, l.Name, sp.APID_SYMBOL, sp.DATA1 FROM {0} as l
|
|
261 | 261 |
LEFT OUTER JOIN {1} as sp |
262 | 262 |
ON l.UID = SP.UID ;", LineTypes_TABLE, APID_SYMBOL_MAPPING_TABLE); |
263 | 263 |
using (SqlDataReader dr = cmd.ExecuteReader()) |
... | ... | |
460 | 460 |
|
461 | 461 |
return dt; |
462 | 462 |
} |
463 |
public static bool InsertSymbolMapping(List<Tuple<string, string, string>> datas) |
|
463 |
public static bool InsertSymbolMapping(List<Tuple<string, string, string, string>> datas)
|
|
464 | 464 |
{ |
465 | 465 |
Project_Info projectInfo = Project_Info.GetInstance(); |
466 | 466 |
if (projectInfo.DBType == ID2DB_Type.SQLite) |
... | ... | |
479 | 479 |
foreach (var item in datas) |
480 | 480 |
{ |
481 | 481 |
cmd.Parameters.Clear(); |
482 |
cmd.CommandText = string.Format("INSERT OR REPLACE INTO {0} (UID, NAME, APID_SYMBOL) VALUES (@UID, @NAME, @APID_SYMBOL)", APID_SYMBOL_MAPPING_TABLE);
|
|
482 |
cmd.CommandText = string.Format("INSERT OR REPLACE INTO {0} (UID, NAME, APID_SYMBOL, DATA1) VALUES (@UID, @NAME, @APID_SYMBOL, @DATA1)", APID_SYMBOL_MAPPING_TABLE);
|
|
483 | 483 |
cmd.Parameters.AddWithValue("@UID", item.Item1); |
484 | 484 |
cmd.Parameters.AddWithValue("@NAME", item.Item2); |
485 | 485 |
cmd.Parameters.AddWithValue("@APID_SYMBOL", item.Item3); |
486 |
cmd.Parameters.AddWithValue("@DATA1", item.Item4); |
|
486 | 487 |
cmd.ExecuteNonQuery(); |
487 | 488 |
} |
488 | 489 |
} |
... | ... | |
527 | 528 |
cmd.Parameters.Clear(); |
528 | 529 |
cmd.CommandText = string.Format(@" |
529 | 530 |
IF EXISTS (SELECT * FROM {0} WHERE UID = '{1}') |
530 |
UPDATE {0} SET NAME = @NAME, APID_SYMBOL = @APID_SYMBOL WHERE UID = @UID |
|
531 |
UPDATE {0} SET NAME = @NAME, APID_SYMBOL = @APID_SYMBOL, DATA1 = @DATA1 WHERE UID = @UID
|
|
531 | 532 |
ELSE |
532 |
INSERT INTO {0} (UID, NAME, APID_SYMBOL) VALUES (@UID, @NAME, @APID_SYMBOL)", APID_SYMBOL_MAPPING_TABLE, item.Item1);
|
|
533 |
INSERT INTO {0} (UID, NAME, APID_SYMBOL, DATA1) VALUES (@UID, @NAME, @APID_SYMBOL, @DATA1)", APID_SYMBOL_MAPPING_TABLE, item.Item1);
|
|
533 | 534 |
cmd.Parameters.AddWithValue("@UID", item.Item1); |
534 | 535 |
if (string.IsNullOrEmpty(item.Item2)) |
535 | 536 |
cmd.Parameters.AddWithValue("@NAME", DBNull.Value); |
... | ... | |
539 | 540 |
cmd.Parameters.AddWithValue("@APID_SYMBOL", DBNull.Value); |
540 | 541 |
else |
541 | 542 |
cmd.Parameters.AddWithValue("@APID_SYMBOL", item.Item3); |
543 |
if (string.IsNullOrEmpty(item.Item4)) |
|
544 |
cmd.Parameters.AddWithValue("@DATA1", DBNull.Value); |
|
545 |
else |
|
546 |
cmd.Parameters.AddWithValue("@DATA1", item.Item4); |
|
547 |
|
|
542 | 548 |
cmd.ExecuteNonQuery(); |
543 | 549 |
} |
544 | 550 |
} |
DTI_PID/APIDConverter/Form/MappingForm.cs | ||
---|---|---|
143 | 143 |
gridControlLine.DataSource = dt; |
144 | 144 |
|
145 | 145 |
gridViewLine.Columns["UID"].Visible = false; |
146 |
gridViewLine.Columns["DATA1"].Visible = false; |
|
146 | 147 |
gridViewLine.Columns["APID_SYMBOL"].Caption = "APID Line"; |
147 | 148 |
gridViewLine.Columns["Type"].GroupIndex = 0; |
148 | 149 |
gridViewLine.ExpandAllGroups(); |
... | ... | |
196 | 197 |
} |
197 | 198 |
private void btnSave_Click(object sender, EventArgs e) |
198 | 199 |
{ |
199 |
List<Tuple<string, string, string>> symbolDatas = new List<Tuple<string, string, string>>();
|
|
200 |
List<Tuple<string, string, string, string>> symbolDatas = new List<Tuple<string, string, string, string>>();
|
|
200 | 201 |
#region Set Datas |
201 | 202 |
DataTable symbolDT = gridControlSymbol.DataSource as DataTable; |
202 | 203 |
foreach (DataRow row in symbolDT.Rows) |
... | ... | |
204 | 205 |
string uid = row["UID"].ToString(); |
205 | 206 |
string name = row["Name"].ToString(); |
206 | 207 |
string apidSymbol = row["APID_SYMBOL"].ToString(); |
207 |
symbolDatas.Add(new Tuple<string, string, string>(uid, name, apidSymbol));
|
|
208 |
symbolDatas.Add(new Tuple<string, string, string, string>(uid, name, apidSymbol, null));
|
|
208 | 209 |
} |
209 | 210 |
DataTable lineDT = gridControlLine.DataSource as DataTable; |
211 |
List<string> pipeStyle = APIDUtils.GetPipeStyle(); |
|
212 |
List<string> signalStyle = APIDUtils.GetSignalStyle(); |
|
210 | 213 |
foreach (DataRow row in lineDT.Rows) |
211 | 214 |
{ |
212 | 215 |
string uid = row["UID"].ToString(); |
213 | 216 |
string name = row["Name"].ToString(); |
214 | 217 |
string apidSymbol = row["APID_SYMBOL"].ToString(); |
215 |
symbolDatas.Add(new Tuple<string, string, string>(uid, name, apidSymbol)); |
|
218 |
string type = null; |
|
219 |
if (!string.IsNullOrEmpty(apidSymbol)) |
|
220 |
{ |
|
221 |
if (pipeStyle.Contains(apidSymbol)) |
|
222 |
type = "PIPE"; |
|
223 |
else if (signalStyle.Contains(apidSymbol)) |
|
224 |
type = "SIGNAL"; |
|
225 |
} |
|
226 |
symbolDatas.Add(new Tuple<string, string, string, string>(uid, name, apidSymbol, type)); |
|
216 | 227 |
} |
217 | 228 |
#endregion |
218 | 229 |
|
DTI_PID/APIDConverter/Model/PlantItem/Document.cs | ||
---|---|---|
527 | 527 |
return LINES.Find(x => x.UID == uid); |
528 | 528 |
} |
529 | 529 |
|
530 |
#region For Aveva |
|
531 |
|
|
530 | 532 |
public bool SetAvevaInfo(DataTable lineMappingTable) |
531 | 533 |
{ |
532 | 534 |
bool result = true; |
... | ... | |
541 | 543 |
item.Aveva.Start_Y = item.Start_Y; |
542 | 544 |
item.Aveva.End_X = item.End_X; |
543 | 545 |
item.Aveva.End_Y = item.End_Y; |
546 |
|
|
547 |
if (!DBNull.Value.Equals(rows[0]["DATA1"])) |
|
548 |
{ |
|
549 |
if (rows[0]["DATA1"].ToString() == "PIPE") |
|
550 |
item.Aveva.Type = Type.Pipe; |
|
551 |
else if (rows[0]["DATA1"].ToString() == "SIGNAL") |
|
552 |
item.Aveva.Type = Type.Signal; |
|
553 |
} |
|
544 | 554 |
} |
545 | 555 |
else |
546 | 556 |
{ |
... | ... | |
550 | 560 |
|
551 | 561 |
return result; |
552 | 562 |
} |
563 |
|
|
564 |
#endregion |
|
553 | 565 |
} |
554 | 566 |
} |
DTI_PID/APIDConverter/Model/PlantItem/Other/AvevaLineInfo.cs | ||
---|---|---|
6 | 6 |
|
7 | 7 |
namespace AVEVA.PID.CustomizationUtility.Model |
8 | 8 |
{ |
9 |
public enum Type |
|
10 |
{ |
|
11 |
None, |
|
12 |
Pipe, |
|
13 |
Signal, |
|
14 |
} |
|
9 | 15 |
public class AvevaLineInfo |
10 | 16 |
{ |
17 |
public Type Type { get; set; } |
|
18 |
public long Handle { get; set; } |
|
11 | 19 |
public string Name { get; set; } |
12 | 20 |
public double Start_X { get; set; } |
13 | 21 |
public double Start_Y { get; set; } |
DTI_PID/APIDConverter/PIDCustomization.cs | ||
---|---|---|
419 | 419 |
[CommandMethod("TestS", Autodesk.AutoCAD.Runtime.CommandFlags.UsePickSet)] |
420 | 420 |
public static void TestSelection() |
421 | 421 |
{ |
422 |
|
|
422 |
|
|
423 | 423 |
//APIDUtils.CreateDrawingAndOpen("testA1", "1", "Aveva-Metric", "1"); |
424 |
AutoModeling.TEST(); |
|
424 |
AutoModeling.TESTStatic(); |
|
425 |
} |
|
426 |
|
|
427 |
[CommandMethod("PicTest", Autodesk.AutoCAD.Runtime.CommandFlags.UsePickSet)] |
|
428 |
public static void PicTest() |
|
429 |
{ |
|
430 |
// Get the current document and database, and start a transaction |
|
431 |
Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; |
|
432 |
Database acCurDb = acDoc.Database; |
|
433 |
Editor acDocEd = acDoc.Editor; |
|
434 |
|
|
435 |
// Request for objects to be selected in the drawing area |
|
436 |
PromptSelectionResult acSSPrompt = acDocEd.GetSelection(); |
|
437 |
|
|
438 |
// If the prompt status is OK, objects were selected |
|
439 |
if (acSSPrompt.Status == PromptStatus.OK) |
|
440 |
{ |
|
441 |
ObjectId[] selectedObjectIds = acSSPrompt.Value.GetObjectIds(); |
|
442 |
// Get the last selected entity |
|
443 |
|
|
444 |
if (selectedObjectIds.Length > 0) |
|
445 |
{ |
|
446 |
ObjectId objIdBlock = selectedObjectIds[0]; |
|
447 |
|
|
448 |
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) |
|
449 |
{ |
|
450 |
DBDictionary gd = (DBDictionary)acTrans.GetObject(acCurDb.GroupDictionaryId, OpenMode.ForRead); |
|
451 |
|
|
452 |
DBObject objDB = acTrans.GetObject(objIdBlock, OpenMode.ForRead, true); |
|
453 |
if (objDB != null) |
|
454 |
{ |
|
455 |
|
|
456 |
foreach (var entry in gd) |
|
457 |
{ |
|
458 |
Autodesk.AutoCAD.DatabaseServices.Group group = acTrans.GetObject(entry.Value, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Group; |
|
459 |
ObjectId[] ids = group.GetAllEntityIds(); |
|
460 |
foreach (var item in group.GetAllEntityIds()) |
|
461 |
{ |
|
462 |
|
|
463 |
} |
|
464 |
} |
|
465 |
// check if the selected entity is of Type BlockReference |
|
466 |
//if (objDB.GetType() == typeof(BlockReference)) |
|
467 |
//{ |
|
468 |
// BlockReference block = objDB as BlockReference; |
|
469 |
|
|
470 |
// // open an entity in write mode so that we can modify its color |
|
471 |
// //Entity objDb = (Entity)acTrans.GetObject(objIdBlock, OpenMode.ForWrite); |
|
472 |
// //if (objDb != null) |
|
473 |
// //{ |
|
474 |
// // objDb.ColorIndex = 0;// white color |
|
475 |
// //} |
|
476 |
//} |
|
477 |
} |
|
478 |
acTrans.Commit(); |
|
479 |
} |
|
480 |
} |
|
481 |
} |
|
425 | 482 |
} |
426 | 483 |
|
427 | 484 |
|
내보내기 Unified diff