-
Notifications
You must be signed in to change notification settings - Fork 5
/
1SmartCopy.js
129 lines (91 loc) · 3.81 KB
/
1SmartCopy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
try
{
console.clear()
var ms=window.MyScripts;
//FuncContainer();
//easyeda.extension.quickScript();
//ms.ScriptWindowReSize();
ms.ShowTimeBegin();
ms.zoom_750();
var json= ms.GetJson();
if (ms.Has(json,"schlib")) console.log("schlib json",json);
if (ms.Has(json,"FOOTPRINT")) console.log("FOOTPRINT json",json);
ms.json = json;
ms.SmartSelect = SmartSelect;
function SmartSelect(json)
{
var SelectedIds = api('getSelectedIds').split(",");
SelectedIds.forEach(function(currentValue,index,array) {array[index] = array[index].replace(/fake-[\d]+/,'');});
SelectedIds = ms.Unique(SelectedIds);
if (ms.Has(json,"schlib")) SelectedIds.sort(ms.SchCompare);
if (ms.Has(json,"FOOTPRINT")) SelectedIds.sort(ms.PcbCompare);
console.log("SelectedIds ",SelectedIds);
api('select',{ids: SelectedIds});
// SelectedIds = api('getSelectedIds').split(",");
}
ms.SmartCopy = SmartCopy;
function SmartCopy(json)
{
debugger;
ms.SmartSelect(json);
ms.a().callCommand.hooks["copy"]();
if (ms.Has(json, "schlib"))
{
ms.LastCopiedSchIds = [];
ms.LastCopiedSchObj = [];
}
if (ms.Has(json, "FOOTPRINT"))
{
ms.LastCopiedPcbIds = [];
ms.LastCopiedPcbObj = [];
ms.footprint_before_paste = [];
ms.footprint_before_pasteObj = [];
}
}
//////////////////////////////////////////////////////////////////////////////////////
ms.SmartCopy(ms.json);
//ms.SmartPaste(ms.json);
//SmartRenameLastCopied();
//SmartReconnectTracks();
console.log("LastCopiedSchObj",ms.LastCopiedSchObj);
console.log("LastCopiedPcbObj",ms.LastCopiedPcbObj);
//var PadCoor=[];
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
if(Has(json,"schlib"))
{
document.MySchJson=json;
json.itemOrder.sort(SchCompare);
ShowTime('begin');
//download(JSON.stringify(json,0,2), 'schlib' + Date()+'.json', 'text/plain');
Renumber(json); ShowTime('Renumber');
json=SortAndReplaceJsonId(json);ShowTime('SortAndReplaceJsonId');
//download(JSON.stringify(json,0,2), 'schlib' + Date()+'.json', 'text/plain');
json.itemOrder.sort(SchCompareInv);
//api('applySource', {source: json, createNew: !true}); ShowTime('applySource');
}
*/
//console.log('APIRenameTrack',APIRenameTrack);
//console.log('APIRenameLib',APIRenameLib);
//console.log('APIGetShape',APIGetShape);
//console.log('CheckCoor',CheckCoor);
//console.log('document.MySchJson',document.MySchJson)
//console.log('document.MyPcbJson',document.MyPcbJson)
//console.log('SelectedIds',SelectedIds)
//download(JSON.stringify(d1,0,2), 'dvw[1].json', 'text/plain');
}
catch(e) { alert('Error: ' + e.name + ":" + e.message + "\n" + e.stack);}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//console.log('getTabIFrame',TabIFrame);
//console.dir(TabIFrame);
//alert(JSON.stringify(api('getShape', {id:'gge10'}),0,2));
//var shape=a.callCommand.apply(a, ["gJsonCache",[{id:'gge10'}]]);
//var shape=a.callCommand.hooks["gJsonCache"].apply(null, [{id:'gge10'}]);
//var shape=a.callCommand.hooks["gJsonCache"]({id:'gge10'});
//alert(JSON.stringify(shape,0,2));
//alert(JSON.stringify( a.callCommand.hooks["getJsonCache"]() ,0,2));
//alert(JSON.stringify( a.callCommand.hooks["getConfig"]() ,0,2));
//alert(JSON.stringify( a.callCommand.hooks["getActiveElement"]('gge8') ,0,2));
//alert(JSON.stringify( a.callCommand.hooks["getElementInfoById"]('gge62') ,0,2));
//alert(JSON.stringify( a.callCommand.hooks["updateBindId"]('gge62') ,0,2));
//alert(JSON.stringify( a.callCommand.hooks["updateJsonCache"]('gge62') ,0,2));