1 """compound of vertices Feature
5 from salome.shaper import model
6 from salome.shaper import geom
9 class compoundVertices(model.Feature):
10 """Import of Construction points
13 # Feature initializations
16 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
17 model.Feature.__init__(self)
21 """Return Id of the Feature."""
22 return "compoundVertices"
26 """Returns ID of the file select parameter."""
31 """Returns ID of the separator parameter."""
35 """Override Feature.getKind()"""
36 return compoundVertices.ID()
39 # Initialization of the dialog panel
41 def initAttributes(self):
42 """Override Feature.initAttributes()"""
43 # Creating the input argument of the feature
44 self.data().addAttribute(self.FILE_ID(), ModelAPI.ModelAPI_AttributeString_typeId())
45 self.data().addAttribute(self.SEPARATOR_ID(), ModelAPI.ModelAPI_AttributeString_typeId())
51 # Execution of the Import
54 """F.execute() -- execute the Feature"""
55 # Retrieving the user input
56 apath = self.string(self.FILE_ID())
57 aseparator = self.string(self.SEPARATOR_ID()).value()
59 self.separator = aseparator
61 filepath = apath.value()
63 part = model.activeDocument()
65 for feature in self.lfeatures:
66 part.removeFeature(feature.feature())
68 model.removeFolder(self.folder)
70 from os.path import basename
71 filename = basename(filepath)
72 nameRes = "Points_" + filename
74 # Creating the construction points in the current document
77 with open(filepath) as file:
79 coord = line.split(self.separator)
82 x = float(coord[0]); y = float(coord[1]); z = float(coord[2]);
83 point = model.addPoint(part, x,y,z); point.execute(True); self.lfeatures.append(point)
84 #vertex = model.addVertex(part, [point.result()]); vertex.execute(True); self.lfeatures.append(vertex)
85 lVertices.append(point.result())
87 compound = model.addCompound(part, lVertices)
88 compound.execute(True); self.lfeatures.append(compound)
89 compound.result().setName(nameRes)
90 self.folder = model.addFolder(part, self.lfeatures[0], compound)
91 self.folder.setName(nameRes)
94 setError("The file does not exist")
97 """Override Feature.initAttributes().
100 compoundVertices feature is macro: removes itself on the creation transaction