MoocChecker.py 23.4 KB
Newer Older
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
# coding: utf-8
################################################
#
#  MoocChecker.py
#
#  Copyright 2018 Jonathan Wiedemann <contact at freecad-france dot com>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#  MA 02110-1301, USA.
#
#
################################################

__title__="MOOC Workbench"
__author__ = "Jonathan Wiedemann"
__url__ = "http://www.freecadweb.org"

import FreeCAD as app
import FreeCADGui as gui

import math


# for debug purposes
37
38
#DEBUG = True
DEBUG = False
39
40
41
42
43
44
45
46
47

if DEBUG:print("MOOC CHECKER")

def make_result(r):
    ''' make final result from list of result
    to get 1 there must not be 0 in r
    r=[1,1,1,0] => result = 0
    r=[1,1,1,1] => result = 1
    '''
Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
48
    if DEBUG:print(u'r = ', r)
49
50
51
52
53
54
55
    if len(r)>0:
        if 0 in r:
            result = 0
        else:
            result = 1
    else:
        result = 0
Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
56
    if DEBUG:print(u'result = ', result)
Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
57
    if DEBUG:print(u'End check')
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
    return result


def get_document(doc):
    '''get document from name or active doc if None'''
    if type(doc)=='str':
        doc = app.getDocument(doc)
    elif doc is None:
        if document_presence() == 1:
            doc = app.activeDocument()
    return doc

def get_sketch(sketch):
    # TODO: method to get sketch
    if DEBUG:print("TODO: method to get sketch")
    pass


def document_presence(name=None, label=None):
    '''check if there is a specific doc or an active one'''
    r = []
    if name is None and label is None:
        if app.ActiveDocument:
            r.append(1)
        else:
            r.append(0)
    elif name != None and label != None:
        if app.ActiveDocument.Name == name:
            r.append(1)
        else:
            r.append(0)
        if app.ActiveDocument.Label == label:
            r.append(1)
        else:
            r.append(0)
    elif name != None and label is None:
        if app.ActiveDocument.Name == name:
            r.append(1)
        else:
            r.append(0)
    elif name is None and label != None:
        if app.ActiveDocument.label == label:
            r.append(1)
        else:
            r.append(0)

    return make_result(r)


Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
107
108
109
110
111
112
def get_object_by_typeId(doc=None, typeId=None):
    for obj in doc.Objects:
        if obj.TypeId==typeId:
            return obj
            break

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

def document_save(name=None):
    '''check if a doc is saved'''
    r=[]
    if app.ActiveDocument == None:
        r.append(0)
    else:
        if name != None:
            if app.ActiveDocument.Label == name:
                r.append(1)
            else:
                r.append(0)
        else:
            if app.ActiveDocument:
                r.append(1)
    return make_result(r)


def active_workbench(wb):
    '''Check if the active workbench is the good one
    PartDesignWorkbench", "PartWorkbench", "DraftWorkbench", "SketcherWorkbench"
    '''
    r = []
    if gui.activeWorkbench().name() != wb:
        r.append(0)
    else:
        r.append(1)
    return make_result(r)


def label_object(doc=None, obj=None, label_required=None):
    '''check if there is an object with the specific label'''
    r = []
    doc = get_document(doc)
    if doc != None:
        for obj in doc:
            if obj:
                if obj.Label == label_required:
                    r.append(1)
                else:
                    r.append(0)
            else:
                r.append(0)
    return make_result(r)



def body_presence(doc=None):
    '''Check if there is a body in the document'''
    r = []
    doc = get_document(doc)
    if doc != None:
        if len(doc.Objects)>0:
            body_list = []
            for obj in doc.Objects:
                if obj.TypeId == 'PartDesign::Body':
                    body_list.append(obj)
            if len(body_list)>0:
                    r.append(1)
            else:
                r.append(0)
        else:
            r.append(0)
    else:
        r.append(0)
    return make_result(r)

def body_features(body):
    '''Check if the body contains required features'''
    if DEBUG:print(body.OutList)
    pass

185

Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
186
def primitive_presence(doc=None, label=None, typeId=None, dimensions=None, support=None, offset=None):
187
188
189
    '''check the presence of datum plane'''
    '''type :   'PartDesign::SubstractiveCylinder'
                'PartDesign::AdditiveBox' '''
Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
190
    if DEBUG:print(u'Check primitive presence')
