133 lines
5.7 KiB
HTML
133 lines
5.7 KiB
HTML
<html><head><title>Macro Duplicate Selection</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link type='text/css' href='wiki.css' rel='stylesheet'></head><body><h1>Macro Duplicate Selection</h1></div>
|
|
|
|
<div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><div class="mw-parser-output"><table class="fcinfobox wikitable ct" width="100%" style="float: right; width: 230px; margin-left: 10px;">
|
|
<tr>
|
|
<td class="ctTitle">
|
|
<h3><span class="mw-headline" id="Macro_Duplicate_Selection"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Text-x-python.png" class="image"><img alt="Text-x-python.png" src="32px-Text-x-python.png" width="32" height="32" srcset="/wiki/images/2/2c/Text-x-python.png 1.5x" /></a> Macro Duplicate Selection</span></h3>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Description
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven left macro-description">This macro testing if one selection are duplicate.
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Author
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-author"><a href="https://www.freecadweb.org/wiki/index.php?title=User:Mario52" title="User:Mario52">Mario52</a>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Links
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven"><a href="Macros_recipes.html" title="Macros recipes">Macros recipes</a><br /><a href="How_to_install_macros.html" title="How to install macros">How to install macros</a><br /><a href="Customize_Toolbars.html" title="Customize Toolbars">How to customize toolbars</a>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Version
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-version">00.00
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Date last modification
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-date">2016-06-06
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctToc"><br /><div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
|
|
<ul>
|
|
<li class="toclevel-1"><a href="#Macro_Duplicate_Selection"><span class="tocnumber">1</span> <span class="toctext">Macro Duplicate Selection</span></a></li>
|
|
<li class="toclevel-1 tocsection-1"><a href="#Description"><span class="tocnumber">2</span> <span class="toctext">Description</span></a></li>
|
|
<li class="toclevel-1 tocsection-2"><a href="#How_to_use"><span class="tocnumber">3</span> <span class="toctext">How to use</span></a></li>
|
|
<li class="toclevel-1 tocsection-3"><a href="#Script"><span class="tocnumber">4</span> <span class="toctext">Script</span></a></li>
|
|
<li class="toclevel-1 tocsection-4"><a href="#Links"><span class="tocnumber">5</span> <span class="toctext">Links</span></a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
</td></tr>
|
|
</table>
|
|
<p><br />
|
|
</p>
|
|
<h2><span class="mw-headline" id="Description">Description</span></h2>
|
|
<p>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.
|
|
</p>
|
|
<h2><span class="mw-headline" id="How_to_use">How to use</span></h2>
|
|
<p>Run the macro, the macro stay resident in memory.
|
|
</p><p>Select yours objects selected is duplicate the cursor mouse ere displayed "ForbiddenCursor"
|
|
</p>
|
|
<h2><span class="mw-headline" id="Script">Script</span></h2>
|
|
<p><b>Macro_Duplicate_Selection.FCMacro</b>
|
|
</p>
|
|
<pre># -*- 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 </pre>
|
|
<h2><span class="mw-headline" id="Links">Links</span></h2>
|
|
<p>The forum discussion <a rel="nofollow" class="external text" href="http://forum.freecadweb.org/viewtopic.php?f=3&t=15994">Duplicate Objects when more than one face selected</a>
|
|
</p>
|
|
<div style="clear:both"></div>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div><div class="printfooter">
|
|
Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=Macro_Duplicate_Selection&oldid=239938">http://www.freecadweb.org/wiki/index.php?title=Macro_Duplicate_Selection&oldid=239938</a>"</div>
|
|
<div id="catlinks" class="catlinks" data-mw="interface"></div><div class="visualClear"></div>
|
|
</div>
|
|
</div>
|
|
<div id="mw-navigation">
|
|
<h2>Navigation menu</h2>
|
|
|
|
</body></html> |