Matthew P Posted December 11, 2024 Share Posted December 11, 2024 I don't know if anyone can help with this. I have been trying to use python scripting to create new classes by importing data from a .cvs file with the class name, lineweight, and pen colour. The script is able to import the name and linewights correctly without any problems. However, when it comes to setting the pen colour it doesn't work and either has just black and white, or semmingly random colours. And help into what i am missing here would be greatly appreciated. import csv import vs # Prompt the user to select the CSV file file_path = vs.GetFile() # Check if a file was selected if file_path: # Read the CSV file with open(file_path, mode='r') as file: csv_reader = csv.DictReader(file) for row in csv_reader: class_name = row['Class Name'] line_weight_mm = float(row['Line Thickness (mm)']) pen_r = int(row['Pen Color (R)']) pen_g = int(row['Pen Color (G)']) pen_b = int(row['Pen Color (B)']) # Convert line weight to mils line_weight_mils = round(line_weight_mm / 0.0254) # Create class and set attributes vs.NameClass(class_name) vs.SetClUseGraphic(class_name, True) vs.SetClLW(class_name, int(line_weight_mils)) # Set line weight vs.SetClPenFore(class_name, pen_r, pen_g, pen_b) vs.SetClPenBack(class_name, pen_r, pen_g, pen_b) vs.SetClFPat(class_name, 0) vs.AlrtDialog('Classes created successfully with correct line weights from the selected CSV file!') else: vs.AlrtDialog('No file was selected. Operation canceled.') Quote Link to comment
Letti R Posted December 12, 2024 Share Posted December 12, 2024 Hello, The RGB values have to be 16 bit. This means they have to be between 0 and something like 65000. For exact values you can look inside some Marionette node. Regards, Letti Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.