SolidWorks verwachte functie of variabele fout

Hallo allemaal,

Ik heb deze foutmelding: " Compilatiefout: functie of variabele verwacht "

De fout zit op de volgende regel en de functie " GetTransparency "

Debug.Print swSketchPicture.GetTransparency(Style, Transparency, MatchingColor, MatchingTolerance)

Ik zit op SolidWorks 2022 en de code is als volgt:

Sub recupTranparenceImage()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeat As SldWorks.Feature
Dim swSketchPicture As SldWorks.ISketchPicture
Dim boolstatus As Boolean
'Dim instance As ISketchPicture
Dim Style As Long
Dim Transparency As Double
Dim MatchingColor As Long
Dim MatchingTolerance As Double
 
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'boolstatus = swModel.Extension.SelectByID2("Feuille1", "SHEET", 5.43900806628579E-02, 0.13276815279762, 0, False, 0, Nothing, 0)
swModel.EditTemplate
swModel.EditSketch
boolstatus = swModel.Extension.SelectByID2("Image d'esquisse2", "SKETCHBITMAP", 0.166852606603703, 0.134853758836237, 0, False, 0, Nothing, 0)
Set swSelMgr = swModel.SelectionManager
Set swFeat = swSelMgr.GetSelectedObject6(1, -1)
Set swSketchPicture = swFeat.GetSpecificFeature2
'Debug.Print swSketchPicture.SetTransparency(2, 0.97, 0, 0)

Debug.Print swSketchPicture.GetTransparency(Style, Transparency, MatchingColor, MatchingTolerance)
Debug.Print Transparency
swModel.EditSheet
End Sub

Enig idee wat er mis is?

Hallo

Probeer de retourwaarde om te zetten naar een type dat kan worden weergegeven door een afdruk:

Debug.Print CStr( swSketchPicture.GetTransparency(Style, Transparency, MatchingColor, MatchingTolerance) )

Bedankt @Sylk , maar geen verandering, ik heb nog steeds dezelfde fout.

En hoe zit het met

swSketchPicture.GetTransparency(Style, Transparency, MatchingColor, MatchingTolerance)
Debug.Print Style
Debug.Print Transparency
Debug.Print MatchingColor
Debug.Print MatchingTolerance

Als de functie GetTransparency geen waarde retourneert, moet u de variabelen in de argumenten gebruiken.

1 like

Ja bedankt @Sylk , dat is precies wat ik zojuist heb getest, dankzij je waardereflectie die wordt geretourneerd door de functie:

Sub recupTranparenceImage()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeat As SldWorks.Feature
Dim swSketchPicture As SldWorks.ISketchPicture
Dim boolstatus As Boolean
Dim Style As Long
Dim Transparency As Double
Dim MatchingColor As Long
Dim MatchingTolerance As Double
 
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
swModel.EditTemplate
swModel.EditSketch
boolstatus = swModel.Extension.SelectByID2("Image d'esquisse2", "SKETCHBITMAP", 0.166852606603703, 0.134853758836237, 0, False, 0, Nothing, 0)
Set swSelMgr = swModel.SelectionManager
Set swFeat = swSelMgr.GetSelectedObject6(1, -1)
Set swSketchPicture = swFeat.GetSpecificFeature2

swSketchPicture.GetTransparency Style, Transparency, MatchingColor, MatchingTolerance
Debug.Print Transparency
swModel.EditSheet
End Sub
1 like