191
192
193
194
195
196
197
198
    r=[]
    doc = get_document(doc)
    reference = None
    # if doc and name, get reference by name
    if doc:
        if label != None:
            reference = doc.getObject(label)
        else:
Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
199
            reference = get_object_by_typeId(doc, typeId)
200
201
    if reference:
        if type != None:
Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
202
203
            if DEBUG:print(u'target',typeId,u'actual',reference.TypeId )
            if reference.TypeId == typeId:
204
205
206
207
                r.append(1)
            else:
                r.append(0)
        if dimensions:
Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
208
            if 'Box' in reference.TypeId :
209
210
211
212
213
214
215
216
217
218
219
220
221
                    if dimensions[0] == reference.Length:
                        r.append(1)
                    else:
                        r.append(0)
                    if dimensions[1] == reference.Width:
                        r.append(1)
                    else:
                        r.append(0)
                    if dimensions[2] == reference.Height:
                        r.append(1)
                    else:
                        r.append(0)

Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
222
            if 'Cylinder' in reference.TypeId :
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
                    if dimensions[0] == reference.Radius:
                        r.append(1)
                    else:
                        r.append(0)
                    if dimensions[1] == reference.Height:
                        r.append(1)
                    else:
                        r.append(0)

        if support != None:
            if reference.Support[0][0].Name == support:
                r.append(1)
            else:
                r.append(0)
        if offset != None:
            attachOffset = []
            attachOffset.append(reference.AttachmentOffset.Base.x)
            attachOffset.append(reference.AttachmentOffset.Base.y)
            attachOffset.append(reference.AttachmentOffset.Base.z)
            attachOffset.append(reference.AttachmentOffset.Rotation.Axis.x)
            attachOffset.append(reference.AttachmentOffset.Rotation.Axis.y)
            attachOffset.append(reference.AttachmentOffset.Rotation.Axis.z)
            attachOffset.append(reference.AttachmentOffset.Rotation.Angle)
            if DEBUG:print(attachOffset, offset)
            if offset == attachOffset:
                r.append(1)
            else:
                r.append(0)
    else:
        r.append(0)
    return make_result(r)


def fillet_presence(doc=None, label=None, radius=None):
    '''check fillet presence'''
    r=[]
    doc = get_document(doc)
260
    reference = None
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
    if doc:
        if label != None:
            reference = doc.getObject(label)
        else:
            if DEBUG:print("TODO: make list of fillet")
            pass
    if reference:
        if reference.TypeId == 'PartDesign::Fillet':
            r.append(1)
        else:
            r.append(0)
        if reference.Radius == radius:
            r.append(1)
        else:
            r.append(0)
    return make_result(r)


279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
def datum_plane_presence(doc=None, label=None, support=None, offset=None):
    '''check the presence of datum plane'''
    r=[]
    doc = get_document(doc)
    reference = None
    # if doc and name, get reference by name
    if doc:
        if label != None:
            reference = doc.getObject(label)
        else:
            if DEBUG:print("TODO: make list of datum_plane")
            pass
    if reference:
        r.append(1)
        if support != None:
            if reference.Support[0][0].Name == support:
                r.append(1)
            else:
                r.append(0)
        if offset != None:
            attachOffset = []
            attachOffset.append(reference.AttachmentOffset.Base.x)
            attachOffset.append(reference.AttachmentOffset.Base.y)
            attachOffset.append(reference.AttachmentOffset.Base.z)
            attachOffset.append(reference.AttachmentOffset.Rotation.Axis.x)
            attachOffset.append(reference.AttachmentOffset.Rotation.Axis.y)
            attachOffset.append(reference.AttachmentOffset.Rotation.Axis.z)
            attachOffset.append(reference.AttachmentOffset.Rotation.Angle)
            if DEBUG:print(attachOffset, offset)
            if offset == attachOffset:
                r.append(1)
            else:
                r.append(0)
    else:
        r.append(0)
    if len(r)>0:
        if 0 in r:
            result = 0
        else:
            result = 1
    else:
        result = 0
    return result

