1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
\r
3 <!-- hennerik CVSweb $Revision$ -->
\r
4 <TITLE>Example</TITLE></HEAD>
\r
5 <BODY BGCOLOR="#eeeeee">
\r
6 <HR noshade><PRE>#% Check methods : %
\r
7 SALOMEDS methods : RemoveAttribute, FindOrCreateAttribute, NewStudy, GetAllAttributes, NewCommand, CommitCommand, AbortCommand, NewComponent%
\r
9 batchmode_geompy.myBuilder._set_UndoLimit(20)
\r
11 batchmode_geompy.myBuilder.NewCommand()
\r
12 child = batchmode_geompy.myBuilder.NewObject(batchmode_geompy.father)
\r
13 batchmode_geompy.myBuilder.CommitCommand()
\r
15 batchmode_geompy.myBuilder.NewCommand()
\r
16 #==========================================================
\r
17 # create AttributeSequenceOfReal
\r
18 #==========================================================
\r
19 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child, "AttributeSequenceOfReal")
\r
21 raise RuntimeError, "Can't create AttributeSequenceOfReal attribute"
\r
22 A = A._narrow(SALOMEDS.AttributeSequenceOfReal)
\r
24 raise RuntimeError, "_narrow returns None instead of AttributeSequenceOfReal pointer"
\r
30 batchmode_geompy.myBuilder.CommitCommand()
\r
33 batchmode_geompy.myBuilder.NewCommand()
\r
34 #==========================================================
\r
35 # create AttributeInteger
\r
36 #==========================================================
\r
37 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child, "AttributeInteger")
\r
39 raise RuntimeError, "Can't create AttributeInteger attribute"
\r
40 A = A._narrow(SALOMEDS.AttributeInteger)
\r
43 if A.Value() != 1000000:
\r
44 raise RuntimeError, "Error : wrong value of AttributeInteger"
\r
46 batchmode_geompy.myBuilder.CommitCommand()
\r
48 batchmode_geompy.myBuilder.NewCommand() #===================
\r
49 # create AttributeName
\r
50 #===========================================================
\r
51 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child, "AttributeName")
\r
53 raise RuntimeError, "Can't create AttributeName attribute"
\r
54 A = A._narrow(SALOMEDS.AttributeName)
\r
57 raise RuntimeError, "Can't create AttributeName attribute"
\r
58 A.SetValue("AttributesTesting")
\r
60 if A.Value() != "AttributesTesting":
\r
61 print "Wrong value of AttributeName"
\r
63 batchmode_geompy.myBuilder.CommitCommand()
\r
65 batchmode_geompy.myBuilder.NewCommand() #===================
\r
66 # create AttributeComment
\r
67 #===========================================================
\r
68 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child, "AttributeComment")
\r
70 raise RuntimeError, "Can't create AttributeComment attribute"
\r
71 A = A._narrow(SALOMEDS.AttributeComment)
\r
74 raise RuntimeError, "Can't create AttributeComment attribute"
\r
76 A.SetValue("GEOM")
\r
78 batchmode_geompy.myBuilder.AbortCommand()
\r
80 batchmode_geompy.myBuilder.NewCommand() #===================
\r
81 # create AttributePersistentRef
\r
82 #===========================================================
\r
83 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child, "AttributePersistentRef")
\r
85 raise RuntimeError, "Can't create AttributePersistentRef attribute"
\r
86 A = A._narrow(SALOMEDS.AttributePersistentRef)
\r
89 raise RuntimeError, "Can't create AttributePersistentRef attribute"
\r
91 A.SetValue("/tmp/test;1")
\r
92 batchmode_geompy.myBuilder.CommitCommand()
\r
94 batchmode_geompy.myBuilder.NewCommand() #===================================
\r
95 # create AttributeDrawable
\r
96 #===========================================================
\r
97 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child, "AttributeDrawable")
\r
99 raise RuntimeError, "Can't create AttributeDrawable attribute"
\r
100 A = A._narrow(SALOMEDS.AttributeDrawable)
\r
103 raise RuntimeError, "Can't create AttributeDrawable attribute"
\r
107 if A.IsDrawable() == 0:
\r
108 "Error: wrong value of AttributeDrawable"
\r
109 batchmode_geompy.myBuilder.CommitCommand()
\r
113 batchmode_geompy.myBuilder.NewCommand() #===================
\r
114 # create AttributeSelectable
\r
115 #===========================================================
\r
116 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child, "AttributeSelectable")
\r
118 raise RuntimeError, "Can't create AttributeSelectable attribute"
\r
119 A = A._narrow(SALOMEDS.AttributeSelectable)
\r
122 raise RuntimeError, "Can't create AttributeSelectable attribute"
\r
126 if A.IsSelectable() == 0:
\r
127 "Error: wrong value of AttributeSelectable"
\r
128 batchmode_geompy.myBuilder.CommitCommand()
\r
131 batchmode_geompy.myBuilder.NewCommand() #===================
\r
132 #===========================================================
\r
133 batchmode_geompy.myBuilder.RemoveAttribute(child,"AttributeSelectable")
\r
134 batchmode_geompy.myBuilder.CommitCommand()
\r
136 # Control the attributes
\r
137 #===========================================================
\r
139 res, A = batchmode_geompy.myBuilder.FindAttribute(child, "AttributeComment")
\r
140 print "res = ", res
\r
142 print " AttributeComment was found"
\r
144 print " AttributeComment is not found. It's correct"
\r
148 attributes = child.GetAllAttributes()
\r
150 length = len(attributes)
\r
152 print "Attributes number = ", length
\r
154 for i in range(0, length) :
\r
155 attr = attributes[i]
\r
156 if attr is None :
\r
157 print i,"None item of object attributes list"
\r
160 raise RuntimeError, "Wrong number of attributes"
\r