1 """compound of vertices Feature
5 from qtsalome import QMessageBox
6 from salome.shaper import model
7 from salome.shaper import geom
10 class compoundVertices(model.Feature):
11 """Import of Construction points
14 # Feature initializations
17 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
18 model.Feature.__init__(self)
22 """Return Id of the Feature."""
23 return "compoundVertices"
27 """Returns ID of the file select parameter."""
32 """Returns ID of the separator parameter."""
36 """Override Feature.getKind()"""
37 return compoundVertices.ID()
40 # Initialization of the dialog panel
42 def initAttributes(self):
43 """Override Feature.initAttributes()"""
44 # Creating the input argument of the feature
45 self.data().addAttribute(self.FILE_ID(), ModelAPI.ModelAPI_AttributeString_typeId())
46 self.data().addAttribute(self.SEPARATOR_ID(), ModelAPI.ModelAPI_AttributeString_typeId())
52 # Execution of the Import
55 """F.execute() -- execute the Feature"""
56 # Retrieving the user input
57 apath = self.string(self.FILE_ID())
58 aseparator = self.string(self.SEPARATOR_ID()).value()
60 self.separator = aseparator
62 filepath = apath.value()
64 part = model.activeDocument()
66 for feature in self.lfeatures:
67 part.removeFeature(feature.feature())
69 model.removeFolder(self.folder)
71 from os.path import basename
72 filename = basename(filepath)
73 nameRes = "Points_" + filename
75 # Creating the construction points in the current document
78 with open(filepath) as file:
80 coord = line.split(self.separator)
82 #QMessageBox.warning( self, 'Error!', '3D coords waited!' )
84 x = float(coord[0]); y = float(coord[1]); z = float(coord[2]);
85 point = model.addPoint(part, x,y,z); point.execute(True); self.lfeatures.append(point)
86 vertex = model.addVertex(part, [point.result()]); vertex.execute(True); self.lfeatures.append(vertex)
87 lVertices.append(vertex.result())
89 compound = model.addCompound(part, lVertices)
90 compound.execute(True); self.lfeatures.append(compound)
91 compound.result().setName(nameRes)
92 self.folder = model.addFolder(part, self.lfeatures[0], compound)
93 self.folder.setName(nameRes)
96 setError("The file does not exist")
99 """Override Feature.initAttributes().
102 compoundVertices feature is macro: removes itself on the creation transaction