Macro Duplicate Selection/it: Difference between revisions

From FreeCAD Documentation
No edit summary
(Updating to match new version of source page)
Line 9: Line 9:
'''Macro_Duplicate_Selection.FCMacro'''
'''Macro_Duplicate_Selection.FCMacro'''


{{Code|code=
<syntaxhighlight>
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import FreeCADGui
import FreeCADGui
Line 60: Line 60:
FreeCADGui.Selection.addObserver(s) # installe la fonction en mode resident
FreeCADGui.Selection.addObserver(s) # installe la fonction en mode resident


}}
</syntaxhighlight>
==Link==
==Link==



Revision as of 11:02, 25 September 2016

File:Text-x-python Macro Duplicate Selection

Descrizione
Questa macro testa se una selezione è duplicabile.

Versione macro: 00.00 (06/06/2016)
Autore: Mario52
Autore
Mario52
Download
None
Link
Versione macro
00.00 (06/06/2016)
Data ultima modifica
None
Versioni di FreeCAD
None
Scorciatoia
Nessuna
Vedere anche
Nessuno

Descrizione

Questa macro testa se una selezione è duplicabile. Selezionare gli oggetti nella vista 3D, se una selezione è duplicabile il mouse rimane bloccato su "ForbiddenCursor" fino a duplicazione avvenuta.

Uso

Avviare la macro, essa rimane residente in memoria.

Selezionare gli oggetti da duplicare. Mentre gli oggetti vengono duplicati il cursore del mouse viene bloccato su "ForbiddenCursor"

Script

Macro_Duplicate_Selection.FCMacro

# -*- coding: utf-8 -*-
import FreeCADGui
import PySide
from PySide import QtGui ,QtCore
from PySide.QtGui import *
from PySide.QtCore import *

__title__   = "Macro_Duplicate_Selection"
__author__  = "Mario52"
__url__     = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.00"
__date__    = "06/06/2016"

__Help__    = "Start the macro select the object IN THE 3D VIEW the ForbiddenCursor stay if the selection is duplicate"

def selectionObject():
    sel = FreeCADGui.Selection.getSelection() 
    x  = []
    del x[:]
    for a in range(len(sel)):
       x.append(sel[a].Name)
    doublet = 0
    for i in range(len(sel)):
        for ii in range((i+1),len(sel)):
            if x[i] == x[ii]:
                doublet = 1
                break
    if doublet == 1:
        QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.ForbiddenCursor))
#        FreeCAD.Console.PrintError("HELP "+sel[-1].Name+" duplicate selection"+"\n")
    else:
        QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))

class SelObserver:
    def addSelection(self,doc,obj,sub,pnt):   # Selection
        selectionObject()
    def removeSelection(self,doc,obj,sub):    # Effacer l'objet salectionne
        selectionObject()
    def setPreselection(self, doc, obj, sub):
        selectionObject()
    def clearSelection(self,doc):             # Si clic sur l'ecran, effacer la selection
        selectionObject()
#    def setSelection(self,doc):               # Selection dans Combo View pour quitter la fonction
#        App.Console.PrintMessage("Fin Macro_Duplicate"+"\n")
#        QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
#        FreeCADGui.Selection.removeObserver(s)# desinstalle la fonction residente

s=SelObserver()
FreeCADGui.Selection.addObserver(s)    # installe la fonction en mode resident

Link

La discussione Duplicate Objects when more than one face selected nel forum di FreeCAD.

Other languages: