OSError:Access violation

Chinese forum

Moderator: paullee

Forum rules
论坛规矩 / 論壇規矩 , 有用的资讯 / 有用的資訊
重要:寻求帮助之前,请先看看这里 /
重要:尋求幫助之前,請先看看這裡

另外,对论坛用户 友善!阅读FreeCAD 行为准则!
/ 另外,對論壇用戶 友善! 閱讀FreeCAD
行為準則
Post Reply
seastar
Posts: 6
Joined: Tue Jan 30, 2024 5:46 am

OSError:Access violation

Post by seastar »

我用Pycharm调用freecad里的API建模,之前运行程序都能成功建模,突然就报错OSError。随后我尝试调用其他函数,如:Draft.make_wire()等,甚至只是单纯创建一个newDocument并保存,都是提示同样的错误OSError

Code: Select all

import FreeCAD as app
import FreeCADGui as Gui
import Draft

def DrawEllipse(a,b,placement=None, face=None, support=None):
    '''
    创建2D椭圆
    :param a: #type:float/int Major Radius
    :param b: #type:float/int Minor Radius
    :param placement: FreeCAD.Vector
    :param face:If face is False, the rectangle is shown as a wireframe,otherwise as a face
    :param support:
    :return:2D ellipse object
    2024.1.27
    '''

    ellipse = Draft.make_ellipse(a, b, placement=placement, face=face, support=support)

    return ellipse

Gui.showMainWindow()
app.newDocument('new')

DrawEllipse(200,100)
app.ActiveDocument.recompute()

app.ActiveDocument.saveAs("D:\\Desktop\\freecad\\椭圆0129.FCStd")

Code: Select all

D:\FREECAD\bin\python.exe "D:\Desktop\freecad via python\forum.py" 
Traceback (most recent call last):
  File "D:\Desktop\freecad via python\forum.py", line 24, in <module>
    DrawEllipse(200,100)
  File "D:\Desktop\freecad via python\forum.py", line 17, in DrawEllipse
    ellipse = Draft.make_ellipse(a, b, placement=placement, face=face, support=support)
  File "D:\FREECAD\Mod\Draft\draftmake\make_ellipse.py", line 68, in make_ellipse
    obj = App.ActiveDocument.addObject("Part::Part2DObjectPython", "Ellipse")
OSError: {'sclassname': 'class Base::AccessViolation', 'sErrMsg': 'Access violation', 'sfile': '', 'iline': 0, 'sfunction': '', 'swhat': 'Access violation', 'btranslatable': False, 'breported': False}

Process finished with exit code 1
paullee
Veteran
Posts: 5081
Joined: Wed May 04, 2016 3:58 pm

Re: OSError:Access violation

Post by paullee »

歡迎! 留意到你在英文Python論譠上帖上你的問題,如有答案、請在這裏帖上連結,謝謝。
User avatar
johnwang
Veteran
Posts: 1313
Joined: Sun Jan 27, 2019 12:41 am

Re: OSError:Access violation

Post by johnwang »

这个运行命令是什么呀?
FreeCADcmd?
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
seastar
Posts: 6
Joined: Tue Jan 30, 2024 5:46 am

Re: OSError:Access violation

Post by seastar »

johnwang wrote: Fri Feb 02, 2024 1:19 pm 这个运行命令是什么呀?
FreeCADcmd?
我是用pycharm直接运行上面那段代码
User avatar
johnwang
Veteran
Posts: 1313
Joined: Sun Jan 27, 2019 12:41 am

Re: OSError:Access violation

Post by johnwang »

你的pycharm是怎么设置的?
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
seastar
Posts: 6
Joined: Tue Jan 30, 2024 5:46 am

Re: OSError:Access violation

Post by seastar »

johnwang wrote: Sat Feb 03, 2024 12:50 am 你的pycharm是怎么设置的?
具体指什么设置呢?
解释器是用freecad安装路径里bin文件的python.exe
Post Reply