Pascal
2015-03-05 22:22:01 UTC
Hello,
I'm not an expert, I just want to experiment python with SolidWorks
I'm trying to use its DLL with some success, but unfortunately, with
some errors :
File "<COMObject <unknown>>", line 2, in Get5
com_error: (-2147352571, 'Type mismatch', None, 5)
I'm not sure about error comment, it's a translation because my python
is in french language.
Here is a simplified extract of code :
app = win32com.client.Dispatch('Sldworks.Application')
part = app.ActiveDoc
docext = part.Extension
custPropMgr = docext.CustomPropertyManager('ma_config')
pNames = tuple(custPropMgr.GetNames) # return array of strings
for item in pNames:
print(item) # string is well printed
var1=''
var2=''
var3=False
custPropMgr.Get5(item, False, var1, var2, var3) <== error happens
here
I tried several things but I didn't reach to pass correctly the
parameters to the Get5 method.
I think the problem is with the ByRef parameters, because I already used
many method with ByVal parameters and it works rather fine.
I tried : var1, var2, var3 = custPropMgr.Get5(item, False) as suggested
somewhere but it didn't works
this method is described as below in the solidworks API help:
Visual Basic (Declaration)
Function Get5( _
ByVal/FieldName <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/ As System.String, _
ByVal/UseCached <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/ As System.Boolean, _
ByRef/ValOut <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/ As System.String, _
ByRef/ResolvedValOut <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/ As System.String, _
ByRef/WasResolved <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/ As System.Boolean _
) As System.Integer
Visual Basic (Usage)
Dim instance AsICustomPropertyManager <http://help.solidworks.com/2015/english/api/sldworksapi/SolidWorks.Interop.sldworks%7ESolidWorks.Interop.sldworks.ICustomPropertyManager.html>
Dim FieldName As System.String
Dim UseCached As System.Boolean
Dim ValOut As System.String
Dim ResolvedValOut As System.String
Dim WasResolved As System.Boolean
Dim value As System.Integer
value = instance.Get5(FieldName, UseCached, ValOut, ResolvedValOut, WasResolved)
C#
System.int Get5(
System.string/FieldName <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/,
System.bool/UseCached <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/,
out System.string/ValOut <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/,
out System.string/ResolvedValOut <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/,
out System.bool/WasResolved <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/
)
C++/CLI
System.int Get5(
& System.String^/FieldName <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/,
& System.bool/UseCached <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/,
& [Out] System.String^/ValOut <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/,
& [Out] System.String^/ResolvedValOut <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/,
& [Out] System.bool/WasResolved <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/
)
Thanks for your help.
Best regards.
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
http://www.avast.com
I'm not an expert, I just want to experiment python with SolidWorks
I'm trying to use its DLL with some success, but unfortunately, with
some errors :
File "<COMObject <unknown>>", line 2, in Get5
com_error: (-2147352571, 'Type mismatch', None, 5)
I'm not sure about error comment, it's a translation because my python
is in french language.
Here is a simplified extract of code :
app = win32com.client.Dispatch('Sldworks.Application')
part = app.ActiveDoc
docext = part.Extension
custPropMgr = docext.CustomPropertyManager('ma_config')
pNames = tuple(custPropMgr.GetNames) # return array of strings
for item in pNames:
print(item) # string is well printed
var1=''
var2=''
var3=False
custPropMgr.Get5(item, False, var1, var2, var3) <== error happens
here
I tried several things but I didn't reach to pass correctly the
parameters to the Get5 method.
I think the problem is with the ByRef parameters, because I already used
many method with ByVal parameters and it works rather fine.
I tried : var1, var2, var3 = custPropMgr.Get5(item, False) as suggested
somewhere but it didn't works
this method is described as below in the solidworks API help:
Visual Basic (Declaration)
Function Get5( _
ByVal/FieldName <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/ As System.String, _
ByVal/UseCached <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/ As System.Boolean, _
ByRef/ValOut <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/ As System.String, _
ByRef/ResolvedValOut <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/ As System.String, _
ByRef/WasResolved <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/ As System.Boolean _
) As System.Integer
Visual Basic (Usage)
Dim instance AsICustomPropertyManager <http://help.solidworks.com/2015/english/api/sldworksapi/SolidWorks.Interop.sldworks%7ESolidWorks.Interop.sldworks.ICustomPropertyManager.html>
Dim FieldName As System.String
Dim UseCached As System.Boolean
Dim ValOut As System.String
Dim ResolvedValOut As System.String
Dim WasResolved As System.Boolean
Dim value As System.Integer
value = instance.Get5(FieldName, UseCached, ValOut, ResolvedValOut, WasResolved)
C#
System.int Get5(
System.string/FieldName <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/,
System.bool/UseCached <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/,
out System.string/ValOut <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/,
out System.string/ResolvedValOut <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/,
out System.bool/WasResolved <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/
)
C++/CLI
System.int Get5(
& System.String^/FieldName <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/,
& System.bool/UseCached <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/,
& [Out] System.String^/ValOut <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/,
& [Out] System.String^/ResolvedValOut <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/,
& [Out] System.bool/WasResolved <http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks%7Esolidworks.interop.sldworks.icustompropertymanager%7Eget5.html#>/
)
Thanks for your help.
Best regards.
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
http://www.avast.com