Pipe tools in Arch

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
User avatar
chakkree
Posts: 288
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Pipe tools in Arch

Postby chakkree » Tue Nov 29, 2016 3:03 am

Every Arch Object,etc. Wall , Structure, have the "return obj" command at end of procedure that can use for handle any properties.
But ArchPile.makePipe and ArchPile.makePipeConnector haven't.


This code will error occur , if doesn't add "return obj" command.

Code: Select all

import Draft , Arch

from FreeCAD import Vector

points=[ Vector(0,0,0),Vector(4000,0.0,0.0)]
line1 = Draft.makeWire(points,closed=False,face=False,support=None)
pipe1 = Arch.makePipe(line1,18)
pipe1.ViewObject.ShapeColor = (0.333,1.000,1.000)

points=[ Vector(2000,0,0),Vector(2000,0.0 , 4000)]
line2 = Draft.makeWire(points,closed=False,face=False,support=None)
pipe2 = Arch.makePipe(line2,18)
pipe2.ViewObject.ShapeColor = (0.333,1.000,1.000)

points=[ 
  Vector(0,0,0),
  Vector(2000,0,0),
  Vector(2000,0.0 , 4000),
  Vector(2500,1000 , 4000),
  Vector(2500,1000 , 4300),
]
line3 = Draft.makeWire(points,closed=False,face=False,support=None)
pipe3 = Arch.makePipe(line3,55)
pipe3.Placement.Base.y=1000
pipe3.ViewObject.ShapeColor = (0.333,1.000,1.000)

FreeCAD.ActiveDocument.recompute()
TestArchPipe.PNG
TestArchPipe.PNG (13.71 KiB) Viewed 2060 times
User avatar
yorik
Site Admin
Posts: 11496
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Pipe tools in Arch

Postby yorik » Tue Nov 29, 2016 1:42 pm

chakkree wrote:ArchPile.makePipe and ArchPile.makePipeConnector haven't.
Oh you're right... this is now fixed in git commit 43aae3d
User avatar
chakkree
Posts: 288
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Pipe tools in Arch

Postby chakkree » Tue Nov 29, 2016 2:08 pm

yorik wrote: Oh you're right... this is now fixed in git commit 43aae3d
Thank you so much.
User avatar
chakkree
Posts: 288
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Pipe tools in Arch

Postby chakkree » Sat Dec 10, 2016 3:38 am

I use ArchPipe object to represent rebars, more comfortable than write python macro for rebar object.
If use Line object for the base object of Pipe, it can define start and end point's coordinate in expression that can get from Spreadsheet alias name.
But Dwire can not assign coordinate of points from the spreadsheet. Now I can use cylinder and torus then fusion to present and control parameter(placement and rotation,etc.),but it is very very hard work.

A diameter and Bend radius of rebar can be assign as parameters.
ArchPipe_as_Rebar.png
ArchPipe_as_Rebar.png (240.59 KiB) Viewed 1933 times
Sample File.
Rebar_from_ArchPipe.FCStd
(8.5 KiB) Downloaded 56 times
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.9184 (Git)
Build type: Release
Branch: master
Hash: 14e32213747928d3a01ab95cf09f611fa383981e
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
ikua
Posts: 125
Joined: Fri Apr 07, 2017 1:32 pm

Re: Pipe tools in Arch

Postby ikua » Fri Aug 25, 2017 1:10 pm

Arch pipe is a great tool! Exactly what i was looking for to plan small plants.

For further planing of my projects and to order material it would be really handy to have a possibility to get the number of bends of the pipes as well as the refering angels into a spreadsheet. I am using for construction of pipes the d-wire.

I get the number of bends with python but to not know how to transfer it to the spreadsheet:

len(FreeCAD.ActiveDocument.DWire.Points)-2

How could i calculate that in the spreadsheet?

Thanks
User avatar
yorik
Site Admin
Posts: 11496
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Pipe tools in Arch

Postby yorik » Fri Aug 25, 2017 2:02 pm

What you could do is to make an intermediary object that will count the segments, for example with a macro like this:

Code: Select all

import FreeCAD,FreeCADGui

class PipeCounter:
    def __init__(self,obj):
        obj.addProperty("App::PropertyLinkList","Wires")
        obj.addProperty("App::PropertyInteger","Segments")
        obj.Proxy = self
    def execute(self,obj):
        total = 0
        for w in obj.Wires:
            if hasattr(w,"Points"):
                total += len(w.Points)-2
        obj.Segments = total

def makePipeCounter():
    obj = FreeCAD.ActiveDocument.addObject("App::Feature","PipeCounter")
    PipeCounter(obj)
    obj.Wires = FreeCADGui.Selection.getSelection()
Then save this as a .py file in your macros folder, for example PipeCounter.py, select all your wires, then:

Code: Select all

import PipeCounter
PipeCounter.makePipeCounter()
Then in your spereadsheet you'll be able to use the "Segments" property of the PipeCounter object

Of course this code can be bettered in many ways. Also, the macro has to be present in any computer where you want to open that file.
ikua
Posts: 125
Joined: Fri Apr 07, 2017 1:32 pm

Re: Pipe tools in Arch

Postby ikua » Tue Aug 29, 2017 4:08 pm

Sorry for my late answer.

But that is awesome! And I was not expecting a answer that fast.
Nevertheless when i tried in on my model i got the following error.

obj = FreeCAD.ActiveDocument.addObject("App::Feature","PipeCounter")
Base.FreeCADError: No document object found of type 'App::Feature'

Do not know how to handle it.



Thank you very much!!
User avatar
yorik
Site Admin
Posts: 11496
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Pipe tools in Arch

Postby yorik » Tue Aug 29, 2017 6:33 pm

Ah sorry, use App::FeaturePython instead of App::Feature (which indeed doesn't exist).
ikua
Posts: 125
Joined: Fri Apr 07, 2017 1:32 pm

Re: Pipe tools in Arch

Postby ikua » Wed Aug 30, 2017 11:11 am

works like charm!
Thank you again!
ikua
Posts: 125
Joined: Fri Apr 07, 2017 1:32 pm

Re: Pipe tools in Arch

Postby ikua » Thu Aug 31, 2017 2:47 pm

I wrote a code, which adds to every wire in the document the number of bends as an property. Therefore the bends can be calculated for different wires/tubes

Code: Select all

import FreeCAD,FreeCADGui,numpy as np

for obj in Gui.ActiveDocument.Document.Objects:
    if hasattr(obj,"Shape"):
	    if "Wire" in str(obj.Shape):
		print obj.Label
		#print obj.Shape
		obj.addProperty("App::PropertyInteger","Bend")
		obj.addProperty("App::PropertyInteger","Bend90Degree") 
		obj.addProperty("App::PropertyInteger","Bend0Degree")  # for further use for points which are alined (no real bend, line with 3 points)
		total = 0
		total90 = 0
		total += len(obj.Points)-2
		obj.Bend = total
		xBefore=8923802384
		yBefore=923080834209
		zBefore= 90238403248 
		for index, p in enumerate(obj.Points):
			if (index >0) and (index < (total+1)):
				#print index
				#print obj.Points[index-1]
				#print obj.Points[index]
				#print obj.Points[index+1]
				#print obj.Points[index-1]-obj.Points[index]
				#print obj.Points[index]-obj.Points[index+1]
				scalarproduct = np.dot(obj.Points[index]-obj.Points[index+1],obj.Points[index-1]-obj.Points[index])
				#print scalarproduct
				if scalarproduct == 0: #if scalarproduct is cero the 2 vectors from the 3 points are normal to each other
					total90 += 1
				obj.Bend90Degree = total90