def sketch_presence(doc=None, label=None, support=None):
    '''check the presence of sketch'''
    r = []
    doc = get_document(doc)
    sk = None
    if doc:
        if label :
            if len(doc.getObjectsByLabel(label)) > 0:
                sk = doc.getObjectsByLabel(label)[0]
        else:
            sk = []
            for obj in doc.Objects:
                if obj.TypeId == 'Sketcher::SketchObject':
                    sk.append(obj)
    if sk:
        if support:
            if type(sk) is list:
                got_support = False
                for s in sk:
                    if len(s.Support) > 0:
                        if s.Support[0][0].Name == support:
                            got_support = True
                if got_support is True:
                    r.append(1) # got at least one sketch with the right Support
                else:
                    r.append(0) # got at least one sketch but not the right Support
            else:
                if len(sk.Support) > 0:
                    if sk.Support[0][0].Name == support:
                        r.append(1) # got the sketch with the right Support
                    else:
                        r.append(0) # got the sketch but not the right Support
        else:
            r.append(1) # got a sketch
    else:
        r.append(0) # do not got sketch
    make_result(r)
    return make_result(r)

def geometry_presence(doc=None, sketch_label=None, count=None, isclosed=None):
    '''check if the skecth contain the count of geometrie and if the wire is closed'''
    r = []
    doc = get_document(doc)
    sk = None
    if doc:
        if sketch_label :
            if len(doc.getObjectsByLabel(sketch_label)) > 0:
                sk = doc.getObjectsByLabel(sketch_label)[0]
        else:
            sk = []
            for obj in doc.Objects:
                if obj.TypeId == 'Sketcher::SketchObject':
                    sk.append(obj)
    if sk:
        if type(sk) is list:
            for s in sk:
                if s.GeometryCount.__int__() == count:
                    r.append(1)
                    if isclosed == True:
                        if s.Shape.isClosed() == True:
                            r.append(1)
                        else:
                            r.append(0)
                    elif isclosed == False:
                        if s.Shape.isClosed() == False:
                            r.append(1)
                        else:
                            r.append(0)
        else:
            if sk.GeometryCount.__int__() == count:
                r.append(1)
                if isclosed == True:
                    if sk.Shape.isClosed() == True:
                        r.append(1)
                    else:
                        r.append(0)
                elif isclosed == False:
                    if sk.Shape.isClosed() == False:
                        r.append(1)
                    else:
                        r.append(0)
    else:
        r.append(0)
    return make_result(r)


def external_geometry_presence(doc=None, sketch_label=None, count=None):
    '''Check if the skecth contain the count of geometrie and if the wire is closed'''
    r = []
    doc = get_document(doc)
    sk = None
    if doc:
        if sketch_label :
            if len(doc.getObjectsByLabel(sketch_label)) > 0:
                sk = doc.getObjectsByLabel(sketch_label)[0]
        else:
            sk = []
            for obj in doc.Objects:
                if obj.TypeId == 'Sketcher::SketchObject':
                    sk.append(obj)

    if sk:
        externalqty = 0
        external = sk.ExternalGeometry
        for x in external:
            externalqty += len(x[1])
        if externalqty == count:
            r.append(1)
        else:
            r.append(0)
    else:
        r.append(0)
    return make_result(r)

def constraint_presence(doc=None, sketch_label=None, count=None, type=None, value=None):
    '''Check if the skecth contain the count of constraint's type and value'''
    r = []
    doc = get_document(doc)
    sk = None
    if doc:
        if sketch_label :
            if len(doc.getObjectsByLabel(sketch_label)) > 0:
                sk = doc.getObjectsByLabel(sketch_label)[0]
        else:
            sk = []
            for obj in doc.Objects:
                if obj.TypeId == 'Sketcher::SketchObject':
                    sk.append(obj)

    if sk:
        if type != None:
            constraints_list=[]
            for constraint in sk.Constraints:
                if constraint.Type == type:
                    constraints_list.append(constraint) # list of constraint matching type
            if value != None :
                find_value = False
                for constraint in constraints_list:
                    if type == 'Angle':
                        angle = constraint.Value * 180 / math.pi
                        if angle == value:
                            find_value = True
                    else:
                        if constraint.Value == value:
                            find_value = True
                if find_value == True:
                    r.append(1)
                else:
                    r.append(0)
            if len(constraints_list) == count:
                r.append(1)
            else:
                r.append(0)
        else:
            if sk.ConstraintCount.__int__() == count:
                r.append(1)
            else:
                r.append(0)
    else:
        r.append(0)

    return make_result(r)

