프로젝트

일반

사용자정보

개정판 45af3335

ID45af3335b1fceda6f006a0c3fbe58478ca767658
상위 a836ff3b
하위 cbce7526

조봉훈이(가) 약 2년 전에 추가함

Insert Auxiliary Graphic

Change-Id: Ied5b02bfede0dcb89919d8a355ed936d4f2ca2f5

차이점 보기:

DTI_PID/SPPIDConverter/ConverterDocking.cs
148 148
                            {
149 149
                                modeling.DocumentLabelText = string.Format("Drawing Name : {0} ({1}/{2})", document.DrawingName, i + 1, converterForm.Documents.Count);
150 150
                                modeling.Run();
151

  
152
                                List<string> endLine = new List<string>();
153
                                Placement placement = new Placement();
154
                                LMADataSource dataSource = placement.PIDDataSource;
155
                                
156
                                foreach (var lineNumber in document.LINENUMBERS)
157
                                {
158
                                    foreach (LineRun run in lineNumber.RUNS)
159
                                    {
160
                                        foreach (var item in run.RUNITEMS)
161
                                        {
162
                                            if (item.GetType() == typeof(Line))
163
                                            {
164
                                                Line line = item as Line;
165
                                                if (line != null && !endLine.Contains(line.SPPID.ModelItemId))
166
                                                {
167
                                                    LMModelItem _LMModelItem = dataSource.GetModelItem(line.SPPID.ModelItemId);
168
                                                    if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active")
169
                                                    {
170
                                                        foreach (var attribute in lineNumber.ATTRIBUTES)
171
                                                        {
172
                                                            LineNumberMapping mapping = document.LineNumberMappings.Find(x => x.UID == attribute.UID);
173
                                                            if (mapping != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None" && mapping.SPPIDATTRIBUTENAME == "PlantGroup.Name")
174
                                                            {
175
                                                                LMAAttribute _LMAAttribute = _LMModelItem.Attributes[mapping.SPPIDATTRIBUTENAME];
176
                                                                if (_LMAAttribute != null)
177
                                                                {
178
                                                                    if (DBNull.Value.Equals(_LMAAttribute.get_Value()))
179
                                                                        _LMAAttribute.set_Value(attribute.VALUE);
180
                                                                    else if (_LMAAttribute.get_Value() != attribute.VALUE)
181
                                                                        _LMAAttribute.set_Value(attribute.VALUE);
182
                                                                }
183
                                                            }
184
                                                        }
185
                                                        _LMModelItem.Commit();
186
                                                    }
187
                                                    if (_LMModelItem != null)
188
                                                        ReleaseCOMObjects(_LMModelItem);
189
                                                    endLine.Add(line.SPPID.ModelItemId);
190
                                                }
191
                                            }
192
                                        }
193
                                    }
194
                                }
195

  
196
                                ReleaseCOMObjects(dataSource);
197
                                ReleaseCOMObjects(placement);
198 151
                            }
199 152
                        }
200 153
                    }
......
1142 1095
        #endregion
1143 1096

  
1144 1097
        #region SpecBreak
1098
        //private void btnSpecBreakRelocation_Click(object sender, EventArgs e)
1099
        //{
1100
        //    dynamic dApplication = Interaction.GetObject("", "PIDAutomation.Application");
1101
        //    WrapperApplication wApp = new WrapperApplication(dApplication.Application);
1102
        //    application = wApp.RADApplication;
1103

  
1104
        //    int count = application.ActiveSelectSet.Count;
1105
        //    int dependencyCount = 0;
1106
        //    foreach (var item in application.ActiveSelectSet)
1107
        //        if (item.GetType() == typeof(DependencyObject))
1108
        //            dependencyCount++;
1109

  
1110
        //    if (count > 0 && application.ActiveSelectSet[0].GetType() == typeof(DependencyObject))
1111
        //    {
1112
        //        MessageBox.Show("First selected item is DependencyObject!\r\nPlease move symbol", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
1113
        //        return;
1114
        //    }
1115

  
1116
        //    if ((count == 3 || count == 4) && application.ActiveSelectSet[0].GetType() == typeof(Symbol2d) &&
