Split placeSchematic from importSchematic for already-loaded schematics
This commit is contained in:
parent
4ed9d10174
commit
4aff8bbf58
@ -1104,10 +1104,12 @@ class EditorSession(QtCore.QObject):
|
|||||||
def importSchematic(self, filename, importPos=None):
|
def importSchematic(self, filename, importPos=None):
|
||||||
try:
|
try:
|
||||||
schematic = WorldEditor(filename, readonly=True)
|
schematic = WorldEditor(filename, readonly=True)
|
||||||
|
self.placeSchematic(schematic, importPos, os.path.basename(filename))
|
||||||
except UnknownFormatError:
|
except UnknownFormatError:
|
||||||
log.exception("Unknown format.")
|
log.exception("Unknown format.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def placeSchematic(self, schematic, importPos=None, name="Unknown"):
|
||||||
ray = self.editorTab.currentView().rayAtCenter()
|
ray = self.editorTab.currentView().rayAtCenter()
|
||||||
if importPos is not None:
|
if importPos is not None:
|
||||||
pos = importPos
|
pos = importPos
|
||||||
@ -1121,12 +1123,11 @@ class EditorSession(QtCore.QObject):
|
|||||||
else:
|
else:
|
||||||
pos = pos + face.vector
|
pos = pos + face.vector
|
||||||
|
|
||||||
name = os.path.basename(filename)
|
|
||||||
dim = schematic.getDimension()
|
dim = schematic.getDimension()
|
||||||
center = dim.bounds.center
|
center = dim.bounds.center
|
||||||
bottomCenter = pos - (center[0], 0, center[2])
|
bottomCenter = pos - (center[0], 0, center[2])
|
||||||
|
|
||||||
imp = PendingImport(schematic.getDimension(), bottomCenter, dim.bounds, name)
|
imp = PendingImport(schematic.getDimension(), bottomCenter.intfloor(), dim.bounds, name)
|
||||||
command = PasteImportCommand(self, imp, "Import %s" % name)
|
command = PasteImportCommand(self, imp, "Import %s" % name)
|
||||||
self.undoStack.push(command)
|
self.undoStack.push(command)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user