hexagon logo

Need help with my script

First i hope you will excuse my programming skills. Its been 17 years since i learned programming in Java, so this code i made here is parts from other people's programs i put togther for this.

Most of my program work, and do what is was intended for.

My current problem is that when i try to make a string "PRINT_PATH" with information where to save my report.
Then it does not get used in my Print command part. Seems that the PRINT_PATH only have a "0" and not the prober path i made in my script.

Hope this make any sence Slight smile


LØBENR2 =COMMENT/INPUT,NO,'Løbenr.'
ORDRENR2 =COMMENT/INPUT,NO,'Ordrenr.'
ASSIGN/LØBENR1=STR(LØBENR2.INPUT)
ASSIGN/ORDRE1=ORDRENR2.INPUT
ASSIGN/EMNE1="7427270"
ASSIGN/REVISION1="2"
Test_samle =SCRIPT/FILENAME= M:\SCRIPT\SAMLESCRIPT.BAS
FUNCTION/Main,SHOW=YES,ARG1=REVISION1,ARG2=LØBENR1,ARG3=EMNE1,ARG4=ORDRE1,,
STARTSCRIPT/
C1000 =COMMENT/INPUT,NO,'Initialer'
ASSIGN/INI=C1000.INPUT
ASSIGN/PRINT_PATH="O:\QA\TEST\PRL05555\7427270_2_MP_5555-.PDF"
ENDSCRIPT/
$$ NO,***************************** Statestik *************************************************
STATS/OFF
TRACEFIELD/NO_DISPLAY,LIMIT=15 ; : EMNE1.INPUT
TRACEFIELD/NO_DISPLAY,LIMIT=15 ; : REVISION1.INPUT
TRACEFIELD/NO_DISPLAY,LIMIT=15 ; : STR(LØBENR1.INPUT)
TRACEFIELD/NO_DISPLAY,LIMIT=25 ; Ordre : ORDRENR2.INPUT
TRACEFIELD/NO_DISPLAY,LIMIT=15 ; PROCESS : CTP
TRACEFIELD/NO_DISPLAY,LIMIT=15 ; Initialer : STR(INI)
$$ NO,********************************** Sættes ind i ende af program ******************
PRINT/REPORT,EXEC MODE=END,$
TO_FILE=ON,AUTO=PRINT_PATH,$
TO_PRINTER=OFF,$
TO_DMIS_REPORT=OFF,FILE_OPTION=OVERWRITE,FILENAME=,$
REPORT_THEORETICALS=ALL,REPORT_FEATURE_WITH_DIMENSIONS=YES,$
PREVIOUS_RUNS=DELETE_INSTANCES

Sub main(REVISION1 As String, LØBENR1 As String, EMNE1 As String, ORDRE1 As String) 'bring newpn In As ARG1 from PCDMIS
Dim DmisApp As Object
Dim DmisPart As Object
Dim DmisCommands As Object
Dim DmisCommand As Object


Set DmisApp = CreateObject("PCDLRN.Application")
Set DmisPart = DmisApp.ActivePartProgram
Set DmisCommands = DmisPart.Commands
CommandCount = DmisCommands.Count
Set DmisCommand = DmisCommands.Item(CommandCount)
DmisCommands.InsertionPointAfter DmisCommand

Dim C1000
' Set C1000 = "" A Null String
C1000 = ""

Set DmisCommand = DmisCommands.Add(SET_COMMENT, True)
DmisCommand.Marked = True

retval = DmisCommand.PutText ("C1000", ID, 0)
retval = DmisCommand.SetToggleString (3, COMMENT_TYPE, 0)
retval = DmisCommand.PutText ("Initialer", COMMENT_FIELD, 1)
retval = DmisCommand.SetToggleString (1, OUTPUT_TYPE, 0)

Set DmisCommand = DmisCommands.Add(ASSIGNMENT, True)
DmisCommand.Marked = True
retval = DmisCommand.PutText ("INI", DEST_EXPR, 0)
retval = DmisCommand.PutText ("C1000.INPUT", SRC_EXPR, 0)

Dim PARTNAME2 As String
PARTNAME2 = EMNE1 + "_" + REVISION1 + "_MP_" + LØBENR1

Dim JOB_PATH As String
JOB_PATH = "O:\QA\TEST"
Dim REPORT_PATH1 As String
REPORT_PATH1 = JOB_PATH + "" + ORDRE1
Dim REPORT_PATH2 As String
REPORT_PATH2 = REPORT_PATH1 + ""
Dim REPORT_NAME As String
REPORT_NAME = PARTNAME2 + "-"
Dim PRINT_PATH1
PRINT_PATH1 = """" + REPORT_PATH2 + REPORT_NAME + ".PDF" + """"