1117
        //        (dependencyCount == 2 || dependencyCount == 3))
1118
        //    {
1119
        //        Symbol2d symbol = application.ActiveSelectSet[0] as Symbol2d;
1120

  
1121
        //        if (!symbol.DefinitionName.Contains(@"Design\Annotation\Graphics\"))
1122
        //        {
1123
        //            MessageBox.Show("Select SpecBreak!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
1124
        //            return;
1125
        //        }
1126

  
1127
        //        DependencyObject dependency1 = application.ActiveSelectSet[1] as DependencyObject;
1128
        //        DependencyObject dependency2 = application.ActiveSelectSet[2] as DependencyObject;
1129
        //        DependencyObject dependency3 = null;
1130
        //        if (count == 4)
1131
        //            dependency3 = application.ActiveSelectSet[3] as DependencyObject;
1132

  
1133
        //        application.ActiveSelectSet.RemoveAll();
1134
        //        double angle = symbol.Angle;
1135
        //        if (symbol.GetTransform().HasReflection)
1136
        //            angle += Math.PI;
1137

  
1138
        //        double degree = double.NaN;
1139
        //        if (angle > -0.1 && angle < 0.1)
1140
        //            degree = 0;
1141
        //        else if (angle > 1.56 && angle < 1.58)
1142
        //            degree = 90;
1143
        //        else if (angle > 3.13 && angle < 3.15)
1144
        //            degree = 180;
1145
        //        else if (angle > 4.7 && angle < 4.72)
1146
        //            degree = 270;
1147
        //        else if (angle > 6.27 && angle < 6.29)
1148
        //            degree = 0;
1149
        //        else if (angle > -1.58 && angle < -1.56)
1150
        //            degree = 270;
1151
        //        else if (angle > -3.15 && angle < -3.13)
1152
        //            degree = 180;
1153
        //        else
1154
        //            throw new Exception("Check Angle");
1155

  
1156

  
1157
        //        double originX, originY;
1158
        //        symbol.GetOrigin(out originX, out originY);
1159

  
1160
        //        double crossX = 0;
1161
        //        double crossY = 0;
1162
        //        double topX = 0;
1163
        //        double topY = 0;
1164
        //        foreach (var item in symbol.DrawingObjects)
1165
        //        {
1166
        //            Line2d line2d = item as Line2d;
1167
        //            if (line2d != null)
1168
        //            {
1169
        //                double x1, y1, x2, y2;
1170
        //                line2d.GetStartPoint(out x1, out y1);
1171
        //                line2d.GetEndPoint(out x2, out y2);
1172
        //                SlopeType slopeType = SPPIDUtil.CalcSlope(x1, y1, x2, y2, 0.1);
1173

  
1174
        //                if (slopeType == SlopeType.HORIZONTAL)
1175
        //                {
1176
        //                    if (crossY == 0)
1177
        //                        crossY = y1;
1178
        //                    else
1179
        //                        crossY = (crossY + y1) / 2;
1180

  
1181
        //                    switch (degree)
1182
        //                    {
1183
        //                        case 90:
1184
        //                            if (topX == 0)
1185
        //                                topX = Math.Min(x1, x2);
1186
        //                            else
1187
        //                                topX = Math.Min(topX, Math.Min(x1, x2));
1188
        //                            break;
1189
        //                        case 270:
1190
        //                            if (topX == 0)
1191
        //                                topX = Math.Max(x1, x2);
1192
        //                            else
1193
        //                                topX = Math.Max(topX, Math.Max(x1, x2));
1194
        //                            break;
1195
        //                        default:
1196
        //                            break;
1197
        //                    }
1198
        //                }
1199
        //                else if (slopeType == SlopeType.VERTICAL)
1200
        //                {
1201
        //                    if (crossX == 0)
1202
        //                        crossX = x1;
1203
        //                    else
1204
        //                        crossX = (crossX + x1) / 2;
1205

  
1206
        //                    switch (degree)
1207
        //                    {
1208
        //                        case 0:
1209
        //                            if (topY == 0)
1210
        //                                topY = Math.Max(y1, y2);
1211
        //                            else
1212
        //                                topY = Math.Max(topY, Math.Max(y1, y2));
