"""Returns ID of the file select parameter."""
return "file_path"
+ @staticmethod
+ def SEPARATOR_ID():
+ """Returns ID of the separator parameter."""
+ return "separator"
+
def getKind(self):
"""Override Feature.getKind()"""
return compoundVertices.ID()
"""Override Feature.initAttributes()"""
# Creating the input argument of the feature
self.data().addAttribute(self.FILE_ID(), ModelAPI.ModelAPI_AttributeString_typeId())
+ self.data().addAttribute(self.SEPARATOR_ID(), ModelAPI.ModelAPI_AttributeString_typeId())
+
+ self.lfeatures = []
+ self.folder = None
+ self.separator = " "
# Execution of the Import
"""F.execute() -- execute the Feature"""
# Retrieving the user input
apath = self.string(self.FILE_ID())
+ aseparator = self.string(self.SEPARATOR_ID()).value()
+ if aseparator:
+ self.separator = aseparator
+
filepath = apath.value()
- print("filepath : ", filepath)
if filepath != "" :
-
+ part = model.activeDocument()
+ if self.lfeatures :
+ for feature in self.lfeatures:
+ part.removeFeature(feature.feature())
+ self.lfeatures = []
+ #part.removeFeature(self.folder.feature())
+
from os.path import basename
filename = basename(filepath)
- print("filename : ", filename)
+ nameRes = "Points_" + filename
# Creating the construction points in the current document
- part = model.activeDocument()
lVertices = []
- startPoint = None
-
with open(filepath) as file:
for line in file:
- coord = line.split(' ')
+ coord = line.split(self.separator)
x = float(coord[0]); y = float(coord[1]); z = float(coord[2]);
- point = model.addPoint(part, x,y,z); point.execute(True)
- if startPoint == None : startPoint = point
- vertex = model.addVertex(part, [point.result()]); vertex.execute(True)
+ point = model.addPoint(part, x,y,z); point.execute(True); self.lfeatures.append(point)
+ vertex = model.addVertex(part, [point.result()]); vertex.execute(True); self.lfeatures.append(vertex)
lVertices.append(vertex.result())
file.close()
compound = model.addCompound(part, lVertices)
- compound.execute(True)
- folder = model.addFolder(part, startPoint, compound)
- folder.setName(filename)
+ compound.execute(True); self.lfeatures.append(compound)
+ compound.result().setName(nameRes)
+ self.folder = model.addFolder(part, self.lfeatures[0], compound)
+ self.folder.setName(nameRes)
return
setError("The file does not exist")
compoundVertices feature is macro: removes itself on the creation transaction
finish.
"""
- return True
+ return True