def pad_presence(doc=None, name=None, type=None, length=None, midplane=None):
    '''check the presence of pad'''
    r=[]
    doc = get_document(doc)
    if DEBUG:print(doc)
    feature = None
    if doc:
        if name != None :
            feature = doc.getObject(name)
        else:
            objs=[]
            for obj in doc.Objects:
                if obj.TypeId == 'PartDesign::Pad':
                    objs.append(obj)
            if len(objs)>0:
                feature=objs[0]
    if feature:
        r.append(1)
        if type != None:
            if feature.Type == str(type):
                r.append(1)
            else:
                r.append(0)
        if length != None:
            if feature.Length.Value == length:
                r.append(1)
            else:
                r.append(0)
        if midplane != None:
            if feature.Midplane == midplane:
                r.append(1)
            else:
                r.append(0)
    else:
        r.append(0)

    return make_result(r)

def pocket_presence(doc=None, name=None, type=None, length=None, midplane=None, reversed=None):
    '''check the presence of pocket'''
    r=[]
    doc = get_document(doc)
    feature = None
    features_list = None
    if doc:
        if name != None :
            feature = doc.getObject(name)
        else:
            features_list = []
            for obj in doc.Objects:
                if obj.TypeId == 'PartDesign::Pocket':
                    features_list.append(obj)

    if feature:
        r.append(1)
        if type != None:
            if feature.Type == str(type):
                r.append(1)
            else:
                r.append(0)
        if length != None:
            if feature.Length.Value == length:
                r.append(1)
            else:
                r.append(0)
        if midplane != None:
            if feature.Midplane == midplane:
                r.append(1)
            else:
                r.append(0)
        if reversed != None:
            if feature.Reversed == reversed:
                r.append(1)
            else:
                r.append(0)

    elif features_list:
        r.append(1)
        for feature in features_list:
            got_it = []
            if type != None:
                if feature.Type == str(type):
                    got_it.append(1)
                else:
                    got_it.append(0)
            if length != None:
                if feature.Length.Value == length:
                    got_it.append(1)
                else:
                    got_it.append(0)
            if midplane != None:
                if feature.Midplane == midplane:
                    got_it.append(1)
                else:
                    got_it.append(0)
            if reversed != None:
                if feature.Reversed == reversed:
                    got_it.append(1)
                else:
                    got_it.append(0)
            if not 0 in got_it:
                r.append(1)

    else:
        r.append(0)

    return make_result(r)

def revolution_presence(doc=None):
    '''check the presence of revolution'''
    r=[]
    doc = get_document(doc)
    for obj in doc.Objects:
        if obj.TypeId == 'PartDesign::Revolution':
            r.append(1)
    return make_result(r)

def groove_presence(doc=None):
    '''check the presence of groove'''
    r=[]
    doc = get_document(doc)
    for obj in doc.Objects:
        if obj.TypeId == 'PartDesign::Groove':
            r.append(1)
    return make_result(r)

def polar_pattern_presence(doc=None, name=None, reversed=None, angle=None, occurrences=None, axis=None):
    '''check the presence of polar pattern'''
    r=[]
    doc = get_document(doc)
    feature = None
    if app.ActiveDocument:
        doc = app.ActiveDocument
        if name != None :
            feature = doc.getObject(name)
        else:
            objs=[]
            for obj in doc.Objects:
                if obj.TypeId == 'PartDesign::PolarPattern':
                    objs.append(obj)
            if len(objs)>0:
                feature=objs[0]
        if feature:
            if reversed:
                if feature.Reversed == reversed:
                    r.append(1)
                else:
                    r.append(0)
            if angle:
                if feature.Angle == angle:
                    r.append(1)
                else:
                    r.append(0)
            if occurrences:
                if feature.Occurrences == occurrences:
                    r.append(1)
                else:
                    r.append(0)
            if axis:
                if feature.Axis[1][0] == axis:
                    r.append(1)
                else:
                    r.append(0)
        else:
            r.append(0)
    else:
        r.append(0)
    return make_result(r)

