-
Posts
585 -
Joined
-
Last visited
Reputation
549 SpectacularPersonal Information
-
Location
Switzerland
Recent Profile Visitors
10,482 profile views
-
Rykarch-ce started following DomC
-
"C:\\Temp\\Output.csv" would work also I would strongly recommend, always create path strings with the path module. So it is as proof as it can be and this works also cross-platform: import os path = os.path.join('C:', 'Temp', 'Output.csv') # or even more propper path = os.path.join('C', os.sep, 'Temp', 'Output.csv')
-
-
I would say maybe a rookie error: #allowed >> produces no errors caching is off vs.SetPref(412, True) # turn off caching #don't do that >> seems to breaks the vs modul or ignore newer methods vs.SetPref(412, False) # turn off caching #allowed >> produces no errors caching is on #vs.SetPref(412, True) # turn off caching
-
Must be specific an issue of my vso 🤔 I will STF (Search Till Found)
-
Hello I have a Vectorscript tool (not Event driven 2024). This tool rund a python module. The tool is working so far. code of the tool PROCEDURE ClickCallback; VAR x1, y1 : REAL; path : STRING; BEGIN SetCursor(LgCrossC); GetPt(x1, y1); PythonExecute('import dev.tool.mod.poly2PIO'); END; RUN( ClickCallback ); the module poly2PIO runs this code: import vs import os #vs.SetPref(412, True) #turn off caching #vs.Message(str(dir(vs))) with open(os.path.expanduser('~') +'/file_vst.txt', "w", encoding='utf-8') as f: f.write('\r'.join(dir(vs))) # error here isOnLine undefined method isOnLine = vs.PtOnLine((0,0), (-10, 0), (10, 0), 0.00001) everything and also vs.PtOnLine() is working. If i use that tool. But then, if i run run another vso (Event Enabled path object) it seems that the vst does not have the same vs-function anymore as before. Also if i use a standard vso (Script Based like the Rolling Stairs) the vs class in my vst do not contains the same methods anymore. import vs #from datetime import datetime import json import math import copy #import uuid import os import base64 import time #import urllib.request import code.common.controler as controler #vs.SetPref(412, False) # turn off caching with open(os.path.expanduser('~') +'/file_vso.txt', "w", encoding='utf-8') as f: f.write('\r'.join(dir(vs))) The functions in the vst does not work anymore. Also other vst's have the same issues now. The special thin i do is, that i run a pascal script and call a python after i click in the drawing. For further debug i write a text file with dir(vs) which lists all methods of the vs class. If i then compare the two files, i can see, that the dump written from file_vst.txt has much less methods available (left) as the file dumped from the vso? Somebody knows if this is a normal limitation or if it is worth for further diving in? I think not many devs wrapps a pascal around a python script so maybe this is a normal limitation that the methods freezed on a specific version or it is just a bug? It looks some-like, that methods after 2014 are not included now for my vst. Anybody knows what could going on? Here a screenshot from the method list compared with diff Merge
-
Module 'certifi' not found on VW2023 / Windows 10 Pro OS
DomC replied to Paolo's topic in Python Scripting
Maybe you make something like this and skip the certificate update? Maybe it is not necessery to import certifi on windows and the request will work without certifi? And then skip the ssl context part. -
Marionette is a Programming-Tool. In such tools wer are in a place to have the force to produce wonderful artwork or unwanted behaviors (crashes?) and comparative we are mostly alone with our artworks. And thanksfully there are forums like this other people can help for bringing those projects to success. I took a look a the Marionette Control-Point and agree, there is some space for improvement: 1. Fixing Axis I think @Gregi wantet to fix one axis. This is not possible because the position of the control-point comes from the Mouse not from a value inside the script. This value is just a default value. To change the control point by script itself is theoretically possible to manipulate the Record of the Marionette Node where the position of the point is stored but it would be very hard (Because also the position of the PIO is involved). So this is not a bug it works the way the feature is designed. 2. Moving 3D Point in Standard View. If I am in a standard view (front right etc.). Lets say from right and I move the point in z-Direction, the x value from the point snaps on the working plane and the x-value gets 0. Which can maybe produces issues in the script inside the PlugIn. So working plane should be used or unwanted values have to be intercepted inside the script (which is always the most costly part). So if the script crash because the width of the pio change to 0 it is not a bug in the code of the 3D modification point. It is just an unhandled error. Error can be handled on different places. In shoft: OK, I can see, that the reshape behaviour of this modi-point can be improved and i will report this as an enhancement Request. 3. Position of the 3D Point outside of PIO geometry. If the Modification Point is the most outside object in a PlugIn. And not geometry is there, the position of the Point somehow is calculated wrong relatively to the object. So in our test with Extrudes etc. it always works as expected. But If the extrude is smaller than the bbox of the modipoint and the 0-point it somehow Fails. I think, this is definitely a bug. I will report. 4. Position of the 3D Point with layer elevation I think this is already known but I try to give it an impact. Generally, there are not much additional layers of error-handling between marionette and the Script Engine. I think the more "idiot-proof" something is made the weaker it is. Not 100% the truth (It could be possible to have both). But this is the way I am still pleased even if my script crashes 😁
-
This may also help
-
OK, the part of the code which I will not paste is the part how you update your certificates by the script on mac computers to make python accept them to communicate over TLS (SSL) (https instead of http). caution should be exercised.
-
The forum allows me not to paste some code ... I think maybe for security reasons. Or your testing api request: import urllib.request import json api_url = "https://jsonplaceholder.typicode.com/todos/1" result_string = '' with urllib.request.urlopen(api_url) as f: result = json.loads(f.read().decode('utf-8')) vs.AlrtDialog(str(result)) An other real example with a http request url, if you can't get https to work import urllib.request import json import math #dezimalgrad in minuten und Sekunden umwandeln (copy paste aus dem Netz) def deg_to_dms(deg, type='lat'): deg = float(deg) decimals, number = math.modf(deg) d = int(number) m = int(decimals * 60) s = (deg - d - m / 60) * 3600.00 compass = { 'lat': ('N','S'), 'lon': ('E','W') } compass_str = compass[type][0 if d >= 0 else 1] return '{}º{}\'{:.2f}"{}'.format(abs(d), abs(m), abs(s), compass_str) h = vs.FSActLayer() x = 2600000 y = 1200000 z = 500 #Nimmt Position von aktiviertem Hilspunkt, Objekt oder Symbol sonst Bern Sternwarte als Vorgabewert if h != vs.Handle(0): x,y,z = vs.GetLocus3D(h) #vs.AlrtDialog(str(vs.GeogCoordToVWN(x, y))) vs.AlrtDialog(str(vs.VWCoordToGeog(x, y))) xPt, yPt, zPt = vs.PtDialog3D('LV95 Koordikante zu WGS84', x, y, z) #Abfragestring auf dem Geportal direkt im Internet url = "http://geodesy.geo.admin.ch/reframe/lv95towgs84?easting="+str(xPt)+"&northing="+str(yPt)+"&altitude="+str(zPt)+"&format=json" result_string = '' with urllib.request.urlopen(url) as f: result = json.loads(f.read().decode('utf-8')) #Antwort vom Geoportal interpretieren und umwandeln in json result_string = str(result['easting']) + '\r' + str(result['northing']) + '\r' + str(result['altitude'])+'\r\r'\ 'Grad: ' result_string += '\r' result_string += 'Grad Minuten Sekunden: \r' + deg_to_dms(result['easting'], 'lat') +' ' + deg_to_dms(result['easting'], 'lon') vs.AlrtDialog(str(result_string))
-
Maybe not necessarely. urllib is a standard library and also should do the job. Give a usable feedback or your request:
-
Marionette Node to insert symbols in rows
DomC replied to DomC's topic in Resource Share - Marionette
Oh, this is an old code and not very nice one. Without testing: 1. The vs.GetType should replaced by: vs.GetTypeN(res) 2. The node returns not the Symbol Name. That means the node itself insert the Symbol. In fact it looks, like the output just returns the last inserted symbol. Which means the node should insert the symbols in the number of rows and should do the job but not returning the resulting symbol handles. With that node, you can't use the output useful disconnect symbol node and print debug node. -
Agree with Letti I would vote for the smart solution using the function node without wrapping.
-
Elite Exhibits started following DomC
-
Edit: Added a New Version 1.0.2. where the script tries to convert non-valid cell numbers to numbers. The script tries to convert every cell so I hope this has no other negative effect. However the the existing Example is Version 2023 and works also on my Windows System with Swiss-German and German Keyboard Layout (Switzerland uses Decimal seperator ".", Germany uses ",").
-