Area Pattern

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
jaisejames
Posts: 384
Joined: Sat Sep 24, 2016 6:51 am

Area Pattern

Post by jaisejames »

I having a floor of irregular shape like attachment. I need to Patten tile inside area.
I having corner vectors so I can find maximum lengths. Using this, largest rectangle can be patterned.
Is there any option to check tile inside or outside polygon area to add or skip tile?

Add Code used:

Code: Select all

objs = FreeCAD.ActiveDocument.Objects

for obj in objs:
	if obj.isDerivedFrom("Part::Extrusion") :
		bb=obj.Shape.BoundBox
j = 0
for x in range(0,int(bb.XLength),500) :
	i = 0
	for x in range(0,int(bb.YLength),500) :
		CP001=FreeCAD.ActiveDocument.addObject("Part::Box","CP")
		CP001.Length = 500
		CP001.Width = 500
		CP001.Height = 10
		CP001.Placement=App.Placement(App.Vector(0+j*500,0+i*500,0),App.Rotation(App.Vector(0,0,1),0))
		i = i + 1
	j = j + 1

App.activeDocument().recompute()
Attachments
common 2.FCStd
(218.45 KiB) Downloaded 22 times
common.FCStd
(4.52 KiB) Downloaded 23 times
floor area.png
floor area.png (2.07 KiB) Viewed 626 times
jaisejames
Posts: 384
Joined: Sat Sep 24, 2016 6:51 am

Re: Area Pattern

Post by jaisejames »

Got some Idea from here.

https://forum.freecadweb.org/viewtopic. ... 60#p171509

Code: Select all

objs = FreeCAD.ActiveDocument.Objects

for obj in objs:
	print obj.TypeId
	if obj.isDerivedFrom("Part::Extrude") :
		aa=obj.Shape
		bb=aa.BoundBox
		print 'Length along x %f, y %f,z %f' % (bb.XLength,bb.YLength,bb.ZLength)

for obj in objs:
	if obj.isDerivedFrom("Part::Box") :
		distance,solutions,support = aa.distToShape(obj.Shape)
		if distance > 0 :
			print distance
			App.ActiveDocument.removeObject(obj.Name)

App.activeDocument().recompute()
Post Reply