개정판 c8b025e0
dev issue #1230 : edit properties form
Change-Id: I75ede7e3e639b7dfc7e71e2d123a5f2e47cfe0e5
DTI_PID/APIDConverter/AutoModeling.cs | ||
---|---|---|
8 | 8 |
using System.IO; |
9 | 9 |
using System.Runtime.CompilerServices; |
10 | 10 |
using Microsoft.VisualBasic.CompilerServices; |
11 |
using System.Runtime.InteropServices; |
|
12 |
using System.Threading; |
|
11 | 13 |
|
12 | 14 |
using Autodesk.AutoCAD.ApplicationServices; |
13 | 15 |
using Autodesk.AutoCAD.ApplicationServices.Core; |
... | ... | |
35 | 37 |
{ |
36 | 38 |
public class AutoModeling |
37 | 39 |
{ |
40 |
[DllImport("user32")] |
|
41 |
public static extern int FindWindow(string lpClassName, string lpWindowName); |
|
42 |
|
|
38 | 43 |
public static AutoModeling Running { get; set; } |
39 | 44 |
Model.Document document; |
40 | 45 |
AvevaInfo avevaInfo; |
... | ... | |
231 | 236 |
if (lineNumber != null) |
232 | 237 |
{ |
233 | 238 |
GUIUtils.SetAutoLabelCheck(true); |
239 |
AvevaThread.Run(ThreadType.OkBtnClick, null); |
|
234 | 240 |
break; |
235 | 241 |
} |
236 | 242 |
} |
... | ... | |
244 | 250 |
handle = DrawSignal(line.Aveva.Name, points); |
245 | 251 |
|
246 | 252 |
if (lineNumber != null) |
253 |
{ |
|
247 | 254 |
GUIUtils.SetAutoLabelCheck(false); |
255 |
AvevaThread.Stop(ThreadType.OkBtnClick); |
|
256 |
} |
|
248 | 257 |
|
249 | 258 |
foreach (var item in groupLine) |
250 | 259 |
item.Aveva.Handle = handle; |
... | ... | |
340 | 349 |
} |
341 | 350 |
private void SetLineNumberAttribute(Model.LineNumber lineNumber) |
342 | 351 |
{ |
352 |
Model.Line line = APIDUtils.FindObjectByUID(document, lineNumber.CONNLINE) as Model.Line; |
|
353 |
if (line != null) |
|
354 |
{ |
|
355 |
foreach (Model.Attribute attribute in lineNumber.ATTRIBUTES) |
|
356 |
{ |
|
357 |
AttributeInfo info = avevaInfo.AttributeInfo.Find(x => x.UID == attribute.UID); |
|
358 |
if (info != null) |
|
359 |
{ |
|
360 |
if (info.APID_ATTRIBUTE_TYPE == AvevaAttributeType.PipeAttribute) |
|
361 |
{ |
|
343 | 362 |
|
363 |
} |
|
364 |
} |
|
365 |
} |
|
366 |
} |
|
344 | 367 |
} |
345 | 368 |
private void SetSymbolAttribute(Model.Symbol symbol) |
346 | 369 |
{ |
347 |
foreach (var attribute in symbol.ATTRIBUTES)
|
|
370 |
if (symbol.Aveva.Handle != 0)
|
|
348 | 371 |
{ |
349 |
AttributeInfo info = avevaInfo.AttributeInfo.Find(x => x.UID == attribute.UID);
|
|
350 |
if (info != null)
|
|
372 |
List<Tuple<string, string>> udaDatas = new List<Tuple<string, string>>();
|
|
373 |
foreach (var attribute in symbol.ATTRIBUTES)
|
|
351 | 374 |
{ |
352 |
|
|
375 |
AttributeInfo info = avevaInfo.AttributeInfo.Find(x => x.UID == attribute.UID); |
|
376 |
if (info != null) |
|
377 |
{ |
|
378 |
if (info.APID_ATTRIBUTE_TYPE == AvevaAttributeType.UDA) |
|
379 |
udaDatas.Add(new Tuple<string, string>(info.APID_ATTRIBUTE, attribute.VALUE)); |
|
380 |
} |
|
353 | 381 |
} |
382 |
if (udaDatas.Count > 0) |
|
383 |
SetSymbolUDAAttribute(GetObjectIdByHandle(symbol.Aveva.Handle), udaDatas); |
|
354 | 384 |
} |
355 | 385 |
} |
356 | 386 |
#endregion |
... | ... | |
636 | 666 |
Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; |
637 | 667 |
Database acCurDb = acDoc.Database; |
638 | 668 |
Handle handle = new Handle(lHandle); |
669 |
ObjectId result = ObjectId.Null; |
|
670 |
try |
|
671 |
{ |
|
672 |
result = acCurDb.GetObjectId(false, handle, 0); |
|
673 |
} |
|
674 |
catch (System.Exception ex) |
|
675 |
{ |
|
639 | 676 |
|
640 |
return acCurDb.GetObjectId(false, handle, 0); |
|
677 |
} |
|
678 |
return result; |
|
679 |
} |
|
680 |
private Entity GetEntityByHandle(long handle) |
|
681 |
{ |
|
682 |
Entity entity = null; |
|
683 |
ObjectId objectId = GetObjectIdByHandle(handle); |
|
684 |
if (objectId != ObjectId.Null) |
|
685 |
{ |
|
686 |
Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; |
|
687 |
Database acCurDb = acDoc.Database; |
|
688 |
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) |
|
689 |
{ |
|
690 |
entity = (Entity)acTrans.GetObject(objectId, OpenMode.ForRead); |
|
691 |
acTrans.Commit(); |
|
692 |
} |
|
693 |
} |
|
694 |
|
|
695 |
return entity; |
|
641 | 696 |
} |
642 | 697 |
private void SetBlockReferenceRotation(ObjectId objectId, double rotation) |
643 | 698 |
{ |
... | ... | |
690 | 745 |
} |
691 | 746 |
} |
692 | 747 |
} |
748 |
|
|
749 |
#endregion |
|
750 |
|
|
751 |
#region For Aveva |
|
752 |
private void SetAttributeByAvevaForm(long handle, List<Tuple<string, string>> datas) |
|
753 |
{ |
|
754 |
Entity entity = GetEntityByHandle(handle); |
|
755 |
|
|
756 |
ComponentPropertiesHelper componentPropertiesHelper = new ComponentPropertiesHelper(); |
|
757 |
AvevaThread.Run(ThreadType.AddProperty, datas); |
|
758 |
if (!componentPropertiesHelper.DisplayComponentProperties(entity)) |
|
759 |
AvevaThread.Stop(ThreadType.AddProperty); |
|
760 |
} |
|
693 | 761 |
#endregion |
694 | 762 |
|
695 | 763 |
#region Modeling Utils |
... | ... | |
904 | 972 |
#region Test Source |
905 | 973 |
public void test() |
906 | 974 |
{ |
907 |
//InitGUI(); |
|
908 |
//DrawSignal("SONIC", new List<string>() { "2,100", "100,100" }); |
|
909 |
|
|
910 |
DrawPipe("Main Pipe", new List<string>() { "2,100", "100,100" }, null); |
|
911 |
return; |
|
912 |
Symbol symbol = new Symbol(); |
|
913 |
symbol.Aveva = new AvevaSymbolInfo(); |
|
914 |
symbol.Aveva.Name = "INVB"; |
|
915 |
symbol.Aveva.X = 50; |
|
916 |
symbol.Aveva.Y = 100; |
|
917 |
|
|
918 |
DataRow[] allRows = avevaInfo.AvevaSymbolTable.Select(string.Format("Symbol_Name = '{0}'", symbol.Aveva.Name)); |
|
919 |
if (allRows.Length == 1) |
|
920 |
{ |
|
921 |
DataRow symbolRow = allRows[0]; |
|
922 |
bool bAngle = CheckAngle(symbolRow); |
|
923 |
bool bBalloon = CheckBalloon(symbol); |
|
924 |
bBalloon = false; |
|
925 |
long handle = InsertSymbol(symbol, symbolRow, bAngle, bBalloon); |
|
926 |
} |
|
927 |
|
|
928 |
Hashtable symbolDefinitions = GraphicsUtility.GetSymbolDefinitions(symbol.Aveva.Name); |
|
929 |
string text = symbolDefinitions[SymbolDefinition.symAflowType].ToString().ToUpper(); |
|
930 |
if (int.Parse(symbolDefinitions[SymbolDefinition.symNoOfInsertPoints].ToString()).Equals(2)) |
|
931 |
{ |
|
932 |
bool bIsPromptRotate = true; |
|
933 |
} |
|
934 |
int num = int.Parse(symbolDefinitions[SymbolDefinition.symFixedOrUserDefined].ToString()); |
|
935 | 975 |
|
936 |
AssociateSymbolType eAssosiateSym = AssociateSymbolType.None; |
|
937 |
bool bIsSymbolHasAssociation = GraphicalUtility.FindSymbolHasAssociation(text, ref eAssosiateSym); |
|
938 |
bool bPlaceSimpleBlocks = SymbolCategory.astrSimplePlacedBlocks.Contains(text); |
|
939 |
|
|
940 |
//DrawPipe("Main Pipe", new List<string>() { "2,200", "100,200" }); |
|
941 |
|
|
942 |
//DrawPipe("Sub Pipe", new List<string>() { "50,100", "50,200" }); |
|
943 | 976 |
} |
944 |
public static void TESTStatic(ObjectId objectId)
|
|
977 |
public static void TESTStatic(long handle)
|
|
945 | 978 |
{ |
946 |
// Get the current document and database, and start a transaction |
|
947 |
//Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; |
|
948 |
//Database acCurDb = acDoc.Database; |
|
949 |
//Editor acDocEd = acDoc.Editor; |
|
950 |
|
|
951 |
//using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) |
|
952 |
//{ |
|
953 |
// Entity objDb = (Entity)acTrans.GetObject(objectId, OpenMode.ForWrite); |
|
954 |
// Entity startNodeEntityForPipe = Pipe.GetStartNodeEntityForPipe(objDb); |
|
955 |
|
|
956 |
// //ArrayList arrayList = new ArrayList(); |
|
957 |
// //ArrayList arrayList2 = new ArrayList(); |
|
958 |
// //PIDUtils.VBUtils.GetUserDefineAttributes(startNodeEntityForPipe.ObjectId, ref arrayList, ref arrayList2); |
|
959 |
// //PIDUtils.VBUtils.GetUserDefineAttributes(objDb.ObjectId, ref arrayList, ref arrayList2); |
|
960 |
// //NamedXDataBlock namedXDataBlock = XDataUtilities.GetNamedBlock(objDb, "ReferenceObject"); |
|
961 |
|
|
962 |
// XData xData = XDataUtilities.GetXData<Entity>(objDb); |
|
963 |
// XData xData2 = XDataUtilities.GetXData<Entity>(startNodeEntityForPipe); |
|
964 |
// acTrans.Commit(); |
|
965 |
//} |
|
966 |
|
|
967 |
//PLABFO |
|
979 |
|
|
968 | 980 |
} |
969 | 981 |
#endregion |
970 | 982 |
} |
내보내기 Unified diff