Talk:Topological data scripting

From FreeCAD Documentation
Revision as of 07:32, 2 July 2008 by Wmayer (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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)