ni / ni/nidaqmx-python

Cannot overwrite custom scales

Open
#670 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
592
Forks
199
Avg merge
1d 16h
Merged PRs (30d)
10

Description

When saving a custom scale, I receive a DaqError if the scale already exists in NI MAX even when using overwrite_existing_scale=True. The example below will run fine the first time when creating the scale, but will fail If I try to run it again now that the scale exists in NI MAX.

Windows 10
NI MAX 2024 Q4
NI-DAQmx 2024 Q4 (24.8.0)
Python 3.11.11 running in Spyder 6.0.1 (conda)
nidaqmx 1.0.2

Sample code:

import nidaqmx
from nidaqmx.constants import UnitsPreScaled

scale = nidaqmx.scale.Scale.create_lin_scale('ch1_V',
                                     10, # slope
                                     0, # intercept
                                     pre_scaled_units=UnitsPreScaled.VOLTS,
                                     scaled_units='V')
scale.save(author="Me",
           overwrite_existing_scale=True,
           allow_interactive_editing=True,
           allow_interactive_deletion=True)

Error message:

Traceback (most recent call last):

  File ~\.conda\envs\env_gui\Lib\site-packages\spyder_kernels\customize\utils.py:209 in exec_encapsulate_locals
    exec_fun(compile(code_ast, filename, "exec"), globals)

  File c:\users\me\untitled0.py:24
    scale = nidaqmx.scale.Scale.create_lin_scale('ch1_V',

  File ~\.conda\envs\env_gui\Lib\site-packages\nidaqmx\scale.py:338 in create_lin_scale
    scale._interpreter.create_lin_scale(

  File ~\.conda\envs\env_gui\Lib\site-packages\nidaqmx\_library_interpreter.py:1764 in create_lin_scale
    self.check_for_error(error_code)

  File ~\.conda\envs\env_gui\Lib\site-packages\nidaqmx\_library_interpreter.py:6412 in check_for_error
    raise DaqError(extended_error_info, error_code)

DaqError: Custom scale cannot be created. A saved scale with this name already exists.

Scale Name: ch1_V

Status Code: -200356

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with nidaqmx/scale.py at create_lin_scale and save, then follow the corresponding calls in nidaqmx/_library_interpreter.py. Re-run the supplied sample against an existing NI MAX scale and trace where creation fails before overwrite_existing_scale is applied. Done means saving the same named custom scale succeeds with overwrite_existing_scale=True.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.