I have some code which reads a step file and returns a shape (geometrical information). This uses the XDE of OCCD and will also be able to extract the attribute information such as colour or name or layer. But im new to pythonocc and im getting the following error :
'function' object has no attribute 'NewDocument' type is: AttributeError Traceback (most recent call last): File "d:\ShareUbuntu\Optimization\Optimization_NACA.py", line 117, in funcSU2 config.m1=ExtractTopo(config.meshDir,config.modelName1) File "d:\ShareUbuntu\Optimization\Optimization_NACA.py", line 463, in init self.main() File "d:\ShareUbuntu\Optimization\Optimization_NACA.py", line 469, in main [self.topo,colour_tool]=OCCB.read_step_file_with_attribute2(self.path+self.model+".stp") File "d:\ShareUbuntu\Optimization\OCCD_Basic.py", line 875, in read_step_file_with_attribute2 app.NewDocument(TCollection_ExtendedString("MDTV-CAF"),h_doc) AttributeError: 'function' object has no attribute 'NewDocument' Traceback (most recent call last): File "d:\ShareUbuntu\Optimization\Optimization_NACA.py", line 1992, in main(config) File "d:\ShareUbuntu\Optimization\Optimization_NACA.py", line 64, in main res = fmin_slsqp(funcSU2, x0, f_eqcons=None, f_ieqcons=inequality_const_thickness,bounds=config.parmBounds, fprime=gradSU2, fprime_eqcons=None,fprime_ieqcons=inequality_const_thickness_grad, args=(config,), acc=1e-2,iprint=2, disp=None, full_output=1) File "C:\Users\yesbo.conda\envs\py39env\lib\site-packages\scipy\optimize_slsqp_py.py", line 206, in fmin_slsqp res = _minimize_slsqp(func, x0, args, jac=fprime, bounds=bounds, File "C:\Users\yesbo.conda\envs\py39env\lib\site-packages\scipy\optimize_slsqp_py.py", line 374, in _minimize_slsqp sf = _prepare_scalar_function(func, x, jac=jac, args=args, epsilon=eps, File "C:\Users\yesbo.conda\envs\py39env\lib\site-packages\scipy\optimize_optimize.py", line 383, in _prepare_scalar_function sf = ScalarFunction(fun, x0, args, grad, hess, File "C:\Users\yesbo.conda\envs\py39env\lib\site-packages\scipy\optimize_differentiable_functions.py", line 158, in init self._update_fun() File "C:\Users\yesbo.conda\envs\py39env\lib\site-packages\scipy\optimize_differentiable_functions.py", line 251, in _update_fun self._update_fun_impl() File "C:\Users\yesbo.conda\envs\py39env\lib\site-packages\scipy\optimize_differentiable_functions.py", line 155, in update_fun self.f = fun_wrapped(self.x) File "C:\Users\yesbo.conda\envs\py39env\lib\site-packages\scipy\optimize_differentiable_functions.py", line 137, in fun_wrapped fx = fun(np.copy(x), args) File "d:\ShareUbuntu\Optimization\Optimization_NACA.py", line 144, in funcSU2 return objconfig.functionScaling UnboundLocalError: local variable 'obj' referenced before assignment
Some of my code is as follows. I get the error after this line app.NewDocument(TCollection_ExtendedString("MDTV-CAF"),h_doc)
h_doc = TDocStd_Document
#print "Empty Doc?", h_doc.IsNull()
### Create the application
app = XCAFApp_Application.GetApplication
print('mohsin before')
app.NewDocument(TCollection_ExtendedString("MDTV-CAF"),h_doc)
I tried to access the pythonocc documentation for different versions of pythonocc but i did not find. I think this code is written for some other version of pythonocc whereas i am using pythonocc 7.4.1.