Macro BoundingBox Tracing: Difference between revisions
Renatorivo (talk | contribs) (<translate>) |
Renatorivo (talk | contribs) (Marked this version for translation) |
||
Line 1: | Line 1: | ||
<translate> |
<translate> |
||
<!--T:1--> |
|||
{{Macro|Icon=Text-x-python|Name=Macro_BoundingBox_Tracing|Description=This macro red trace (editable) around the BoundingBox with 6 rectangles.|Author=Mario52}} |
{{Macro|Icon=Text-x-python|Name=Macro_BoundingBox_Tracing|Description=This macro red trace (editable) around the BoundingBox with 6 rectangles.|Author=Mario52}} |
||
==Description== |
==Description== <!--T:2--> |
||
This macro red trace (editable) around the BoundingBox 6 Faces with 6 rectangles. |
This macro red trace (editable) around the BoundingBox 6 Faces with 6 rectangles. |
||
==Use== |
==Use== <!--T:3--> |
||
Select the object and launch the macro. 6 rectangles are colored red (can be changed) |
Select the object and launch the macro. 6 rectangles are colored red (can be changed) |
||
==Macro== |
==Macro== <!--T:4--> |
||
</translate> |
</translate> |
||
Revision as of 20:14, 20 April 2014
File:Text-x-python Macro_BoundingBox_Tracing |
Description |
---|
This macro red trace (editable) around the BoundingBox with 6 rectangles. Author: Mario52 |
Author |
Mario52 |
Download |
None |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
1.0 |
Date last modified |
None |
FreeCAD Version(s) |
None |
Default shortcut |
None |
See also |
None |
Description
This macro red trace (editable) around the BoundingBox 6 Faces with 6 rectangles.
Use
Select the object and launch the macro. 6 rectangles are colored red (can be changed)
Macro
Macro_BoundingBox_Tracing.FCMacro
# -*- coding: utf-8 -*-
# cette macro trace en rouge (modifiable) le tour du boundingbox avec 6 rectangles
# this macro red trace (editable) around the BoundingBox with 6 rectangles
# Macro_BoundingBox_Tracing
# ver 0.2 20/04/2014
import FreeCAD, FreeCADGui, Draft, Part
selEx = FreeCADGui.Selection.getSelectionEx()
objs = [selobj.Object for selobj in selEx]
if len(objs) >= 1:
s = objs[0].Shape
# boundBox
boundBox_ = s.BoundBox
boundBoxLX = boundBox_.XLength
boundBoxLY = boundBox_.YLength
boundBoxLZ = boundBox_.ZLength
print boundBox_
print "_____________________"
a = str(boundBox_)
a,b = a.split('(')
c = b.split(',')
oripl_X = float(c[0])
oripl_Y = float(c[1])
oripl_Z = float(c[2])
# LineColor
red = 1.0 # 1 = 255
green = 0.0 #
blue = 0.0 #
#####
try:
pl_0 = App.Placement(App.Vector(oripl_X,oripl_Y,oripl_Z), App.Rotation(0.0,0.0,0.0))
double = Draft.makeRectangle(length=boundBox_.XLength,height=boundBox_.YLength,placement=pl_0,face=False,support=None) #OK
FreeCADGui.activeDocument().activeObject().LineColor = (red, green, blue)
except:
App.Console.PrintError("not done 0"+"\n")
try:
pl_1 = App.Placement(App.Vector(oripl_X,oripl_Y,oripl_Z+boundBoxLZ), App.Rotation(0.0,0.0,0.0))
double = Draft.makeRectangle(length=boundBox_.XLength,height=boundBox_.YLength,placement=pl_1,face=False,support=None) #Ok
FreeCADGui.activeDocument().activeObject().LineColor = (red, green, blue)
except:
App.Console.PrintError("not done 1"+"\n")
try:
pl_2 = App.Placement(App.Vector(oripl_X,oripl_Y,oripl_Z), App.Rotation(0.0,0.0,90))
double = Draft.makeRectangle(length=boundBox_.XLength,height=boundBox_.ZLength,placement=pl_2,face=False,support=None) #Ok
FreeCADGui.activeDocument().activeObject().LineColor = (red, green, blue)
except:
App.Console.PrintError("not done 2"+"\n")
try:
pl_3 = App.Placement(App.Vector(oripl_X,oripl_Y+boundBoxLY,oripl_Z), App.Rotation(0.0,0.0,90))
double = Draft.makeRectangle(length=boundBox_.XLength,height=boundBox_.ZLength,placement=pl_3,face=False,support=None) #Ok
FreeCADGui.activeDocument().activeObject().LineColor = (red, green, blue)
except:
App.Console.PrintError("not done 3"+"\n")
try:
pl_4 = App.Placement(App.Vector(oripl_X,oripl_Y,oripl_Z), App.Rotation(90,0.0,90))
double = Draft.makeRectangle(length=boundBoxLY,height=boundBox_.ZLength,placement=pl_4,face=False,support=None) #Ok
FreeCADGui.activeDocument().activeObject().LineColor = (red, green, blue)
except:
App.Console.PrintError("not done 4"+"\n")
try:
pl_5 = App.Placement(App.Vector(oripl_X+boundBoxLX,oripl_Y,oripl_Z), App.Rotation(90,0.0,90))
double = Draft.makeRectangle(length=boundBoxLY,height=boundBoxLZ,placement=pl_5,face=False,support=None) #Ok
FreeCADGui.activeDocument().activeObject().LineColor = (red, green, blue)
except:
App.Console.PrintError("not done 5"+"\n")
#####
App.ActiveDocument.recompute()
else:
App.Console.PrintMessage("Select an object !"+"\n")