프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / DTI_PID / APIDConverter / AutoModeling.cs @ 128c844f

이력 | 보기 | 이력해설 | 다운로드 (21.2 KB)

1 74a0c9d6 gaqhf
using System;
2
using System.Collections.Generic;
3 016701e5 gaqhf
using System.Collections;
4 74a0c9d6 gaqhf
using System.Configuration;
5
using System.Data;
6
using System.Data.Common;
7
using System.Data.SqlClient;
8
using System.IO;
9
10
using Autodesk.AutoCAD.ApplicationServices;
11
using Autodesk.AutoCAD.ApplicationServices.Core;
12
using Autodesk.AutoCAD.DatabaseServices;
13
using Autodesk.AutoCAD.EditorInput;
14
using Autodesk.AutoCAD.Geometry;
15
using Autodesk.AutoCAD.Interop;
16
using Autodesk.AutoCAD.Interop.Common;
17
using Autodesk.AutoCAD.Runtime;
18
using Autodesk.AutoCAD.Windows;
19
20 1c5bd296 gaqhf
using AVEVA.PID.Components;
21
using AVEVA.PID.GUI;
22
using AVEVA.PID.Common;
23
using AVEVA.PID.DWGSelector;
24
25 14540282 gaqhf
using AVEVA.PID.CustomizationUtility.DB;
26
using AVEVA.PID.CustomizationUtility.Model;
27
using AVEVA.PID.CustomizationUtility.Properties;
28 74a0c9d6 gaqhf
29
namespace AVEVA.PID.CustomizationUtility
30
{
31
    public class AutoModeling
32
    {
33 1c5bd296 gaqhf
        public static AutoModeling Running { get; set; }
34 14540282 gaqhf
        Model.Document document;
35 74a0c9d6 gaqhf
36 14540282 gaqhf
        public AutoModeling(Model.Document document)
37 74a0c9d6 gaqhf
        {
38 14540282 gaqhf
            this.document = document;
39 74a0c9d6 gaqhf
        }
40
41 1c5bd296 gaqhf
        public void CreateDrawing()
42 46756c13 gaqhf
        {
43 1c5bd296 gaqhf
            string outPath = Project_DB.GetDirectiveValue("DRGPTH");
44
            string tempPath = Path.GetTempPath();
45
            string selectedFullPath = Path.Combine(tempPath, document.AvevaTemplateName + ".DWT");
46
47
            DWTSelector.strDrawingNumber = document.AvevaDrawingNumber;
48
            DWTSelector.strSheetNumber = document.AvevaSheetNumber;
49
            DWTSelector.strCadFileName = document.AvevaDrawingNumber + document.AvevaSheetNumber;
50
            DWTSelector.strCadFilePath = outPath;
51
52
            try
53 46756c13 gaqhf
            {
54 1c5bd296 gaqhf
                string text = ReadWriteDrawingData.ReadTemplateData(document.AvevaTemplateName, document.AvevaTemplateID, selectedFullPath, false);
55
                Autodesk.AutoCAD.Interop.AcadApplication acadApplication = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication as Autodesk.AutoCAD.Interop.AcadApplication;
56
                Autodesk.AutoCAD.Interop.AcadDocument acadDocument = acadApplication.Documents.Add(text);
57
58
                Commands.addLatestPidvesrionToDictionary();
59
                AVVPropCmd.ActivateAcad();
60
61
                if (acadDocument != null)
62
                {
63
                    Running = this;
64
                    acadApplication.ActiveDocument = acadDocument;
65
                    acadDocument.SendCommand("QSAVE ");
66
                    acadDocument.SendCommand("APPIDRun ");
67 9dab7146 gaqhf
                    acadDocument.SendCommand("QSAVE ");
68 1c5bd296 gaqhf
                    Running = null;
69
                }
70 46756c13 gaqhf
            }
71 1c5bd296 gaqhf
            catch (System.Exception ex)
72
            {
73
                
74
            }
75
76
            GC.Collect();
77
        }
78
        public void Run()
79
        {
80 016701e5 gaqhf
            try
81
            {
82
                RunLineModeling();
83
                RunSymbolModeling();
84
            }
85
            catch (System.Exception ex)
86
            {
87
                System.Windows.Forms.MessageBox.Show(ex.Message + @"\n" + ex.StackTrace);
88
            }
89 46756c13 gaqhf
        }
90
91 9dab7146 gaqhf
        #region Run Method
92
        private void RunLineModeling()
93 74a0c9d6 gaqhf
        {
94 9dab7146 gaqhf
            foreach (var item in document.LINES)
95 74a0c9d6 gaqhf
            {
96 53344e2c gaqhf
                if (item.Aveva.Handle == 0)
97
                    LineModeling(item);
98 74a0c9d6 gaqhf
            }
99 9dab7146 gaqhf
        }
100 016701e5 gaqhf
        private void RunSymbolModeling()
101
        {
102 b90890eb gaqhf
            foreach (var item in document.SYMBOLS)
103
            {
104
                if (item.Aveva.Handle == 0)
105
                    SymbolModeling(item);
106
            }
107 016701e5 gaqhf
        }
108 9dab7146 gaqhf
        #endregion
109 74a0c9d6 gaqhf
110 9dab7146 gaqhf
        #region Modeling Method
111
        private void LineModeling(Model.Line line)
112
        {
113 53344e2c gaqhf
            List<Model.Line> groupLine = new List<Model.Line>();
114 9dab7146 gaqhf
            List<string> points = new List<string>();
115 016701e5 gaqhf
            GetConnectedGroupLine(line, groupLine, false);
116 53344e2c gaqhf
            GetGroupLinePoints(groupLine, points);
117 9dab7146 gaqhf
118 53344e2c gaqhf
            long handle = 0;
119 9dab7146 gaqhf
            if (line.Aveva.Type == Model.Type.Pipe)
120 53344e2c gaqhf
                handle = DrawPipe(line.Aveva.Name, points);
121 9dab7146 gaqhf
            else if (line.Aveva.Type == Model.Type.Signal)
122 53344e2c gaqhf
                handle = DrawSignal(line.Aveva.Name, points);
123
124
            foreach (var item in groupLine)
125
                item.Aveva.Handle = handle;
126 74a0c9d6 gaqhf
        }
127 b90890eb gaqhf
        private void SymbolModeling(Symbol symbol)
128
        {
129 73152510 gaqhf
            long handle = InsertSymbol(symbol.Aveva.Name, symbol.Aveva.X, symbol.Aveva.Y);
130
            if (handle != 0)
131 2d09df82 gaqhf
            {
132 73152510 gaqhf
                symbol.Aveva.Handle = handle;
133 2d09df82 gaqhf
                ObjectId objectId = GetObjectIdByHandle(handle);
134
                if (objectId != ObjectId.Null)
135
                {
136
                    SetBlockReferenceRotation(objectId, symbol.ANGLE);
137
                }
138
            }
139
                
140 b90890eb gaqhf
        }
141 9dab7146 gaqhf
        #endregion
142 74a0c9d6 gaqhf
143
        #region Drawing Method
144 9dab7146 gaqhf
        private long DrawPipe(string style, List<string> coordinates)
145 74a0c9d6 gaqhf
        {
146 9dab7146 gaqhf
            List<long> prevHandles = GetAllGroupHandles();
147 74a0c9d6 gaqhf
148 9dab7146 gaqhf
            GUIUtils.SetPipeStyle(style);
149 14540282 gaqhf
            Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
150 74a0c9d6 gaqhf
            Editor editor = acDoc.Editor;
151
            List<object> commandParam = new List<object>();
152
            //command name
153
            commandParam.Add("DRPIPE");
154
            //coordinate
155
            foreach (var item in coordinates)
156
                commandParam.Add(item);
157
            //enter
158
            commandParam.Add(null);
159
            //enter
160
            commandParam.Add(null);
161
162
            editor.Command(commandParam.ToArray());
163
164 9dab7146 gaqhf
            List<long> newHandles = GetAllGroupHandles();
165
            List<long> otherHandles = new List<long>();
166
            foreach (var item in newHandles)
167
                if (!prevHandles.Contains(item))
168
                    otherHandles.Add(item);
169 74a0c9d6 gaqhf
170 9dab7146 gaqhf
            if (otherHandles.Count == 1)
171
                return otherHandles[0];
172
            else
173
                return 0;
174 74a0c9d6 gaqhf
        }
175 9dab7146 gaqhf
        private long DrawPipe(string style, List<string> coordinates, ObjectId objectId)
176 74a0c9d6 gaqhf
        {
177 9dab7146 gaqhf
            List<long> prevHandles = GetAllGroupHandles();
178 14540282 gaqhf
            GUIUtils.SetPipeStyle(style);
179 74a0c9d6 gaqhf
180 14540282 gaqhf
            Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
181 74a0c9d6 gaqhf
            Editor editor = acDoc.Editor;
182
            List<object> commandParam = new List<object>();
183
            //command name
184
            commandParam.Add("DRPIPE");
185
            //coordinate
186
            foreach (var item in coordinates)
187
                commandParam.Add(item);
188
            //enter
189
            commandParam.Add(null);
190
191
            //Input Object ID
192
            commandParam.Add(objectId);
193
194
            //enter
195
            commandParam.Add(null);
196
197
            editor.Command(commandParam.ToArray());
198 9dab7146 gaqhf
199
            List<long> newHandles = GetAllGroupHandles();
200
            List<long> otherHandles = new List<long>();
201
            foreach (var item in newHandles)
202
                if (!prevHandles.Contains(item))
203
                    otherHandles.Add(item);
204
205
            if (otherHandles.Count == 1)
206
                return otherHandles[0];
207
            else
208
                return 0;
209
        }
210
        private long DrawSignal(string style, List<string> coordinates)
211
        {
212
            List<long> prevHandles = GetAllGroupHandles();
213
214
            GUIUtils.SetPipeStyle(style);
215
            Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
216
            Editor editor = acDoc.Editor;
217
            List<object> commandParam = new List<object>();
218
            //command name
219
            commandParam.Add("VPESIGNAL");
220
            //coordinate
221
            foreach (var item in coordinates)
222
                commandParam.Add(item);
223
            //enter
224
            commandParam.Add(null);
225
226
            editor.Command(commandParam.ToArray());
227
228
            List<long> newHandles = GetAllGroupHandles();
229
            List<long> otherHandles = new List<long>();
230
            foreach (var item in newHandles)
231
                if (!prevHandles.Contains(item))
232
                    otherHandles.Add(item);
233
234
            if (otherHandles.Count == 1)
235
                return otherHandles[0];
236
            else
237
                return 0;
238 74a0c9d6 gaqhf
        }
239 73152510 gaqhf
        private long InsertSymbol(string insertSymbolName, double x, double y)
240 6b3cb476 gaqhf
        {
241 73152510 gaqhf
            long handle = 0;
242 6b3cb476 gaqhf
            try
243
            {
244 73152510 gaqhf
                List<long> prevHandles = GetAllBlockHandlesByName(insertSymbolName);
245
246 6b3cb476 gaqhf
                AVEVA.PID.Utilities.DrawingData drawingData = new AVEVA.PID.Utilities.DrawingData();
247
                drawingData.InsertSymbolName = insertSymbolName;
248
                Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
249
                Editor editor = acDoc.Editor;
250
                List<object> commandParam = new List<object>();
251
                commandParam.Add("INSSYM");
252
                Point3d point = new Point3d(x, y, 0);
253
                commandParam.Add(point);
254
                commandParam.Add(null);
255
256
                editor.Command(commandParam.ToArray());
257 73152510 gaqhf
258
                List<long> newHandles = GetAllBlockHandlesByName(insertSymbolName);
259
                List<long> otherHandles = new List<long>();
260
                foreach (var item in newHandles)
261
                    if (!prevHandles.Contains(item))
262
                        otherHandles.Add(item);
263
264
                if (otherHandles.Count == 1)
265
                    return otherHandles[0];
266
                else
267
                    return 0;
268 6b3cb476 gaqhf
            }
269
            catch (System.Exception ex)
270
            {
271 74a0c9d6 gaqhf
272 6b3cb476 gaqhf
            }
273 73152510 gaqhf
274
            return handle;
275 6b3cb476 gaqhf
        }
276 74a0c9d6 gaqhf
        #endregion
277
278 73152510 gaqhf
        #region Autocad Utils
279
        private List<long> GetAllBlockHandlesByName(string name)
280
        {
281
            List<long> handles = new List<long>();
282
283
            Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
284
            Database acCurDb = acDoc.Database;
285
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
286
            {
287
                BlockTable gd = (BlockTable)acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead);
288
                foreach (var entry in gd)
289
                {
290
                    BlockTableRecord blockTableRecord = acTrans.GetObject(entry, OpenMode.ForRead, true) as BlockTableRecord;
291
                    if (blockTableRecord != null)
292
                    {
293
                        IEnumerable<BlockReference> records = AcDbLinqExtensionMethods.GetBlockReferences(blockTableRecord);
294
                        foreach (var item in records)
295
                        {
296
                            if (item.Name == name)
297
                                handles.Add(item.Handle.Value);
298
                        }
299
                    }
300
                }
301
                    
302
                acTrans.Commit();
303
            }
304
            return handles;
305
        }
306 9dab7146 gaqhf
        private List<long> GetAllGroupHandles()
307
        {
308
            List<long> handles = new List<long>();
309
310
            Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
311
            Database acCurDb = acDoc.Database;
312
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
313
            {
314
                DBDictionary gd = (DBDictionary)acTrans.GetObject(acCurDb.GroupDictionaryId, OpenMode.ForRead);
315
                foreach (var entry in gd)
316
                    handles.Add(entry.Value.Handle.Value);
317
                acTrans.Commit();
318
            }
319
            return handles;
320
        }
321
        private ObjectId GetFirstPolyLine(long groupHandle)
322
        {
323
            ObjectId result = ObjectId.Null;
324
325
            Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
326
            Database acCurDb = acDoc.Database;
327
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
328
            {
329
                DBDictionary gd = (DBDictionary)acTrans.GetObject(acCurDb.GroupDictionaryId, OpenMode.ForRead);
330
                foreach (var entry in gd)
331
                {
332
                    if (entry.Value.Handle.Value == groupHandle)
333
                    {
334
                        Autodesk.AutoCAD.DatabaseServices.Group group = acTrans.GetObject(entry.Value, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Group;
335
                        foreach (var item in group.GetAllEntityIds())
336
                        {
337
                            if (acTrans.GetObject(item, OpenMode.ForRead).GetType() == typeof(Autodesk.AutoCAD.DatabaseServices.Polyline))
338
                            {
339
                                result = item;
340
                                break;
341
                            }
342
                        }
343
                        break;
344
                    }
345
                }
346
                acTrans.Commit();
347
            }
348
349
            return result;
350
        }
351 2d09df82 gaqhf
        private ObjectId GetObjectIdByHandle(long lHandle)
352
        {
353
            Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
354
            Database acCurDb = acDoc.Database;
355
            Handle handle = new Handle(lHandle);
356
357
            return acCurDb.GetObjectId(false, handle, 0);
358
        }
359
        private void SetBlockReferenceRotation(ObjectId objectId, double rotation)
360
        {
361
            Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
362
            Database acCurDb = acDoc.Database;
363
            Editor acDocEd = acDoc.Editor;
364
365
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
366
            {
367
                DBObject objDB = acTrans.GetObject(objectId, OpenMode.ForWrite);
368
                if (objDB != null)
369
                {
370
                    if (objDB.GetType() == typeof(BlockReference))
371
                    {
372
                        BlockReference block = objDB as BlockReference;
373
                        block.Rotation = rotation;
374
                    }
375
                }
376
                acTrans.Commit();
377
            }
378
        }
379 016701e5 gaqhf
        #endregion
380
381 73152510 gaqhf
        #region Modeling Utils
382 016701e5 gaqhf
        private void GetConnectedGroupLine(Model.Line line, List<Model.Line> group, bool isInsert)
383 53344e2c gaqhf
        {
384
            if (!group.Contains(line))
385
            {
386 016701e5 gaqhf
                if (isInsert)
387 53344e2c gaqhf
                    group.Insert(0, line);
388
                else
389
                    group.Add(line);
390
391 016701e5 gaqhf
                if (line.CONNECTORS[0].ConnectedObject != null && !IsExistEndBreak(line, line.CONNECTORS[0].ConnectedObject))
392
                {
393
                    object connObj = line.CONNECTORS[0].ConnectedObject;
394
                    if (connObj.GetType() == typeof(Model.Line) &&
395
                        APIDUtils.IsConnectedLine(connObj as Model.Line, line))
396
                        GetConnectedGroupLine(connObj as Model.Line, group, true);
397
                    else if (connObj.GetType() == typeof(Model.Symbol))
398
                    {
399
                        Model.Line connLine = FindOtherLineByRun(line, connObj as Symbol);
400
                        if (connLine != null)
401
                            GetConnectedGroupLine(connLine as Model.Line, group, true);
402
                    }
403
                }
404
                if (line.CONNECTORS[1].ConnectedObject != null && !IsExistEndBreak(line, line.CONNECTORS[1].ConnectedObject))
405
                {
406
                    object connObj = line.CONNECTORS[1].ConnectedObject;
407
                    if (connObj.GetType() == typeof(Model.Line) &&
408
                        APIDUtils.IsConnectedLine(connObj as Model.Line, line))
409
                        GetConnectedGroupLine(connObj as Model.Line, group, false);
410
                    else if (connObj.GetType() == typeof(Model.Symbol))
411
                    {
412
                        Model.Line connLine = FindOtherLineByRun(line, connObj as Symbol);
413
                        if (connLine != null)
414
                            GetConnectedGroupLine(connLine as Model.Line, group, false);
415
                    }
416
                }
417 53344e2c gaqhf
            }
418
        }
419
        private void GetGroupLinePoints(List<Model.Line> groupLine, List<string> points)
420
        {
421
            for (int i = 0; i < groupLine.Count; i++)
422
            {
423
                Model.Line line = groupLine[i];
424 016701e5 gaqhf
                if (i == 0)
425
                    points.Add(line.Aveva.Start_X + "," + line.Aveva.Start_Y);
426
                else
427
                {
428
                    Model.Line prevLine = groupLine[i - 1];
429
                    if (line.SlopeType == SlopeType.HORIZONTAL &&
430
                        prevLine.SlopeType == SlopeType.VERTICAL)
431
                        points.Add(prevLine.Aveva.End_X + "," + line.Aveva.Start_Y);
432
                    else if (line.SlopeType == SlopeType.VERTICAL &&
433
                        prevLine.SlopeType == SlopeType.HORIZONTAL)
434
                        points.Add(line.Aveva.Start_X + "," + prevLine.Aveva.End_Y);
435
                    else
436
                        points.Add(line.Aveva.Start_X + "," + line.Aveva.Start_Y);
437
                }
438
439 53344e2c gaqhf
                if (i == groupLine.Count - 1)
440
                    points.Add(line.Aveva.End_X + "," + line.Aveva.End_Y);
441
            }
442
        }
443 016701e5 gaqhf
        private bool IsExistEndBreak(object item1, object item2)
444
        {
445
            bool result = false;
446
            if (item1 != null && item2 != null)
447
            {
448
                EndBreak endBreak = document.EndBreaks.Find(x =>
449
            (APIDUtils.FindObjectByUID(document, x.OWNER) == item1 &&
450
            APIDUtils.FindObjectByUID(document, x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE) == item2) ||
451
            (APIDUtils.FindObjectByUID(document, x.OWNER) == item2 &&
452
            APIDUtils.FindObjectByUID(document, x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE) == item1));
453
454
                if (endBreak != null)
455
                    result = true;
456
            }
457
458
            return result;
459
        }
460
        private LineRun FindLineRun(Model.Line line)
461
        {
462
            List<LineRun> allLineRun = new List<LineRun>();
463
            foreach (var item in document.LINENUMBERS)
464
                allLineRun.AddRange(item.RUNS);
465
            foreach (var item in document.TRIMLINES)
466
                allLineRun.AddRange(item.RUNS);
467
468
            return allLineRun.Find(x => x.RUNITEMS.Contains(line));
469
        }
470
        private Model.Line FindOtherLineByRun(Model.Line line, Symbol symbol)
471
        {
472
            Model.Line result = null;
473
            LineRun run = FindLineRun(line);
474
            Connector connector = symbol.CONNECTORS.Find(x =>
475
            x.ConnectedObject != null &&
476
            x.ConnectedObject != line &&
477
            run.RUNITEMS.Contains(x.ConnectedObject) &&
478
            x.ConnectedObject.GetType() == typeof(Model.Line));
479
480
            if (connector != null)
481
                result = connector.ConnectedObject as Model.Line;
482 2d09df82 gaqhf
            
483 016701e5 gaqhf
            return result;
484
        }
485 53344e2c gaqhf
        #endregion
486 9dab7146 gaqhf
487 74a0c9d6 gaqhf
        #region Test Source
488
        public void test()
489
        {
490 14540282 gaqhf
            //InitGUI();
491 9dab7146 gaqhf
            //DrawSignal("SONIC", new List<string>() { "2,100", "100,100" });
492 74a0c9d6 gaqhf
493
            DrawPipe("Main Pipe", new List<string>() { "2,100", "100,100" });
494 73152510 gaqhf
            InsertSymbol("BAVA", 50, 100);
495 9dab7146 gaqhf
            //DrawPipe("Main Pipe", new List<string>() { "2,200", "100,200" });
496 74a0c9d6 gaqhf
497 9dab7146 gaqhf
            //DrawPipe("Sub Pipe", new List<string>() { "50,100", "50,200" });
498 74a0c9d6 gaqhf
        }
499 9dab7146 gaqhf
        public static void TESTStatic()
500 74a0c9d6 gaqhf
        {
501 14540282 gaqhf
            AutoModeling auto = new AutoModeling(null);
502 74a0c9d6 gaqhf
            auto.test();
503
        }
504
        #endregion
505
    }
506 73152510 gaqhf
507
508
    public static class AcDbLinqExtensionMethods
509
    {
510
        /// <summary>
511
        /// Get all references to the given BlockTableRecord, including 
512
        /// references to anonymous dynamic BlockTableRecords.
513
        /// </summary>
514
515
        public static IEnumerable<BlockReference> GetBlockReferences(
516
           this BlockTableRecord btr,
517
           OpenMode mode = OpenMode.ForRead,
518
           bool directOnly = true)
519
        {
520
            if (btr == null)
521
                throw new ArgumentNullException("btr");
522
            var tr = btr.Database.TransactionManager.TopTransaction;
523
            if (tr == null)
524
                throw new InvalidOperationException("No transaction");
525
            var ids = btr.GetBlockReferenceIds(directOnly, true);
526
            int cnt = ids.Count;
527
            for (int i = 0; i < cnt; i++)
528
            {
529
                yield return (BlockReference)
530
                   tr.GetObject(ids[i], mode, false, false);
531
            }
532
            if (btr.IsDynamicBlock)
533
            {
534
                BlockTableRecord btr2 = null;
535
                var blockIds = btr.GetAnonymousBlockIds();
536
                cnt = blockIds.Count;
537
                for (int i = 0; i < cnt; i++)
538
                {
539
                    btr2 = (BlockTableRecord)tr.GetObject(blockIds[i],
540
                       OpenMode.ForRead, false, false);
541
                    ids = btr2.GetBlockReferenceIds(directOnly, true);
542
                    int cnt2 = ids.Count;
543
                    for (int j = 0; j < cnt2; j++)
544
                    {
545
                        yield return (BlockReference)
546
                           tr.GetObject(ids[j], mode, false, false);
547
                    }
548
                }
549
            }
550
        }
551
    }
552 74a0c9d6 gaqhf
}
클립보드 이미지 추가 (최대 크기: 500 MB)