-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyr-ExportBomlink.mcr
266 lines (211 loc) · 6.75 KB
/
Myr-ExportBomlink.mcr
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#Version 8
#BeginDescription
Last modified: OBOS (Oscar Ragnerby)
This tsl will run neccesary tools for the bomlink to work.
2020-03-24 - 1.0 - Pilot
2020-03-26 - 1.1 - Bomlink export based on project settings
2020-04-08 - 1.2 - CNC Exporter is started instead of running through exportrunner
2020-05-05 - 1.3 - Tsl is executed in the correct order
2020-05-07 - 1.4 - ExportRunner
#End
#Type O
#NumBeamsReq 0
#NumPointsGrip 0
#DxaOut 1
#ImplInsert 1
#FileState 1
#MajorVersion 1
#MinorVersion 4
#KeyWords
#BeginContents
/******************************************************
<summary Lang=en>
This tsl will call necessary tools for bomlink
TSL:
- HSB_E-ResetZoneOutlines
- Myr-MapModules
- Myr-AttachPS
- ExportRunner (Tsl that calls the export)
</summary>
<insert>
Tsl will pickup all entities in model
</insert>
<remark Lang=en>
</remark>
<history>
OR - 1.0 - 20-03-24 - Pilot version
OR - 2020-03-26 - 1.1 - Bomlink export based on project settings
OR - 2020-04-08 - 1.2 - CNC Exporter is started instead of running through exportrunner
OR - 2020-05-05 - 1.3 - Tsl is executed in the correct order
OR - 2020-05-07 - 1.4 - ExportRunner
</history>
******************************************************/
double dEps = Unit(0.1, "mm");
//Catalogue information on the exportss
String sFileLocation = _kPathHsbCompany+"\\TSL";
String sFileName = "ExportBomlinkCatalogue.xml";
String sFullPath = sFileLocation + "\\" + sFileName;
//Read this into a local map
Map mapExports;
int bMapIsRead = mapExports.readFromXmlFile(sFullPath);
if( !bMapIsRead ){
reportWarning(TN("|The following file is missing:|")+"\n"+sFullPath);
eraseInstance();
return;
}
String bomlinkProjects[] = {"OBOS Planelement", "OBOS Volym"};
String bomlinkExports[] = {"Bomlink Exporter", "Bomlink Exporter Volym"};
String bomlinkExport;
String sBOMLinkProject;
String categories[] ={ "Element Filter", "Export"};
Map mpProjectSettings=subMapXProject("HSB_PROJECTSETTINGS");
if(mpProjectSettings.length()<1)
{
reportNotice("\nPlease set project settings first and then run this application again");
eraseInstance();
return;
}
else
{
sBOMLinkProject=mpProjectSettings.getString("BOMLINKPROJECT");
}
if (sBOMLinkProject=="")
{
reportNotice("\nBOMLink Project name not found. Please set project settings first and then run this application again");
eraseInstance();
return;
}
if(bomlinkProjects.find(sBOMLinkProject, -1) == -1)
{
reportNotice("\nBOMLink Project name not found. Please set project settings first and then run this application again");
eraseInstance();
return;
}
if(bomlinkProjects.find(sBOMLinkProject, -1) == -1)
{
reportNotice("\nExport for selected project not found. Please select a valid project in project settings first and then run this application again");
eraseInstance();
return;
}else
{
bomlinkExport = bomlinkExports[bomlinkProjects.find(sBOMLinkProject, -1)];
}
String tslOnExport[0];
if(mapExports.hasMap(bomlinkExport))
{
Map mapExport = mapExports.getMap(bomlinkExport);
tslOnExport = mapExport.getString("Exports").tokenize(";");
}
String elementFilterCatalogNames[] = TslInst().getListOfCatalogNames("hsbElementFilter");
elementFilterCatalogNames.insertAt(0, T("|Do not use an element filter|"));
PropString elementFilter(0, elementFilterCatalogNames, T("|Element filter catalog|"));
elementFilter.setDescription(T("|Sets the element filter to use.|"));
elementFilter.setCategory(categories[0]);
// Set properties if inserted with an execute key
String arSCatalogNames[] = TslInst().getListOfCatalogNames(scriptName());
if( _bOnDbCreated && arSCatalogNames.find(_kExecuteKey) != -1 )
setPropValuesFromCatalog(_kExecuteKey);
if( _bOnInsert ){
Entity arEntSelected[0];
// Entity entities[]=Group().collectEntities(true, Element(), _kModel);
PrEntity ssE(T("Select a set of elements"), Element());
if (ssE.go())
_Element.append(ssE.elementSet());
if (_Element.length() == 0)
{
reportNotice(TN("|No Elements found|"));
eraseInstance();
return;
}
for( int i=0;i<_Element.length();i++ ){
Entity ent = _Element[i];
if(ent.bIsKindOf(ElementMulti()))
continue;
Element el = (Element)ent;
Group grpElement = el.elementGroup();
// Element entities need to be collected unless we are selecting entities in which case
// if only an element is selected then that is what we will export.
if( el.bIsValid()){
Entity arEntEl[] = grpElement.collectEntities(true, Entity(), _kModelSpace);
_Entity.append(arEntEl);
}
}
// Apply collection of tsl on the elements
for (int s = 0; s < tslOnExport.length(); s++)
{
String strScriptName;
String strCatalogName;
String exportVal = tslOnExport[s].tokenize(":");
if (exportVal.length() > 0)
{
strScriptName = tslOnExport[s].token(0, ":");
strCatalogName = tslOnExport[s].token(1, ":");
}else
{
strScriptName = tslOnExport[s];
strCatalogName = "";
}
Map mapTsl;
Vector3d vecUcsX(1, 0, 0);
Vector3d vecUcsY(0, 1, 0);
Beam lstBeams[0];
Point3d lstPoints[0];
int lstPropInt[0];
double lstPropDouble[0];
String lstPropString[0];
TslInst tslNew;
tslNew.dbCreate(strScriptName, vecUcsX, vecUcsY, lstBeams, _Entity, lstPoints, strCatalogName, FALSE, Map() , "", "OnDbCreated");
// reportNotice(TN("|Tsl " + s + " " + strScriptName + " inserted|"));
}
ModelMapComposeSettings mmFlags;
mmFlags.addSolidInfo(TRUE); // default FALSE
mmFlags.addAnalysedToolInfo(TRUE); // default FALSE
mmFlags.addElemToolInfo(TRUE); // default FALSE
mmFlags.addConstructionToolInfo(TRUE); // default FALSE
mmFlags.addHardwareInfo(TRUE); // default FALSE
mmFlags.addRoofplanesAboveWallsAndRoofSectionsForRoofs(TRUE); // default FALSE
mmFlags.addCollectionDefinitions(TRUE); // default FALSE
String strDestinationFolder = _kPathDwg;
Map mpProjectInfoOverwrite;
int bOk = false;
// reportNotice(TN("|Bomlink Export|"));
if( _Entity.length() > 0 ){
bOk = ModelMap().callExporter(mmFlags, mpProjectInfoOverwrite, _Entity, bomlinkExport, strDestinationFolder);
}
if (!bOk)
reportMessage("\nTsl::callExporter failed.");
}
//Call cncexporter for user to select
// set some export flags
//pushCommandOnCommandStack("HSB_CNCEXPORTER");
eraseInstance();
return;
#End
#BeginThumbnail
#End
#BeginMapX
<?xml version="1.0" encoding="utf-16"?>
<Hsb_Map>
<lst nm="TslIDESettings">
<lst nm="HOSTSETTINGS">
<dbl nm="PREVIEWTEXTHEIGHT" ut="L" vl="1" />
</lst>
<lst nm="{E1BE2767-6E4B-4299-BBF2-FB3E14445A54}">
<lst nm="BREAKPOINTS" />
</lst>
</lst>
<lst nm="TslInfo">
<lst nm="TSLINFO">
<lst nm="TSLINFO">
<lst nm="TSLINFO">
<lst nm="TSLINFO">
<lst nm="TSLINFO" />
</lst>
</lst>
</lst>
</lst>
</lst>
<unit ut="L" uv="millimeter" />
<unit ut="A" uv="radian" />
</Hsb_Map>
#End