Macro Duplicate Selection: Difference between revisions

From FreeCAD Documentation
(create page)
 
(Marked this version for translation)
Line 1: Line 1:
<translate>
<translate>
<!--T:1-->
{{Macro|Icon=Text-x-python|Name=Macro_Duplicate_Selection|Description= This macro testing if one selection are duplicate.|Author=Mario52}}
{{Macro|Icon=Text-x-python|Name=Macro_Duplicate_Selection|Description= This macro testing if one selection are duplicate.|Author=Mario52}}
</translate>
</translate>
<translate>
<translate>
==Description==
==Description== <!--T:2-->
This macro testing if one selection are duplicate , select the object IN THE 3D VIEW the "ForbiddenCursor" stay if the or one selection is duplicate, the macro stay resident.
This macro testing if one selection are duplicate , select the object IN THE 3D VIEW the "ForbiddenCursor" stay if the or one selection is duplicate, the macro stay resident.
</translate>
</translate>
<translate>
<translate>
==How to use==
==How to use== <!--T:3-->
Run the macro, the macro stay resident in memory.
Run the macro, the macro stay resident in memory.


<!--T:4-->
Select yours objects selected is duplicate the cursor mouse ere displayed "ForbiddenCursor"
Select yours objects selected is duplicate the cursor mouse ere displayed "ForbiddenCursor"
</translate>
</translate>
<translate>
<translate>
==Script==
==Script== <!--T:5-->
</translate>
</translate>
'''Macro_Duplicate_Selection.FCMacro'''
'''Macro_Duplicate_Selection.FCMacro'''
Line 70: Line 72:
</syntaxhighlight>
</syntaxhighlight>
<translate>
<translate>
==Links==
==Links== <!--T:6-->


<!--T:7-->
The forum discussion [http://forum.freecadweb.org/viewtopic.php?f=3&t=15994 Duplicate Objects when more than one face selected]
The forum discussion [http://forum.freecadweb.org/viewtopic.php?f=3&t=15994 Duplicate Objects when more than one face selected]
</translate>
</translate>

Revision as of 15:34, 7 June 2016

File:Text-x-python Macro_Duplicate_Selection

Description
This macro testing if one selection are duplicate.

Author: Mario52
Author
Mario52
Download
None
Links
Macro Version
1.0
Date last modified
None
FreeCAD Version(s)
None
Default shortcut
None
See also
None

Description

This macro testing if one selection are duplicate , select the object IN THE 3D VIEW the "ForbiddenCursor" stay if the or one selection is duplicate, the macro stay resident.

How to use

Run the macro, the macro stay resident in memory.

Select yours objects selected is duplicate the cursor mouse ere displayed "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

Links

The forum discussion Duplicate Objects when more than one face selected

Other languages: