hexagon logo

Custom code to reduce data entry

I wasn't sure to post this in the code section as I don't have code to share.

I'm absolutely NOT a coder nor do I want to learn anything but the basics, it just isn't my thing. However, I did learn enough python to cut data entry in half with our GOM software. I'm looking to get a few data entry fields removed in pcdmis now. Not critical, just one of those small improvements to make operator life better.

I've read that pcdmis code is 'BASIC' language based, and you can export this language somewhow. Then I've read it is written in C++ by a post by Neil and my head starts spinning. Can someone share how I export pcdmis command mode stuff into BASIC language export?

I see ASSIGN in pcdmis when I do a variable yet, in BASIC a variable is defined like so:

Dim item_number as String
item_number = "S-12345"


If I drop stuff like the above into pcdmis command mode is it going to understand it? Did I read correctly that is understands BASIC language. I don't feel like dealing with pulling Python programs into the dmis.

Thanks.

  • Hello,

    the answer to this question is simple: no, it doesn't work that way.
    why is something more complicated.

    The interface for data exchange or automation is in Basic and thats it.

    in "C++" or "Object Pascal" and probably also in "Phyton" you can include and use the pcDMIS-Basic-DLL. How this is done in the respective language would lead too far here.

    I strongly advise against writing scripts or automations for someone without understanding them yourself.

    (if you can explain to us exactly what you intend to do and if it's not too much, maybe someone will write it for you.)

    ########################

    * ASSIGN is a program-internal pcDMIS command that is only understood by this software within the Editwindow
    * if you write "basic" or "C++"-code in pc-dmis Editwindow, he will not understand this

    ########################

    if you still want to familiarize yourself with it, I recommend that you write an Excel macro that controls pcDMIS. something easy eg open a program.

    Excel macros are in basic, there are many examples online, if it works you can google how to translate it to python.
  • If you would export the PC-DMIS program as BASIC (available under File -> Export) and drop your string definition in that exported .bas file, there is a good possibility that PC-DMIS will understand that during import of the .bas file into PC-DMIS again. You cannot use that type of definition directly in PC-DMIS, but you may in the script editor (which essentially is VB).
  • it sounds like you're getting confused between how the core code of PC-DMIS is handled and all of the various ways of interacting with a routine through the edit window. To clarify, the PC-DMIS core application is written in C++ but that code is not something a general user would have access to, it is only available to Hexagon software developers. When it comes to PC-DMIS routines and interacting with the code in the edit window it is different. The underlying routine is a form of database which is encrypted and what you see in the edit window is simply a wrapper - it is not plain text as many people assume. You can get some appreciation for this by switching between the various display options - summary mode, command mode & DMIS mode which are all just different ways of displaying the underlying routine. There are numerous ways of exporting / importing code for a routine or of interacting with the edit window via automation - which I think is what you are looking for. PC-DMIS provides a basic script editor which uses a very old version of cypress enable scripting (which is VB based) but you can actually use pretty much any object orientated programming language, so long as you are able to set it up to use the PC-DMIS automation objects (see the help: https://docs.hexagonmi.com/pcdmis/2020.2/en/helpcenter/mergedProjects/automationobjects/webframe.html) which is what Henniger123 is referring to.

    A little more information on exactly what it is you are trying to achieve would help us understand your needs and to maybe propose possible solutions.

  • Much appreciate to all of you for helping....Bottom line is we copy and paste a long line of jibberish that contains data we have to backspace and/or re-type in. Wears you out doing hundreds of these, and then increases errors.

    So thru a comment input I want to assign the operator's copied and pasted long azz part number, so after the copy and past pcdmis natively creates this in memory thru the ASSIGN(I can handle this):
    long_azz_num = "S-123456 (1234)-(3435)3{2}4"

    Then I want to run the below BASIC code to pull out the shortened data:
    Dim long_lot as String
    Dim short_lot as String
    Dim position as Integer
    Dim lot_num as String
    
    Dim long_azz_num as String                    ' This will eventually come from PCDMIS copied and pasted user entry
    long_azz_num = "S-123456 (1234)-(3435)3{2}4"  ' This will eventually come from PCDMIS copied and pasted user entry
    
    long_lot = long_azz_num
    
    short_lot = Left$(long_lot, 8)
    
    Print long_lot
    Print short_lot
    
    position = INSTR(1, long_lot, "{")
    If position < 1 Then
        lot_num = "1_1"
    ElseIf position >=1 Then
        lot_num = MID$(long_lot, position - 1, 1) + "_" + MID$(long_lot, position + 3, 1)
    Else
        lot_num = "0_0"
    EndIf
    
    Print lot_num
    


    The code works as seen here posted into the online compiler:


    My 2nd goal is to have an operator login for the day at 7AM and never have to type in their User ID again until they next person replaces them. Not certain how do this without pcdmis calling a serparate
    program that has this variable sitting in it to be retrieved....that's what I did in GOM's python interface.

    Thanks all.....
  • good day,
    to your first problem:

    1.)
    You must somehow give the user a way to type in a number. This is usually achieved with a pcDMIS input command.
       C1         =COMMENT/INPUT,NO,FULL SCREEN=NO,
       Number:
    


    2.)
    you must then tell pcDMIS to run a script
    CS1        =SCRIPT/FILENAME= C:\USERS\QS\DESKTOP\TEST.BAS
                FUNCTION/Main,SHOW=YES,,
                STARTSCRIPT/
    

    (you know that you can have different functions and subs in basic, the example script calls the sub Main() in the file "Test.bas")

    3.)
    the bas file must contain a basic code that is able to read out the data from the C1 pcDMIS command.
    only then can you use the code you posted.
    after that you need more basic code to write the data back into the input command

    ->
    * the disadvantage from all this is that you have to insert the said script call into every measurement routine.
    * on the other hand definitely makeable. As I have already mentioned, write an excel macro, easy to test and many examples online.
    * the online compiler will not be of much use to you because it cannot understand the communication between Basic and pcDMIS. In Excel you can enter the pcDMIS-Basic-DLL as a reference and then it works
    * please read the pcDMIS helpfile for this: https://docs.hexagonmi.com/pcdmis/20..._Script_1.html

    * All of this is of course just a script call from pcDMIS and everything is in Basic.
    This has nothing to do with C++ or Python. Of course, then it all has to look a bit different. (maybe you can then save the scripcall)

    ########################################

    The second problem has many possible solutions:
    For example, we have a server where you log in with a ship card. I can then import the user data into the pcDMIS report using a small basic script via a provided HTML page


  • Thanks for the writeup...I will have a look at the helpfile. This is more in depth than I thought and perhaps outside my comfort level at the moment. You said it best stating 'don't do this until you understand the script yourself'. I wholeheartedly agree with this statement.

    I'm going to table this for the time being. I have to get all our programs on GOM setup for new python scripts and then I will tackle this. GOM is nice in that I can simply import a script in one line and pretty much just call in that variable. I'm sure the framework of how to do this will make more sense once I read the helpfile and get a better understanding on what skills I need to learn.

    Thank you, and I'm sure we will be chatting again later on....


  • So, after months of python programming and becoming more comfortable scripting, myself and a co-worker knocked this out. My vb program above worked like a charm. The key was in your last post explaining that you must pass the arguments/variables to and from the script. This wasn't straightforward, but we found this link explaining two methods and we choose the 2nd method:

    https://docs.hexagonmi.com/pcdmis/2020.1/en/helpcenter/mergedProjects/core/27_external_topics/Passing_Variables_To_and_From_BASIC_Scripts.htm

    I did not know that you couldn't program VB inside of pcdmis. Basically, you are forced to run a script resting somewhere on your computer. This script should put an end to complaints about operator incorrect data entry. It will also speed us up a little bit. Scripting is fun when it works out well.

    PS...this F3 deal to get the /endscript in the program was a low-blow by the pcdmis programming team. It shouldn't be that hard.