Set DmisCommand = DmisCommands.Add(ASSIGNMENT, True)
DmisCommand.Marked = True

retval = DmisCommand.PutText ("PRINT_PATH", DEST_EXPR, 0)
retval = DmisCommand.PutText (PRINT_PATH1, SRC_EXPR, 0)

DmisPart.PARTNAME=PARTNAME2 'make the new control number, the part number
DmisPart.SERIALNUMBER=LØBENR1
DmisPart.REVISIONNUMBER=REVISION1
DmisPart.statscount=PROCESS1
DmisPart.refreshpart
DmisPart.save ' save the part program so it has the latest part number
Dim repwin As Object
Set repwin = DmisPart.reportwindow
repwin.refreshreport 'refresh report; now the report shows the latest part number.

On Error Resume Next
MkDir REPORT_PATH1

End Sub
  • For debugging purposes, display an operator comment with the PRINT_PATH string to "see" if it really contains what it should contain.
  • I did use comment/oper and it looks lile it contains what it should.

    PRINT_PATH contains the full directory path.

    But somehow in the print report command it does not get updated with the prober string. When i open the print command it only contains a "0".

    Do i miss some kind of a refresh/update when i return from my script to pc dmis?
  • Your script is adding commands to your PC-DMIS program (they show up between STARTSCRIPT and ENDSCRIPT), but are you sure those lines are executed? I don't know, and I can't find any solid information in the Help about this (I'm probably searching with the wrong keywords).

    I would suggest using a PC-DMIS variable in a PRINT command that already exists in the program, and setting this variable with the script, instead of generating PC-DMIS commands (see "Passing Variables To and From BASIC Scripts", the section about "SetVariableValue").
  • It's called poor mans debugger. I use all the time.
  • I would suggest using a PC-DMIS variable in a PRINT command that already exists in the program, and setting this variable with the script, instead of generating PC-DMIS commands (see "Passing Variables To and From BASIC Scripts", the section about "SetVariableValue").


    I agree with . Never seen this example before, all other examples I've came across handles it with what was suggested, its the method I use. Good luck!
  • Try using double backslashes in your variable name assignment, i.e. ASSIGN/PRINT_PATH="O:\QA\TEST\PRL05555\7427270_2_MP_5555-.PDF" should be ASSIGN/PRINT_PATH="O:\\QA\\TEST\\PRL05555\\7427270_2_MP_5555-.PDF"

    I have no idea why, but when I try to automate the output of pointcloud files I have to do this, but not in a direct PRINT statement
  • Try using double backslashes in your variable name assignment, i.e. ASSIGN/PRINT_PATH="O:\QA\TEST\PRL05555\7427270_2_MP_5555-.PDF" should be ASSIGN/PRINT_PATH="O:\\QA\\TEST\\PRL05555\\7427270_2_MP_5 555-.PDF"

    I have no idea why, but when I try to automate the output of pointcloud files I have to do this, but not in a direct PRINT statement


    I only use those when breaking string directory paths i.e. "C:\Users\Public\Documents\WAI\PC-DMIS\2015.1" + Variable + "\\FolderName". Never had to use double \\ in between everything...strange.
  • I could very well be mistaken, thought it may have been with a shot.


  • I only use those when breaking string directory paths i.e. "C:\Users\Public\Documents\WAI\PC-DMIS\2015.1" + Variable + "\\FolderName". Never had to use double \\ in between everything...strange.


    Double \\ is only needed in front of some special characters, as the combination of a single backslash and the special character means PC-DMIS should do something else.

    Specifically, if you end a string with a backslash, like "C:\Programs\" PC-DMIS will read the combination \" to mean "add a quotation mark to the string", and signal the line as an error because there is no end quote. Here you must write "C:\Programs\\" to get the backslash into the string, and the end quote interpreted in the normal way.

    There were some other characters that also got special treatment, but I don't remember right now which they were.

    Edit1: OK, this forum is doing the same thing - it seems I need to double the double backslashes to see them...
    Edit2: Aaaargh! This forum drives me crazy sometimes!
  • The only *sane* way to implement such a thing is to *always* replace <backslash><any char> with something else, and *always* convert <backslash><backslash> to a single <backslash>. Not doing different things depending on where in the text/string it occurs!

    (Now, don't tell me this forum is eating angular brackets too!)