1213
        //                            break;
1214
        //                        case 180:
1215
        //                            if (topY == 0)
1216
        //                                topY = Math.Min(y1, y2);
1217
        //                            else
1218
        //                                topY = Math.Min(topY, Math.Min(y1, y2));
1219
        //                            break;
1220
        //                        default:
1221
        //                            break;
1222
        //                    }
1223
        //                }
1224
        //            }
1225
        //        }
1226
        //        switch (degree)
1227
        //        {
1228
        //            case 0:
1229
        //                crossX = originX;
1230
        //                topX = crossX;
1231
        //                break;
1232
        //            case 90:
1233
        //                crossY = originY;
1234
        //                topY = crossY;
1235
        //                break;
1236
        //            case 180:
1237
        //                crossX = originX;
1238
        //                topX = crossX;
1239
        //                break;
1240
        //            case 270:
1241
        //                crossY = originY;
1242
        //                topY = crossY;
1243
        //                break;
1244
        //            default:
1245
        //                break;
1246
        //        }
1247

  
1248
        //        SpecBreakRelocation(degree, originX, originY, crossX, crossY, topX, topY, dependency1, dependency2, dependency3);
1249
        //        SetSpecBreakParameters(symbol, dependency1, dependency2, degree);
1250
        //    }
1251
        //    else
1252
        //    {
1253
        //        MessageBox.Show("Check Rule!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
1254
        //    }
1255
        //}
1145 1256
        private void btnSpecBreakRelocation_Click(object sender, EventArgs e)
