Beiträge von uuchip
-
-
Wenn du (wie für .CoordXYZ() ) die Basic Header hast, poste unbedingt diese. Das ist AutoIt am nächsten.
Und nochmals:
Poste allen Code IMMER IN CODE-Markierung. Python-Code funktioniert NUR mit Einrückungen und diese verschwinden, wenn du das als reinen Text postest.
Hallo BugFix vielen Dank für die schnelle Antwort!
Klar, ich werde mich an die Spielregeln hier halten, ich bin leider ein wenig eingerostet! Die Frage hat sich nach einigem ausprobieren wahrscheinlich erledigt (SORRY!) und es hakt nun daran, dass bei $frame = 0 das Objekt $display akzeptiert wird, und sogar ein Feld zurückgegeben wird. AuoIt ist so schlau das sogar als Feld zu erkennen. Aber ich bin nicht so schlau jetzt mit den 3200 Eintägen zurecht zu kommen. -
Hallo in die Runde,
mir wurde ja bisher sehr gut weitergeholfen, vielen Dank dafür, aber jetzt stehe ich an einer anderen Stelle wie der Ochse vorm Berg. Die Methode GetData braucht das Objekt §display, was augenscheinlich nicht richtig übergeben wird? Bzw. Autoit kennt diesen Mechanismus so gar nicht?
Fehler Meldung>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "O:\archiv\prg\prg\programmieren\sprachen\AutoIt\test\PolyTec\polytec01.au3" /UserParams
+>12:08:56 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0) Keyboard:00000407 OS:WIN_10/2009 CPU:X64 OS:X64 Environment(Language:0407) CodePage:0 utf8.auto.check:4
+> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\Lutz\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Lutz\AppData\Local\AutoIt v3\SciTE
>Running AU3Check (3.3.14.5) from:C:\Program Files (x86)\AutoIt3 input:O:\archiv\prg\prg\programmieren\sprachen\AutoIt\test\PolyTec\polytec01.au3
+>12:08:57 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "O:\archiv\prg\prg\programmieren\sprachen\AutoIt\test\PolyTec\polytec01.au3"
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
polytec01.au3 (98) : ==> COM Error intercepted !
err.number is: 0x80020009
err.windescription: Ausnahmefehler aufgetreten.
err.description is: This condition is false:
'signalCopyInfo.m_lFrame >= 0 && signalCopyInfo.m_lFrame < psfp->nFrames'
err.source is: Function: 'CMediaStreamToData::CopyFftMediaSample()'
File: 'D:\TF\12\s\Main\Vib\Vibcommon\PolyFile\MediaStreamToData.cpp'
Line: 1016
err.helpfile is:
err.helpcontext is: -2143075517
err.lastdllerror is: 0
err.scriptline is: 98
err.retcode is: 0x80434343
+>12:08:57 AutoIt3.exe ended.rc:0
+>12:08:57 AutoIt3Wrapper Finished.
>Exit code: 0 Time: 1.997
In Phyton sieht eine ähnliche Funktion so aus ->
def GetPointData(filename, domainname, channelname, signalname, displayname, point, frame):
"""
% [x,y,usd] = GetPointData(filename, domainname, channelname, signalname, displayname,
% point, frame)
%
% Gets original or user defined data from a polytec file.
%
% filename is the path of the .pvd or .svd file
% domainname is the name of the domain, e.g. 'FFT' or 'Time'
% channelname is the name of the channel, e.g. 'Vib' or 'Ref1' or 'Vib &
% Ref1' or 'Vib X' or 'Vib Y' or 'Vib Z'.
% signalname is the name of the signal, e.g. 'Velocity' or 'Displacement'
% displayname is the name of the display, e.g. 'Real' or 'Magnitude' or
% 'Samples'. If the display name is 'Real & Imag.' the data is returned
% as complex values.
% point is the (1-based) index of the point to get data from. If point is
% 0 the data of all points will be returned. y will contain the data of
% point i at row index i.
% frame is the frame number of the data. for data acquired in MultiFrame
% mode, 0 is the averaged frame and 1-n are the other frames. For user
% defined datasets the frame number is in the range 1-n where n is the
% number of frames in the user defined dataset. For all other data,
% use frame number 0.
%
% returns x, the x axis values of the data
% returns y, the data. colomns correspond to the x-axis, rows to the point
% index. for point = 0: rows for points that have no data are set to zeros.
% returns usd, a struct describing the signal
"""
file = win32com.client.Dispatch('PolyFile.PolyFile')
#Make sure that you can write to the file
file_path = filename
# file_path = os.path.join(".", filename)
file.ReadOnly = False
file.Open(file_path)
usd = ClassData
pointdomains = file.GetPointDomains();
pointdomain = pointdomains.Item(domainname);
channel = pointdomain.Channels.Item(channelname);
signal = channel.Signals.Item(signalname);
display = signal.Displays.Item(displayname);
signalDesc = signal.Description;
xaxis = signalDesc.XAxis;
yaxis = signalDesc.YAxis;
x = np.linspace(xaxis.Min, xaxis.Max, xaxis.MaxCount)
usd.Name = signalDesc.Name;
usd.Complex = signalDesc.Complex;
usd.DataType = signalDesc.DataType;
usd.DomainType = signalDesc.DomainType;
usd.FunctionType = signalDesc.FunctionType;
usd.PowerSignal = signalDesc.PowerSignal;
usd.Is3D = (signalDesc.ResponseDOFs.Count > 0) and (not str(signalDesc.ResponseDOFs.Direction).find('ptcVector'))
responseDOFs = signalDesc.ResponseDOFs;
usd.ResponseDOFs = []
if responseDOFs.Count == 0:
usd.ResponseDOFs = []
else:
for i in range(1,responseDOFs.Count+1):
usd.ResponseDOFs.append(responseDOFs.Item(i))
referenceDOFs = signalDesc.ReferenceDOFs
usd.ReferenceDOFs = []
if referenceDOFs.Count == 0:
usd.ReferenceDOFs = []
else:
for i in range(1,referenceDOFs.Count):
usd.ReferenceDOFs.append(referenceDOFs.Item(i))
usd.DbReference = signalDesc.DbReference
usd.XName = xaxis.Name
usd.XUnit = xaxis.Unit
usd.XMin = xaxis.Min
usd.XMax = xaxis.Max
usd.XCount = xaxis.MaxCount
usd.YName = yaxis.Name
usd.YUnit = yaxis.Unit
usd.YMin = yaxis.Min
usd.YMax = yaxis.Max
datapoints = pointdomain.datapoints
if (point == 0):
# % get data of all points
y = []
nr_datapoints = datapoints.count
# y = np.zeros((int(nr_datapoints),int(usd.XCount)))
for i in range(nr_datapoints):
datapoint = datapoints.Item(i+1);
ytemp = np.array(datapoint.GetData(display, frame));
# y[i,:] = ytemp
y.append(ytemp)
file.Close()
return (x,y,usd)
VG Lutz
AutoIt
Alles anzeigenFunc _GetPointData($domainname,$channelname,$signalname,$displayname,$point,$frame) Local $pointdomains = $oPolyFile.GetPointDomains() Local $pointdomain = $pointdomains.Item($domainname) Local $channel = $pointdomain.Channels.Item($channelname) Local $signal = $channel.Signals.Item($signalname) Local $display = $signal.Displays.Item($displayname) ; writeln(IsObj($signal)) ; Exit Local $signalDesc = $signal.Description Local $usd_Name = $signalDesc.Name Local $usd_Complex = $signalDesc.Complex Local $usd_DataType = $signalDesc.DataType Local $usd_DomainType = $signalDesc.DomainType Local $usd_FunctionType = $signalDesc.FunctionType Local $usd_PowerSignal = $signalDesc.PowerSignal; ;usd.Is3D = signalDesc.ResponseDOFs.Count > 0 && ~isempty(strfind(signalDesc.ResponseDOFs.Direction, 'ptcVector')); Local $responseDOFs = $signalDesc.ResponseDOFs ; writeln($usd_Name,$usd_Complex,$usd_DataType,$usd_DomainType,$usd_FunctionType,$responseDOFs.Item(1)) ; writeln(($responseDOFs.Item(1).Direction)) Local $datapoints = $pointdomain.datapoints Local $datapoint = $datapoints.Item($point+1) writeln($datapoint.GetData($display,$frame)) EndFunc
-
Zur Zeit sieht es so aus, ohne Schnickschnal schreibe ich die relavanten Werte (z.Z. sind nur die Ortskoordinaten implementiert) in Felder, dann werden die Felder verbunden und als CSV abgespeichert. Alte Schule Mittelstufe halt.
AutoIt
Alles anzeigen#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_Run_AU3Check=y #AutoIt3Wrapper_Run_Au3Stripper=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;#AutoItSetOption("ExpandVarStrings",1) #include-once #include "O:\archiv\prg\prg\programmieren\sprachen\AutoIt\Include\__ALL00.au3" ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc $svdfile = "sin_400Hz_5V.svd" Func _PolytecIni($filename) Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Global $oPolyFile = ObjCreate('PolyFile.PolyFile') $oPolyFile.Open($filename) EndFunc Func _GetXYZCoordinates($point) Local $measpoints, $measpoint, $aXYZ[3] Local $X, $Y, $Z $oPolyFile.Infos.MeasPoints.Item($point).CoordXYZ($X,$Y,$Z) $aXYZ[0] = $X $aXYZ[1] = $Y $aXYZ[2] = $Z Return($aXYZ) EndFunc Func _GetXYZNumbers() Return $oPolyFile.Infos.MeasPoints.count EndFunc Func _GetXYZCoordinatesAll() local $count = _GetXYZNumbers() local $list[$count+1][4],$dlist[3],$i $list[0][0] = "Nummer" $list[0][1] = "X" $list[0][2] = "Y" $list[0][3] = "Z" For $i = 1 to $count $dlist = _GetXYZCoordinates($i) $list[$i][0] = $i $list[$i][1] = $dlist[0] $list[$i][2] = $dlist[1] $list[$i][3] = $dlist[2] Next Return $list EndFunc _PolytecIni($svdfile) ;_ArrayDisplay(_GetXYZCoordinates(1)) ;_ArrayDisplay(_GetXYZCoordinates(2)) ;writeln(_GetXYZNumbers()) ;_ArrayDisplay(_GetXYZCoordinatesAll()) $oPolyFile.Close() Exit
-
Ich habe trotzdem nochmal meine Funktion umgebaut anhand deiner Lösung und zusätzlich die Variante implementiert, X,Y,Z einer Messstelle als Struktur auszugeben. Ich empfinde das schon aus syntaktischen Gründen recht hilfreich, da $aResult[$i].X aussagekräftiger ist als $aResult[$i][0].
AutoIt
Alles anzeigen$aResult = _GetXYZCoordinates('..\File', 25, True) ConsoleWrite('Ergebnis Messstelle "25":' & @CRLF) ConsoleWrite($aResult[0].X & @CRLF) ConsoleWrite($aResult[0].Y & @CRLF) ConsoleWrite($aResult[0].Z & @CRLF) Func _GetXYZCoordinates($filename, $point=0, $bStructArray=False) Local $oPolyFile = ObjCreate('PolyFile.PolyFile') Local $measpoints, $measpoint ; Messstellen mit Daten Local $tagXYZ = "double X;double Y;double Z;", $tXYZ If IsObj($oPolyFile) Then $oPolyFile.Open($filename) $measpoints = $oPolyFile.Infos.MeasPoints Local $aXYZ[$measpoints.count][3] ; Das ist das Ergebnisarray, 1.Dim: Anzahl Messstellen, 2.Dim: Einträge X,Y,Z If $bStructArray Then ReDim $aXYZ[$measpoints.count] ; jedes Item enthält die XYZ-Struktur, somit nur eine Dim erforderlich If $point = 0 Then For $i = 1 To $measpoints.count Local $X = 0, $Y = 0, $Z = 0 ; zur Aufnahme der XYZ-Koordinaten EINES Messpunktes $measpoint = $measpoints.Item($i) ; liefert Objekt für eine Messstelle(i) zurück $measpoint.CoordXYZ($X, $Y, $Z) ; befüllt X,Y,Z für das Messstellenobjekt If $bStructArray Then $tXYZ = DllStructCreate($tagXYZ) $tXYZ.X = $X $tXYZ.Y = $Y $tXYZ.Z = $Z $aXYZ[$i-1] = $tXYZ Else $aXYZ[$i-1][0] = $X $aXYZ[$i-1][1] = $Y $aXYZ[$i-1][2] = $Z EndIf Next Else Local $X = 0, $Y = 0, $Z = 0 $measpoint = $measpoints.Item($point) $measpoint.CoordXYZ($X, $Y, $Z) If $bStructArray Then $tXYZ = DllStructCreate($tagXYZ) $tXYZ.X = $X $tXYZ.Y = $Y $tXYZ.Z = $Z $aXYZ[0] = $tXYZ Else $aXYZ[0][0] = $X $aXYZ[0][1] = $Y $aXYZ[0][2] = $Z EndIf EndIf $oPolyFile.Close() Return $aXYZ Else If $oPolyFile.IsOpen = 1 Then $oPolyFile.Close() EndIf Return SetError(1) EndIf EndFunc
Dankeschön! Und ganz klar kann man es moderner und besser machen in einer modernere Syntax, die mehr Menschen anspricht! Ich alter Sack habe aber mit dem TI59 angefangen zu Programmieren, und später mit FORTRAN IV weiter gem,acht, da kommt mir das einfache Autoit sehr zu pass.
-
Sehr verwunderlich, zumal in Matlab und Python die Methode ohne Parameter aufgerufen und das Ergebnis in einem Array aufgefangen wird.
Aber wenn es funktioniert, ist ja OK. Kannst den Thread dann ja als "Gelöst" markieren.
EDIT:
Das kommt davon, wenn man versucht mit dem Smartphone im Forum "rumzuwerkeln". Dadurch hatte ich überlesen, dass du im Startpost die Beschreibung der Methode gepostet hattest.
Somit ist es eher anders herum verwunderlich, denn die Methode erfordert 3 Parameter - wie das Matlab und Python -Skript ohne operieren können ist mir nicht ganz klar.
Hallo BugFix, das Thema vorläufig als "gelöst" markiert. Mir als technischer Anwender der ab und an ein Schweizer-Taschenmesser braucht reicht die Lösung, auch wenn ich die so nicht erwartet hätte. Ein großes Lob geht ein Dich und auch water; habe damit auch was mit Nährwert gelernt, nämlich wie man COM Fehler konkret ausliest. Im übrigen finde ich es schade, dass ihr im Forum recht wenig los ist, obwohl AutoIt so sehr nützlich ist, im vergleich zu anderen Programmiersprachen. VG Lutz
-
Hallo nochmal, das Problem scheint gelöst, und zwar mit einer ganz trivialen Umsetzung (einzelner Messpunkt) ->
Local $X, $Y, $Z$measpoint = $measpoints.Item($point)
$measpoint.CoordXYZ($X,$Y,$Z)
$aXYZ[0] = $X
$aXYZ[1] = $Y
$aXYZ[2] = $Z
$oPolyFile.Close()
AutoIt scheint mir hier an dieser Stelle für Menschen die in anderen Sprachen programmieren viel zu einfach zu sein.
-
Poste am Besten auch die Python und .NET Lösung. Damit können wir vermutlich noch mehr anfangen.
Ausser den Matlab Modulen ist in den anderen Programmiersprachen die Lösung viel zu komlex, die fragen da nämlich nicht nur die Ortskoordinaten eines Messpunkts ab, sondern noch ein paar andere "lustige" sachen, mit dennen ich mich aber erst dann beschäftige wenn das ganz einfache läuft.
Gefunden habe ich auf github eine relativ einfache Phyton Umsetzung die u.a. anderen auch dieses GetXYZ benutzt.
Python
Alles anzeigenimport numpy as np import win32com.client import os import json class ClassData: pass from json import JSONEncoder class NumpyArrayEncoder(JSONEncoder): FORMAT_SPEC = '@@{}@@' def default(self, obj): if isinstance(obj, np.ndarray): return obj.tolist() # if isinstance(obj, np.ndarray): # return self.FORMAT_SPEC.format(id(obj)) # # return obj.tolist() # return JSONEncoder.default(self, obj) def GetPointData(filename, domainname, channelname, signalname, displayname, point, frame): """ % [x,y,usd] = GetPointData(filename, domainname, channelname, signalname, displayname, % point, frame) % % Gets original or user defined data from a polytec file. % % filename is the path of the .pvd or .svd file % domainname is the name of the domain, e.g. 'FFT' or 'Time' % channelname is the name of the channel, e.g. 'Vib' or 'Ref1' or 'Vib & % Ref1' or 'Vib X' or 'Vib Y' or 'Vib Z'. % signalname is the name of the signal, e.g. 'Velocity' or 'Displacement' % displayname is the name of the display, e.g. 'Real' or 'Magnitude' or % 'Samples'. If the display name is 'Real & Imag.' the data is returned % as complex values. % point is the (1-based) index of the point to get data from. If point is % 0 the data of all points will be returned. y will contain the data of % point i at row index i. % frame is the frame number of the data. for data acquired in MultiFrame % mode, 0 is the averaged frame and 1-n are the other frames. For user % defined datasets the frame number is in the range 1-n where n is the % number of frames in the user defined dataset. For all other data, % use frame number 0. % % returns x, the x axis values of the data % returns y, the data. colomns correspond to the x-axis, rows to the point % index. for point = 0: rows for points that have no data are set to zeros. % returns usd, a struct describing the signal """ file = win32com.client.Dispatch('PolyFile.PolyFile') #Make sure that you can write to the file file_path = filename # file_path = os.path.join(".", filename) file.ReadOnly = False file.Open(file_path) usd = ClassData pointdomains = file.GetPointDomains(); pointdomain = pointdomains.Item(domainname); channel = pointdomain.Channels.Item(channelname); signal = channel.Signals.Item(signalname); display = signal.Displays.Item(displayname); signalDesc = signal.Description; xaxis = signalDesc.XAxis; yaxis = signalDesc.YAxis; x = np.linspace(xaxis.Min, xaxis.Max, xaxis.MaxCount) usd.Name = signalDesc.Name; usd.Complex = signalDesc.Complex; usd.DataType = signalDesc.DataType; usd.DomainType = signalDesc.DomainType; usd.FunctionType = signalDesc.FunctionType; usd.PowerSignal = signalDesc.PowerSignal; usd.Is3D = (signalDesc.ResponseDOFs.Count > 0) and (not str(signalDesc.ResponseDOFs.Direction).find('ptcVector')) responseDOFs = signalDesc.ResponseDOFs; usd.ResponseDOFs = [] if responseDOFs.Count == 0: usd.ResponseDOFs = [] else: for i in range(1,responseDOFs.Count+1): usd.ResponseDOFs.append(responseDOFs.Item(i)) referenceDOFs = signalDesc.ReferenceDOFs usd.ReferenceDOFs = [] if referenceDOFs.Count == 0: usd.ReferenceDOFs = [] else: for i in range(1,referenceDOFs.Count): usd.ReferenceDOFs.append(referenceDOFs.Item(i)) usd.DbReference = signalDesc.DbReference usd.XName = xaxis.Name usd.XUnit = xaxis.Unit usd.XMin = xaxis.Min usd.XMax = xaxis.Max usd.XCount = xaxis.MaxCount usd.YName = yaxis.Name usd.YUnit = yaxis.Unit usd.YMin = yaxis.Min usd.YMax = yaxis.Max datapoints = pointdomain.datapoints if (point == 0): # % get data of all points y = [] nr_datapoints = datapoints.count # y = np.zeros((int(nr_datapoints),int(usd.XCount))) for i in range(nr_datapoints): datapoint = datapoints.Item(i+1); ytemp = np.array(datapoint.GetData(display, frame)); # y[i,:] = ytemp y.append(ytemp) file.Close() return (x,y,usd) def GetXYZCoordinates(filename, point): """ % Gets XYZ coordinates of the scan points from a polytec file. % % This is only possible for files containing 3D geometry or that have % a distance to the object specified. Otherwise there will be an % error message. % % filename is the path of the .svd file % % point is the (1-based) index of the point to get the coordinates from. If point is % 0 the coordiantes of all points will be returned. XYZ will contain the data of % point i at row index i. % % returns the xyz coordinates. columns correspond to the geometry X, Y, Z % in meter, rows to the point index. """ file = win32com.client.Dispatch('PolyFile.PolyFile') #Make sure that you can write to the file file.ReadOnly = False file_path = filename file.Open(file_path) measpoints = file.Infos.MeasPoints; if point == 0: XYZ = [] for i in range(measpoints.count): measpoint=measpoints.Item(np.int32(i+1)); [X,Y,Z] = measpoint.CoordXYZ(); # XYZ(i,:)=[X,Y,Z]; XYZ.append([X,Y,Z]) return XYZ def CreateDataDict(filename, domainname, vib_channelname, vib_signalname, ref_channelname, ref_signalname, displayname, point, frame): print("Opening", filename) time,displacement,usd = GetPointData(filename, domainname, vib_channelname, vib_signalname, displayname, point, frame) time,voltage,usd = GetPointData(filename, domainname, ref_channelname, ref_signalname, displayname, point, frame) XYZ = GetXYZCoordinates(filename, point) nr_points = len(displacement) print("Loaded %d measurements points with %d samples"%(nr_points, len(displacement[0]))) data = dict() data["filename"] = filename data["domainname"] = domainname data["vib_channelname"] = vib_channelname data["vib_signalname"] = vib_signalname data["ref_channelname"] = ref_channelname data["ref_signalname"] = ref_signalname data["displayname"] = ref_signalname data["nr_points"] = nr_points a =1 for i in range(nr_points): data[i] = dict() data[i]['x'] = XYZ[i][0] data[i]['y'] = XYZ[i][1] data[i]['z'] = XYZ[i][2] data[i]['time'] = time data[i]['voltage'] = voltage[i] data[i]['displacement'] = displacement[i] out_filename = filename+".json" print("Saving data to %s"%(out_filename)) with open(out_filename, "w") as outfile: json.dump(data, outfile, cls=NumpyArrayEncoder, indent=4) print("Done saving data to %s"%(out_filename)) return data def save_dict2json(data, out_filename): with open(out_filename, "w") as outfile: json.dump(data, outfile, cls=NumpyArrayEncoder, indent=4) if __name__ == "__main__": filename = "SA_01_left.svd" domainname = "Time" vib_channelname = "Vib" vib_signalname = "Displacement" ref_channelname = "Ref1" ref_signalname = "Voltage" displayname = "Samples" point = 0 frame = 0 data = CreateDataDict(filename, domainname, vib_channelname, vib_signalname, ref_channelname, ref_signalname, displayname, point, frame)
EDIT BugFix: Code in Code-Tags gepackt
-
Ich habe gerade mal euere Vorschläge berücksichtigt, und auf Grundllage der Funktion von Bugfix um gesetzt. Herraus kommt eine braucbare Fehlermeldung, die ich so interpretiere das man der Methode GetXYZ() "nur" was sinnvolles in den Klammern vorgeben muss. VG Lutz
>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "O:\archiv\prg\prg\programmieren\sprachen\AutoIt\test\PolyTec\01.au3" /UserParams
+>07:54:45 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0) Keyboard:00000407 OS:WIN_10/2009 CPU:X64 OS:X64 Environment(Language:0407) CodePage:0 utf8.auto.check:4
+> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\Lutz\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Lutz\AppData\Local\AutoIt v3\SciTE
>Running AU3Check (3.3.14.5) from:C:\Program Files (x86)\AutoIt3 input:O:\archiv\prg\prg\programmieren\sprachen\AutoIt\test\PolyTec\01.au3
+>07:54:45 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "O:\archiv\prg\prg\programmieren\sprachen\AutoIt\test\PolyTec\01.au3"
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
01.au3 (20) : ==> COM Error intercepted !
err.number is: 0x8002000E
err.windescription: Unzulässige Parameteranzahl.
err.description is:
err.source is:
err.helpfile is:
err.helpcontext is:
err.lastdllerror is: 0
err.scriptline is: 20
err.retcode is: 0x00000000
+>07:55:18 AutoIt3.exe ended.rc:0
+>07:55:18 AutoIt3Wrapper Finished.
>Exit code: 0 Time: 33.37
Code
Alles anzeigen$svdfile = "SA_01_left.svd" Func _GetXYZCoordinates($filename, $point) Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local $oPolyFile = ObjCreate('PolyFile.PolyFile') Local $measpoints, $aXYZ[3] If IsObj($oPolyFile) Then $oPolyFile.Open($filename) $measpoints = $oPolyFile.Infos.MeasPoints Local $XYZ[$measpoints.count][3] If $point = 0 Then For $i=1 To $measpoints.count $measpoint = $measpoints.Item($i) $aXYZ = $measpoint.CoordXYZ() ;~ XYZ(i,:) = [X,Y,Z] ; was passiert da? Ist das syntactic sugar für: ;~ Durchlaufe das Array XYZ in der 1.Dimension "i" für alle Einträge der 2.ten Dimension? Next Else $measpoint = $measpoints.Item($point) $aXYZ = $measpoint.CoordXYZ() If @error Then MsgBox("", "COM Error", "@error is set to COM error number." & @CRLF & "@error = 0x" & Hex(@error)) ;~ XYZ=[X,Y,Z] ; was passiert da? EndIf $oPolyFile.Close() ; --- Irgendwo hier muss dann: Return $aXYZ erfolgen Else If $oPolyFile.IsOpen = 1 Then $oPolyFile.Close() EndIf EndIf EndFunc ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc _GetXYZCoordinates($svdfile,1)
-
ich habe eure Vorschläge noch nicht umgesetzt werde es gleich machen und dann berichten. Herzlich bedanken möchte ich mich aber schon jetzt, mit soviel positiver Resonanz habne ich nicht gerechnet.
OT: Diese Funktion und auch andere werden benötigt über COM Messdaten aus einer Datei zu ziehen, die mit einem Laservibrometer-Software erstellt wurden. Phyton, Matlab, .NET Lösungen sind vorhanden, ich möchte aber für so etwas mein Schweizer-Taschenmesser Autoit weiter nutzen. Das ist übrigns so ziemlcih die einzige Anwendung die ich als nun Linux Anwender unter wine weiterhin nutze, da läuft fast alles ausser USB Unterstützung und eben COM was auf .NET (>4.6) aufsetzt.
-
Hallo BugFix,
danke für die schnelle Antwort, ich habe es mal wie nachfolgend probiert:$svdfile = "SA_01_left.svd"
Func GetXYZCoordinates($filename) ;, $domainname, $channelname, $signalname, $displayname, $point, $frame)
Local $i, $measpoint, $dummy, $X, $Y, $Z
Local Const $tagXYZ = "double X;double Y;double Z;"
Local $tXYZ = DllStructCreate($tagXYZ)
Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
Local $file = ObjCreate("PolyFile.PolyFile")
Local $dummy = $file.Open($filename)
; Local $dummy = $file.ReadOnly(0)
$measpoints = $file.Infos.MeasPoints
; $pointdomains = $file.GetPointDomains()
; $pointdomain = pointdomains.Item($domainname);
; $channel = pointdomain.Channels.Item($channelname);
; $signal = channel.Signals.Item($signalname);
; $display = signal.Displays.Item(displayname);
For $i = 1 to $measpoints.Count
writeln($i)
$measpoint = $measpoints.Item(Int(2,1))
$measpoint.CoordXYZ($tXYZ)
Next
EndFunc
GetXYZCoordinates($svdfile)
Leider mit der Meldung ->"O:\archiv\prg\prg\programmieren\sprachen\AutoIt\test\PolyTec\00.au3" (34) : ==> The requested action with this object has failed.:
$measpoint.CoordXYZ($tXYZ)
$measpoint^ ERROR
Das heist der Objekt ist da, aber kann nicht angesprochen weden. VG Lutz
-
Hallo und guten Tag,
auf COM Objekte zuzugreifen ist ja in AutoIt3 normalerweise die kleinste Übung, aber bei der Übersetzung nachfolgenden Matlab- Codes scheitere ich.
function XYZ = GetXYZCoordinates(filename, point)
%
file = actxserver('PolyFile.PolyFile');
try
file.Open(filename);
measpoints = file.Infos.MeasPoints;
if (point == 0)
XYZ=zeros(measpoints.count,3);
for i=1:measpoints.count
measpoint=measpoints.Item(int32(i));
[X,Y,Z]=measpoint.CoordXYZ();
XYZ(i,:)=[X,Y,Z];
end
else
measpoint=measpoints.Item(int32(point));
[X,Y,Z]=measpoint.CoordXYZ();
XYZ=[X,Y,Z];
end
file.Close();
delete(file);
catch
if file.IsOpen == 1
file.Close();
end
delete(file);
rethrow(lasterror);
end
und zwar an der Stelle [X,Y,Z]=measpoint.CoordXYZ();
Der Basic Header der Methode sieht so ausPublic Sub CoordXYZ( _
ByRef pdX As Double, _
ByRef pdY As Double, _
ByRef pdZ As Double _
)
Das heisst diese Methode erzeugt drei "Double" die mit "BeRef" übergeben werden.
Der erste naive Ansatz das mit dem Autoit "ByRef" zu machen funzt natürlich nicht, aber auch wenn man es mit z.B. mitLocal Const $tagXYZ = "struct;double"
Local $tX = DllStructCreate($tagXYZ)
Local $tY = DllStructCreate($tagXYZ)
Local $tZ = DllStructCreate($tagXYZ)
&
$measpoint.CoordXYZ($tX,$tY,$tZ)versucht klappt es leider nicht.
Vielen Dank für dioe Aufmerksamkeit & VG
Lutz -
Hallo,
meine Idee wäre es, das ganze auch mal mit der FANN UDF in Autoit zu probieren. Soweit ich mich noch erinnern kann kann man damit schnelle NN basteln.
LG
-
Die von AspirinJunkie eingestellte Yacas dll nutze ich auch sehr oft, z.B. zum Rechnen mit großen Zahlen. Mann kann die Verwendung mit AutoItSetOption ( "ExpandVarStrings",1) noch ein wenig vereinfachen, denn dann kann man ohne lästiges '&' die Variablen direkt z.B mit "$x$*$y$" nach Yacas senden.
Besten Gruß
P.S.: Yacas wir wieder weiter entwickelt, leider haben die neuen DLL eine andere Struktur mit der ich nicht klar komme, wäre das nicht ein Projekt für die Fachleute?
-
-
Hallo lep230,
ich glaube das OpenCascade und Salome für Deine Zwecke viel zu mächtig sind. Versuche es erst mal mit der OpenGL UDFs (2.0). Mit dieser UDF kann man u.a. auch Punkte vernetzen, und das Netz, was leicht aus STL Daten generiert werden kann, mit beliebigen Texturen und Farben in Echtzeit darstellen.
Besten Gruß
-
Ich bin beeindruckt! THX & Beste Grüße
-
Hallo,
ich hab auch mal damals so etwas programmiert:
Gleichungslöser für AutoIt3Und eine Erweiterung für nicht lineare Gleichungssysteme:
Nicht linearer mehrdimensionaler Gleichungslöser nach NewtonBeste Grüße
-
-
Hallo Zusammen,
ich experimentiere gerade etwas mit tollen AutoItObject und habe dazu eine Anfängerfrage, nämlich wie bette ich Objekte in Objekte ein? Hier mal mein erfolgloser Versuch:
[autoit]
[/autoit][autoit][/autoit][autoit]
#include "AutoitObject.au3"_AutoItObject_Startup()
[/autoit][autoit][/autoit][autoit]
; einfachstes Objekt
Func _Object_1()
Local $oClassObject = _AutoItObject_Class()
$oClassObject.Create()
$oClassObject.AddProperty("x")
$oClassObject.AddDestructor("_DestructorForSomeObject")
Return $oClassObject.Object
EndFunc; einfache vererbung funktioniert
[/autoit][autoit][/autoit][autoit]
Func _Object_2()
Local $oClassObject = _AutoItObject_Class()
$oClassObject.Create(_Object_1())
$oClassObject.AddProperty("y")
$oClassObject.AddDestructor("_DestructorForSomeObject")
Return $oClassObject.Object
EndFunc; einbetten von objekten geht so nicht!
[/autoit][autoit][/autoit][autoit]
Func _Object_3()
Local $oClassObject = _AutoItObject_Class()
Local $test = _Object_1()
$oClassObject.Create()
$oClassObject.AddProperty($test)
$oClassObject.AddDestructor("_DestructorForSomeObject")
Return $oClassObject.Object
EndFunc$oTest1 = _Object_1()
[/autoit][autoit][/autoit][autoit][/autoit][autoit]
$oTest2 = _Object_2()
$oTest3 = _Object_3()$oTest1.x = 4711
[/autoit][autoit][/autoit][autoit][/autoit][autoit]
$oTest2.y = 815
$oTest3.test.x = 7consolewrite($oTest1.x&@CRLF)
[/autoit]
consolewrite($oTest2.y&@CRLF)
consolewrite($oTest3.test.x&@CRLF)Vielen Dank für die Hilfe und beste Grüße
uuchip