def linear_pattern_presence(doc=None):
    '''check the presence of linear pattern'''
    r=[]
    doc = get_document(doc)
    for obj in doc.Objects:
        if obj.TypeId == 'PartDesign::LinearPattern':
            r.append(1)
    return make_result(r)

def mirrored_pattern_presence(doc=None, name=None, plane_name=None, plane_axis=None, bf_name=None):
    '''check the presence of mirrored pattern'''
    r=[]
    doc = get_document(doc)
    if app.ActiveDocument:
        doc = app.ActiveDocument
        if name != None :
            feature = doc.getObject(name)
        else:
            objs=[]
            for obj in doc.Objects:
                if obj.TypeId == 'PartDesign::Mirrored':
                    objs.append(obj)
            if len(objs)>0:
                feature=objs[0]
        if feature:
            r.append(1)
            if plane_name != None:
                if feature.MirrorPlane[0].Name == plane_name:
                    r.append(1)
                else:
                    r.append(0)
            if plane_axis != None:
                if feature.MirrorPlane[1][0] == plane_axis:
                    r.append(1)
                else:
                    r.append(0)
            if bf_name != None:
                if feature.BaseFeature.Name == bf_name:
                    r.append(1)
                else:
                    r.append(0)
        else:
            r.append(0)
    else:
        r.append(0)
    if len(r)>0:
        if 0 in r:
            result = 0
        else:
            result = 1
    else:
        result = 0
    return result

Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
709
def boundbox_dimensions(doc=None, name=None, typeId=None, x=None, y=None, z=None):
710
711
712
713
714
715
    '''Check the length's dimensions of boundbox'''
    r = []
    doc = get_document(doc)
    features_list = []
    if doc:
        for feature in doc.Objects:
Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
716
717
            if typeId:
                if feature.TypeId == typeId:
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
                    features_list.append(feature)
            else:
                features_list.append(feaure)
    if features_list:
        got_it = 0
        for feature in features_list:
            if not feature.Shape.isNull():
                bb_lengths = [ round(feature.Shape.BoundBox.XLength,2), round(feature.Shape.BoundBox.YLength,2), round(feature.Shape.BoundBox.ZLength,2) ]
                dim_count = 0
                if x in bb_lengths:
                    bb_lengths.remove(x)
                    dim_count += 1
                if y in bb_lengths:
                    bb_lengths.remove(y)
                    dim_count += 1
                if z in bb_lengths:
                    bb_lengths.remove(z)
                    dim_count += 1
                if dim_count == 3:
                    got_it = 1
        if got_it == 1:
            r.append(1)
        else:
            r.append(0)
    else:
        r.append(0)
    return make_result(r)

Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
746
def volume(doc=None, name=None, typeId=None, target=None):
747
    '''Check the project volume'''
Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
748
    if DEBUG:print('Check volume')
749
750
751
752
753
    r=[]
    doc = get_document(doc)
    features_list = []
    if doc:
        for feature in doc.Objects:
Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
754
755
            if typeId:
                if feature.TypeId == typeId:
756
757
758
                    features_list.append(feature)
            else:
                features_list.append(feaure)
Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
759
    if features_list and target:
760
761
762
        got_it = 0
        for feature in features_list:
            if not feature.Shape.isNull():
Jonathan Wiedemann's avatar
Jonathan Wiedemann committed
763
764
765
766
                if DEBUG:print('actual volume is : ', feature.Shape.Volume)
                if DEBUG:print('target volume is between : ', target - 10, u'and' , target + 10)
                if (target - 10) < feature.Shape.Volume < (target + 10):
                #if round(target,0) == round(feature.Shape.Volume,0):
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
                    got_it = 1
        if got_it == 1:
            r.append(1)
        else:
            r.append(0)
    else:
        r.append(0)
    return make_result(r)



def navigation_style(style):
    '''Check navigation style'''
    param = app.ParamGet("User parameter:BaseApp/Preferences/View")
    nav = param.GetString('NavigationStyle')
    if nav != style:
783
        result = 0
784
    else:
785
        result = 1
786
    return result