1146 1257
        {
1147 1258
            dynamic dApplication = Interaction.GetObject("", "PIDAutomation.Application");
1148 1259
            WrapperApplication wApp = new WrapperApplication(dApplication.Application);
1149 1260
            application = wApp.RADApplication;
1150 1261

  
1151
            int count = application.ActiveSelectSet.Count;
1152
            int dependencyCount = 0;
1153
            foreach (var item in application.ActiveSelectSet)
1154
                if (item.GetType() == typeof(DependencyObject))
1155
                    dependencyCount++;
1156

  
1157
            if (count > 0 && application.ActiveSelectSet[0].GetType() == typeof(DependencyObject))
1158
            {
1159
                MessageBox.Show("First selected item is DependencyObject!\r\nPlease move symbol", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
1160
                return;
1161
            }
1162

  
1163
            if ((count == 3 || count == 4) && application.ActiveSelectSet[0].GetType() == typeof(Symbol2d) &&
1164
                (dependencyCount == 2 || dependencyCount == 3))
1262
            Ingr.RAD2D.SmartFrame2d borderFrame = application.ActiveDocument.ActiveSheet.SmartFrames2d[0];
1263
            string styleName = borderFrame.Style.Name;
1264
            //
1265
            foreach (var item in application.ActiveDocument.SmartFrame2dStyles)
1165 1266
            {
1166
                Symbol2d symbol = application.ActiveSelectSet[0] as Symbol2d;
1167

  
1168
                if (!symbol.DefinitionName.Contains(@"Design\Annotation\Graphics\"))
1169
                {
1170
                    MessageBox.Show("Select SpecBreak!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
1171
                    return;
1172
                }
1173

  
1174
                DependencyObject dependency1 = application.ActiveSelectSet[1] as DependencyObject;
1175
                DependencyObject dependency2 = application.ActiveSelectSet[2] as DependencyObject;
1176
                DependencyObject dependency3 = null;
1177
                if (count == 4)
1178
                    dependency3 = application.ActiveSelectSet[3] as DependencyObject;
1179

  
1180
                application.ActiveSelectSet.RemoveAll();
1181
                double angle = symbol.Angle;
1182
                if (symbol.GetTransform().HasReflection)
1183
                    angle += Math.PI;
1184

  
1185
                double degree = double.NaN;
1186
                if (angle > -0.1 && angle < 0.1)
1187
                    degree = 0;
1188
                else if (angle > 1.56 && angle < 1.58)
1189
                    degree = 90;
1190
                else if (angle > 3.13 && angle < 3.15)
1191
                    degree = 180;
1192
                else if (angle > 4.7 && angle < 4.72)
1193
                    degree = 270;
1194
                else if (angle > 6.27 && angle < 6.29)
1195
                    degree = 0;
1196
                else if (angle > -1.58 && angle < -1.56)
1197
                    degree = 270;
1198
                else if (angle > -3.15 && angle < -3.13)
1199
                    degree = 180;
1200
                else
1201
                    throw new Exception("Check Angle");
1202

  
1203

  
1204
                double originX, originY;
1205
                symbol.GetOrigin(out originX, out originY);
1206

  
1207
                double crossX = 0;
1208
                double crossY = 0;
1209
                double topX = 0;
1210
                double topY = 0;
1211
                foreach (var item in symbol.DrawingObjects)
1212
                {
1213
                    Line2d line2d = item as Line2d;
1214
                    if (line2d != null)
1215
                    {
1216
                        double x1, y1, x2, y2;
1217
                        line2d.GetStartPoint(out x1, out y1);
1218
                        line2d.GetEndPoint(out x2, out y2);
1219
                        SlopeType slopeType = SPPIDUtil.CalcSlope(x1, y1, x2, y2, 0.1);
1220

  
1221
                        if (slopeType == SlopeType.HORIZONTAL)
1222
                        {
1223
                            if (crossY == 0)
1224
                                crossY = y1;
1225
                            else
1226
                                crossY = (crossY + y1) / 2;
1227

  
1228
                            switch (degree)
1229
                            {
1230
                                case 90:
1231
                                    if (topX == 0)
1232
                                        topX = Math.Min(x1, x2);
1233
                                    else
1234
                                        topX = Math.Min(topX, Math.Min(x1, x2));
1235
                                    break;
1236
                                case 270:
1237
                                    if (topX == 0)
1238
                                        topX = Math.Max(x1, x2);
1239
                                    else
1240
                                        topX = Math.Max(topX, Math.Max(x1, x2));
1241
                                    break;
1242
                                default:
1243
                                    break;
1244
                            }
1245
                        }
1246
                        else if (slopeType == SlopeType.VERTICAL)
1247
                        {
1248
                            if (crossX == 0)
1249
                                crossX = x1;
1250
                            else
1251
                                crossX = (crossX + x1) / 2;
1252

  
1253
                            switch (degree)
1254
                            {
1255
                                case 0:
1256
                                    if (topY == 0)
1257
                                        topY = Math.Max(y1, y2);
1258
                                    else
1259
                                        topY = Math.Max(topY, Math.Max(y1, y2));
1260
                                    break;
1261
                                case 180:
1262
                                    if (topY == 0)
1263
                                        topY = Math.Min(y1, y2);
1264
                                    else
1265
                                        topY = Math.Min(topY, Math.Min(y1, y2));
1266
                                    break;
1267
                                default:
1268
                                    break;
1269
                            }
1270
                        }
1271
                    }
1272
                }
1273
                switch (degree)
1274
                {
1275
                    case 0:
1276
                        crossX = originX;
1277
                        topX = crossX;
1278
                        break;
1279
                    case 90:
1280
                        crossY = originY;
1281
                        topY = crossY;
1282
                        break;
1283
                    case 180:
1284
                        crossX = originX;
1285
                        topX = crossX;
1286
                        break;
1287
                    case 270:
1288
                        crossY = originY;
1289
                        topY = crossY;
1290
                        break;
1291
                    default:
1292
                        break;
1293
                }
1294

  
1295
                SpecBreakRelocation(degree, originX, originY, crossX, crossY, topX, topY, dependency1, dependency2, dependency3);
1296
                SetSpecBreakParameters(symbol, dependency1, dependency2, degree);
1267
                string dd = item.Name;
1297 1268
            }
1298
            else
1269
            foreach (var item in application.ActiveDocument.ActiveSheet.SmartFrames2d)
1299 1270
            {
1300
                MessageBox.Show("Check Rule!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
1271
                var aa = item.Style;
1301 1272
            }
1302 1273
        }
1303 1274
        private void SetSpecBreakParameters(Symbol2d symbol, DependencyObject dependency1, DependencyObject dependency2, double degree)

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)