+ symbolic grid

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
polymer
Posts: 278
Joined: Fri Sep 12, 2014 8:49 am

Re: + symbolic grid

Post by polymer »

No Grid is the best grid.
mario52
Veteran
Posts: 4701
Joined: Wed May 16, 2012 2:13 pm

Re: + symbolic grid

Post by mario52 »

hi
TheMarkster wrote: Fri Jul 19, 2019 5:14 am I think this type of grid would be a nice option for the user to choose from. Already there are options for solid, dotted, and dashed.
+1

here one "simulation"

Code: Select all

#https://forum.freecadweb.org/viewtopic.php?f=8&t=37760
#create a grille on direction of 3View 
#if the grid is viewTop or viewBottom the grid is colored in blue
#if the grid is viewFront or viewRear the grid is colored in green
#if the grid is viewRight or viewLeft the grid is colored in red
#other direction the grid is colored in black
#mario52
#20/07/2019

import Draft, Part, FreeCAD

####Begin Config#######################

lengthCross  = 10.0

numberCrossX = 40      # number of cross in X
numberCrossY = 20      # number of cross in Y

intervalX    = 20.0    # interval axis to axis cross X
intervalY    = 20.0    # interval axis to axis cross Y
intervalZ    = 00.0    # interval axis to axis cross Z

baseVectorX  = 0.0     # coordinate X begin
baseVectorY  = 0.0     # coordinate Y begin
baseVectorZ  = 0.0     # coordinate Z begin

####End Config#########################

doc = FreeCAD.ActiveDocument
if doc == None:
    doc = FreeCAD.newDocument()

#placement on actual view
pl = FreeCAD.Placement()
pl.Rotation = FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation()
pl.Base = FreeCAD.Vector(baseVectorX, baseVectorY, baseVectorZ)

lineH  = Part.LineSegment(FreeCAD.Vector(-lengthCross/2, 0.0, 0.0),FreeCAD.Vector(lengthCross/2, 0.0, 0.0))
lineV  = Part.LineSegment(FreeCAD.Vector(0.0, -lengthCross/2, 0.0),FreeCAD.Vector(0.0, lengthCross/2, 0.0))
cross  = Part.Shape([lineH,lineV])
Part.show(cross)

Grille = Draft.makeArray(FreeCAD.ActiveDocument.getObject(FreeCAD.ActiveDocument.ActiveObject.Name), FreeCAD.Vector(0.0, 0.0, 0.0), FreeCAD.Vector(0.0, 0.0, 0.0), numberCrossX, numberCrossY)
Draft.autogroup(Grille)

#DataObject
Grille.Label     = u"Grille"
Grille.ArrayType = u"ortho"
#Grille.Axis      = (1.0000, 1.0000, 0.0000)
#Grille.Center    = (0, 0, 0)
Grille.IntervalX = (intervalX, 0, 0)
Grille.IntervalY = (0, intervalY, 0)
Grille.IntervalZ = (0, 0, intervalZ)
#Grille.NumberX   = 10
#Grille.NumberY   = 10
#Grille.NumberZ   = 0
Grille.Fuse      = True

#ViewObject
Grille.ViewObject.PointColor = (0.0, 0.0, 0.0)
Grille.ViewObject.PointSize  = 1.0
Grille.ViewObject.LineWidth  = 1.0

Grille.Placement = pl
FreeCAD.ActiveDocument.recompute()

plpl = str(Grille.Placement.Rotation)

plyx = "Rotation (0.0, 0.0, 0.0, 1.0)"   # yx    viewTop
plxy = "Rotation (0.0, 1.0, 0.0, 0.0)"   # xy    viewBottom

plzx = "Rotation (0.7071067811865475, 0.0, 0.0, 0.7071067811865475)" # zx    viewFront
plxz = "Rotation (0.0, 0.7071067811865475, 0.7071067811865475, 0.0)" # xz    viewRear

plzy = "Rotation (0.5, 0.5, 0.5, 0.5)"   # zy    viewRight
plyz = "Rotation (-0.5, 0.5, 0.5, -0.5)" # yz    viewLeft

if   plpl == plyx:
    Grille.ViewObject.LineColor  = (0.0, 0.0, 1.0)    # yx    viewTop
elif plpl == plxy:
    Grille.ViewObject.LineColor  = (0.0, 0.0, 0.8)    # xy    viewBottom
elif plpl == plzx:
    Grille.ViewObject.LineColor  = (0.0, 1.0, 0.0)    # zx    viewFront
elif plpl == plxz:
    Grille.ViewObject.LineColor  = (0.0, 0.8, 0.0)    # xz    viewRear
elif plpl == plzy:
    Grille.ViewObject.LineColor  = (1.0, 0.0, 0.0)    # zy    viewRight
elif plpl == plyz:
    Grille.ViewObject.LineColor  = (0.8, 0.0, 0.0)    # yz    viewLeft
else:
    Grille.ViewObject.LineColor  = (0.0, 0.0, 0.0)    # other view

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
Post Reply