Talk:Topological data scripting

From FreeCAD Documentation
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Hellow,Please teach me a solution.

After File->New command, I input a command in python console as follows.

>>>>import Part

>>>>b = Part.createBox(0,0,0,100,100,100)

Next command does not work.

>>>>Part.show(b)

Traceback (most recent call last):

 File "<input>", line 1, in <module>

AttributeError: 'module' object has no attribute 'show' [User:Aki]

show() is probably not available in your version. But you can achieve the same with a bit more of typing.
doc=App.newDocument() 
obj=doc.addObject("Part::Feature")
obj.Shape=b
-- Wmayer 15:11, 1 July 2008 (CEST)

Thank you for an answer

I wanted to try a Draft function and changed Version into 0.7.1329 from 0.7.135 the other day.

By this, I was able to check the operation of the Draft function.

It was as follows this time when I input the command mentioned above from python Console.

>>> import Part

>>> b = Part.createBox(0,0,0,100,100,100)

>>> doc=App.newDocument()

>>> obj=doc.addObject("Part::Feature")

>>> obj.Shape=b

Traceback (most recent call last):

 File "<input>", line 1, in <module>

TypeError: type must be 'Shape', not TopoShape

Please teach me a solution. [User:Aki]

Argh, you're right. There was another internal change concerning the python topo shape class. Old and new class are incompatible. The only workaround now is to export the shape to disk and import again.
b.exportBrep("shape.brep")
Part.insert("shape.brep")
Hope that works. -- Wmayer 09:32, 2 July 2008 (CEST)


I want to let display the figure which I generated from python console upon the Workspace of FreeCAD, but above command cannot display it.


>>> import Part

>>> b = Part.createBox(0,0,0,100,100,100)

>>> b.exportBrep("shape.brep")

>>> Part.insert("shape.brep")

Traceback (most recent call last):

 File "<input>", line 1, in <module>

TypeError: function takes exactly 2 arguments (1 given)

What will I do? [User:Aki]

Sorry, my fault. Instead of
Part.insert("shape.brep")
write
Part.insert("shape.brep",App.ActiveDocument.Name)
Alternatively you can write
Part.open("shape.brep")
which simply creates a new document. -- Wmayer 12:10, 3 July 2008 (CEST)


Ok,It got along well.

The last command was unnecessary because It opened another screen.

import Part

b = Part.createBox(0,0,0,100,100,100)

b.exportBrep("shape.brep")

Part.insert("shape.brep",App.ActiveDocument.Name)

Thank you very much. [User:Aki]

Why do not it work?

I intend to study FreeCAD from the beginning.

I input a command to learn Exploring shapes.

Why do not it work?

Is this caused by the difference of the FrreeCAD version?

Here, what do you explain?

[User aki]

>>> b = Part.createBox(0,0,0,100,100,100)

>>> b.Wires

[]

>>> w = b.Wires[0]

Traceback (most recent call last):

 File "<input>", line 1, in <module>

IndexError: list index out of range

>>> w

Traceback (most recent call last):

 File "<input>", line 1, in <module>

NameError: name 'w' is not defined

>>> w.Wires

Traceback (most recent call last):

 File "<input>", line 1, in <module>

NameError: name 'w' is not defined

>>> w.Vertexes

Traceback (most recent call last):

 File "<input>", line 1, in <module>

NameError: name 'w' is not defined

>>> Part.show(w)

Traceback (most recent call last):

 File "<input>", line 1, in <module>

AttributeError: 'module' object has no attribute 'show'

>>> w.Edges

Traceback (most recent call last):

 File "<input>", line 1, in <module>

NameError: name 'w' is not defined

>>> e = w.Edges[0]

Traceback (most recent call last):

 File "<input>", line 1, in <module>

NameError: name 'w' is not defined

>>> e.Vertexes

Traceback (most recent call last):

 File "<input>", line 1, in <module>

NameError: name 'e' is not defined

>>> v = e.Vertexes[0]

Traceback (most recent call last):

 File "<input>", line 1, in <module>

NameError: name 'e' is not defined

>>> v.Point

The problem basically is that the Part module is under heavy construction in the recent days with with a lot of new functionality added. This of course doesn't work with your old version. Thus, I think you should wait for the next release. Hopefully, we can release a new version in the next days. -- Wmayer 00:13, 5 July 2008 (CEST)

Issue: UML diagram of Part library, bottom right: "Circel" should be "Circle"