Macro Duplicate Selection: Difference between revisions

From FreeCAD Documentation
m (Change section to 'Usage')
No edit summary
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>

<!--T:1-->
<!--T:1-->
{{Macro
{{Macro
|Name=Macro Duplicate Selection
|Name=Macro Duplicate Selection
|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.
|Description=This macro changes the mouse cursor to "ForbiddenCursor" if a selection is duplicated.
|Author=Mario52
|Author=Mario52
|Version=00.00
|Version=00.00
|Date=2016-06-06
|Date=2016-06-06
|FCVersion=0.16
|FCVersion=0.16
|Download= [https://www.freecadweb.org/wiki/images/5/54/Macro_Duplicate_Selection.png Icon ToolBar]
|Download=[https://wiki.freecad.org/images/5/54/Macro_Duplicate_Selection.png ToolBar Icon]
}}
}}


==Description== <!--T:2-->
==Description== <!--T:9-->
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.


==Usage== <!--T:3-->
<!--T:2-->
This macro changes the mouse cursor to "ForbiddenCursor" if a selection is duplicated.
Run the macro, the macro stay resident in memory.

==Usage== <!--T:10-->

<!--T:3-->
Run the macro, the macro stays resident in memory.


<!--T:4-->
<!--T:4-->
Select yours objects selected is duplicate the cursor mouse ere displayed "ForbiddenCursor"
Select your objects. If a selected objects is a duplicate the "ForbiddenCursor" mouse cursor is displayed.


==Script== <!--T:5-->
==Script== <!--T:5-->


<!--T:8-->
<!--T:8-->
Icon for the toolBar [[File:Macro_Duplicate_Selection.png]]
Icon for the toolbar [[File:Macro_Duplicate_Selection.png]]


</translate>
</translate>

'''Macro_Duplicate_Selection.FCMacro'''
'''Macro_Duplicate_Selection.FCMacro'''


{{Code|code=
{{MacroCode|code=
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import FreeCADGui
import FreeCADGui
Line 83: Line 87:
}}
}}
<translate>
<translate>

==Links== <!--T:6-->
==Links== <!--T:6-->



Latest revision as of 11:53, 29 December 2023

Other languages:

Macro Duplicate Selection

Description
This macro changes the mouse cursor to "ForbiddenCursor" if a selection is duplicated.

Macro version: 00.00
Last modified: 2016-06-06
FreeCAD version: 0.16
Download: ToolBar Icon
Author: Mario52
Author
Mario52
Download
ToolBar Icon
Links
Macro Version
00.00
Date last modified
2016-06-06
FreeCAD Version(s)
0.16
Default shortcut
None
See also
None

Description

This macro changes the mouse cursor to "ForbiddenCursor" if a selection is duplicated.

Usage

Run the macro, the macro stays resident in memory.

Select your objects. If a selected objects is a duplicate the "ForbiddenCursor" mouse cursor is displayed.

Script

Icon for the toolbar

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