PDA

View Full Version : Help with DCL lisp



mhy3sx.
2024-03-13, 11:40 PM
Hi I use this code to insert points in the drawing. I want to replace the (textpage) menu with a dcl menu. I am new in DCL so I need help.

dcl



pointsin : dialog {
label = "Structural Holes" ;

: row {

:boxed_radio_column {
label = "Type" ;

: radio_button {
key = "1" ;
label = "1. PNEZD (comma delimited)" ;
}

: radio_button {
key = "2"
label = "2. PNEZD (tab delimited)"
}

: radio_button {
key = "3" ;
label = "3. PNEZD (white-space delimited)" ;
}
: radio_button {
key = "4" ;
label = "4. PENZD (comma delimited)" ;
value = "1" ;
}
: radio_button {
key = "5" ;
label = "5. PENZD (tab delimited)" ;
}

: radio_button {
key = "6" ;
label = "6. PENZD (white-space delimited)" ;
}

: row {

: button {label = "OK"; key = "accept"; alignment = centered; width = 12; is_default = true;}
: button {label = "Cancel"; key = "cancel"; alignment = centered; width = 12;}

}
}
}
}




I attach the lisp code because is big

mhy3sx.
2024-03-14, 03:36 PM
I try this change, but I need help. Can anyone help me?

peter
2024-03-14, 04:09 PM
Just the dialog part with radio buttons.

Easy to modify.

P=

PointsIn.lsp



;___________________________________________________________________________________________________________|
;
; Written By: Peter Jamtgaard copyright 2024 All Rights Reserved
;___________________________________________________________________________________________________________|
;
; Command Line Function Header List
;___________________________________________________________________________________________________________|

;* C:PIN
;* Command Line Function to show points in dialog box

;* C:PointsIn
;* Command Line Function to show points in dialog box

;___________________________________________________________________________________________________________|
;
; General Function Header List
;___________________________________________________________________________________________________________|

;___________________________________________________________________________________________________________|
;
; Command Line Function to show points in dialog box
;___________________________________________________________________________________________________________|

(defun C:PIN ()(DialogPointsIn))

(defun C:PointsIn ()
(DialogPointsIn)
)

;___________________________________________________________________________________________________________|
;
; Function to show points in dialog box
;___________________________________________________________________________________________________________|

(defun DialogPointsIn (
/
id
sngReturn
)
(findfile "PointsIn.dcl")
(setq id (load_dialog "PointsIn.dcl"));<---
(new_dialog "pointsin" id)
(setq sngReturn 1)
(set_tile "radio_button01" "1")
(action_tile "radio_button01" "(setq sngReturn 1)")
(action_tile "radio_button02" "(setq sngReturn 2)")
(action_tile "radio_button03" "(setq sngReturn 3)")
(if (= (setq start (start_dialog)) 1)
sngReturn
)
)

(princ "!")
(vl-load-com)


PointsIn.dcl


//////////////////////////////////// Header ////////////////////////////////////
// Developer = "Peter"
// Copyright = "2024"
// DCLFileName = "PointsIn.dcl"
// DateCreated = "2024/03/14 08:19:34"
// DateModified = "2024/03/14 08:19:34"
// Revision = "1.0.0.1"
////////////////////////////////////////////////////////////////////////////////

pointsin : dialog {
label = " Structural Holes";
: boxed_column {
height = 1.0;
width = 20.0;
key = "boxed_column01";
: radio_column {
height = 1.0;
label = "PENZD Format";
width = 20.0;
key = "radio_column01";
: radio_button {
height = 1.0;
is_tab_stop = true;
key = "radio_button01";
label = "1. Comma Delimited";
width = 20.0;
}
: radio_button {
height = 1.0;
is_tab_stop = true;
key = "radio_button02";
label = "2. Tab Delimited";
width = 20.0;
}
: radio_button {
height = 1.0;
is_tab_stop = true;
key = "radio_button03";
label = "3. White-Space Delimited";
width = 20.0;
}
}
: spacer {
height = 1.0;
key = "spacer01";
width = 20.0;
}
}
ok_cancel;
}

mhy3sx.
2024-03-14, 09:02 PM
Hi peter. Thanks for reply. Is it possible to put all together. I try but I can't fix the code !!!

Thanks

mhy3sx.
2024-03-16, 08:41 AM
I try to update the code, but I need help. Any ideas?

BIG-AL
2024-03-18, 01:10 AM
Have you looked at Lee-mac Import points Manager ? May do what you want.

mhy3sx.
2024-03-18, 07:45 AM
Hi Bigal. Yes I know Lee-mac Import points Manager, but is not working for me. Lee-mac Import points with x,y,z with no point number or description in the coordinate files. Pointsin is a good code (little slow if I have 100 points to insert), but support many types of files.

peter
2024-03-19, 10:15 PM
Hi peter. Thanks for reply. Is it possible to put all together. I try but I can't fix the code !!!

Thanks


Tell me what you are trying to do?

What I can see...

Specify data file format (in dialog), read a data file, and insert points into drawing.

Can you be specific?

P=

If this is what you are doing than it is relatively easy to do this.

peter
2024-03-19, 10:18 PM
can you provide some example data files?

P=

mhy3sx.
2024-03-19, 10:33 PM
I update the code. The DCL menu load but not insert the points. I attach a point file (I use option 4)

I use this code by default for all my lisp codes (please don't change)



( DEFUN C:SETSC ()
(setvar "OSMODE" 13)
(setq cursc (getvar "useri1" ))
(princ "\nSet scale 1:")(princ cursc)
(setq newsc (getint "\nThe new scale is1:"))
(setvar "useri1" newsc)
(princ "\n The scale set 1:")(princ newsc)(princ)
)


I update [code] (DEFUN
PI:GETFILEFORMAT (/ )
[code]

Thanks

mhy3sx.
2024-03-19, 10:44 PM
I update to this but give me this error



Error: An error has occurred inside the *error* function too many arguments




(DEFUN
PI:GETFILEFORMAT (/ )

(defun *error* ( / *error* dch dcl des)
(if (and (= 'int (type dch)) (< 0 dch))
(unload_dialog dch)
)
(if (= 'file (type des))
(close des)
)
(if (and (= 'str (type dcl)) (findfile dcl))
(vl-file-delete dcl)
)

(princ)
) ; end defun

(cond
( (not
(setq dcl (vl-filename-mktemp nil nil ".dcl")
des (open dcl "w")
) ; end setq
) ; end not
(princ "\nUnable to open DCL for writing.")
)
( (progn
(foreach str '(
"ed : edit_box { alignment = left; width = 20; edit_width = 10; fixed_width = true;}"
""
"pointsin : dialog { spacer; key = \"dcl\";"
" : boxed_column { label = \"Text Style\"; height = 1.0;}"
" : radio_button { height = 1.0; width = 20; is_tab_stop = true;"
" key = \"radio_button01\"; label = \"1. PNEZD (comma delimited)\";"
" }" ; radio_button
" : radio_button { height = 1.0; width = 20; is_tab_stop = true;"
" key = \"radio_button02\"; label = \"2. PNEZD (tab delimited)\";"
" }" ; radio_button
" : radio_button { height = 1.0; width = 20; is_tab_stop = true;"
" key = \"radio_button03\"; label = \"3.PNEZD (white-space delimited)\";"
" }" ; radio_button
" : radio_button { height = 1.0; width = 20; is_tab_stop = true;"
" key = \"radio_button04\"; label = \"4. PENZD (comma delimited)\";"
" }" ; radio_button
" : radio_button { height = 1.0; width = 20; is_tab_stop = true;"
" key = \"radio_button05\"; label = \"5. PENZD (tab delimited)\";"
" }" ; radio_button
" : radio_button { height = 1.0; width = 20; is_tab_stop = true;"
" key = \"radio_button06\"; label = \"6. PENZD (white-space delimited)\";"
" }" ; radio_button
" : row { width = 20;"
" : button { key = \"OK\"; label = \"OK\"; is_default = true;"
" is_cancel = true; fixed_width = true; width = 10; }"
" }" ; end row
" }" ; end dialog
) ;end list
(write-line str des)
) ; end foreach
(setq des (close des)
dch (load_dialog dcl)
) ; end setq
(<= dch 0)
)
(princ "\nUnable to load DCL file.")
)
( (not (new_dialog "pointsin" dch))
(princ "\nUnable to display 'pointsin' dialog.")
)
( t
(set_tile "dcl" "Select file")
(setq sngReturn 1)
(action_tile "radio_button01" "(setq sngReturn 1))")
(action_tile "radio_button02" "(setq sngReturn 2))")
(action_tile "radio_button03" "(setq sngReturn 3))")
(action_tile "radio_button04" "(setq sngReturn 4))")
(action_tile "radio_button05" "(setq sngReturn 5))")
(action_tile "radio_button06" "(setq sngReturn 6))")
(action_tile "OK" "(progn (done_dialog 1) sngReturn)")
(start_dialog)
)
) ; end cond
(*error* nil)
(princ)
) ;_ end defun


Thanks

mhy3sx.
2024-03-23, 12:37 PM
Can anyone fix the code?

Thanks

mhy3sx.
2024-03-23, 07:05 PM
I update the code . The DCL load , gives me the option to select the coordination file and the gives me this error



Esc or Error Pressed...



Can any one help?

Thanks

mhy3sx.
2024-03-27, 09:19 PM
Any ideas?

Thanks

peter
2024-03-29, 04:10 PM
I would not try to fix someone else's code.

I write everything from scratch using structured programming techniques with good notes.

I try to write code that others can easily read.

The code I presented is to teach you to create a dialog box with radio buttons.

I would have you write a functional specification (write out what you need the code to do in steps)

1. Select data file
2. Present Dialog to select data format (with radio buttons).
3. Insert point block at specified location (from data) into the drawing.
4. Add data to attributes of each point block.

If this is what you want...

Can you select a data file using the 'getfiled' expression?

Can you insert a block with attributes using LISP?

Can you programmatically change the attributes of each block?

P=


This is really not a difficult program to write.

BIG-AL
2024-04-04, 11:59 PM
My $0.05 try this make sure Multi radio buttons is saved in a support path so auto loads.



(if (not AH:Butts)(load "Multi Radio buttons.lsp"))

(setq ans (atoi(ah:butts 1 "V" '("Structural Holes" "PNEZD (comma delimited)" "PNEZD (tab delimited)" "PNEZD (white-space delimited)" )))) ; ans holds the button picked as an integer value


109904

A little hint is look at variable BUT it is button chosen eg 1 2 3

mhy3sx.
2024-04-07, 07:48 PM
Hi BIG-AL the radio buttons load correct in the code, the problem is after choose the coordinate file the code stop. CAn you help me to fix the code ?

Thanks

BIG-AL
2024-04-12, 04:10 AM
Forgot to post this can do the dcl for you look at examples in code.

mhy3sx.
2024-04-18, 08:22 PM
The radio buttons in the code I post work fine , the DCL file open , I select the coordinate file type and the coordinate file but not insert the points. Perhaps something in the code is not corrrect. Can any one help?
Thanks

BIG-AL
2024-04-22, 04:32 AM
Are you talking about my Radio buttons code or yours, in mine the code returns 2 answers a hidden Value of BUT which is the radio button selected and ans which is the radio button string. So do a cond and import points.

Have you checked that part of your code seperately, I dummy up values like "PENZD" and test bits of code. So after running dcl is it returning a known variable answer ?

For me with my experience never write lots of code but test portions as I go so make sure they are working, looking at DCL checking I write the dcl to a file but do not load rather open in Notepad++ and look at all the bracket pairings to make sure I did not have something missing or out of sequence. Checking stuff like labels and keys have double quotes.

mhy3sx.
2024-04-22, 05:04 AM
Hi BIG_AL. I check in notepad ++ all the bracket and is correct. I can not find the problem in this code !!!:(

This code open dcl , select the coordinate file , but when I press OK I have this error


Error: invalid argument type: listp:



(defun PI:GETFILEFORMAT (/ )

(defun *error* ( / *error* dch dcl des)
(if (and (= 'int (type dch)) (< 0 dch))
(unload_dialog dch)
)
(if (= 'file (type des))
(close des)
)
(if (and (= 'str (type dcl)) (findfile dcl))
(vl-file-delete dcl)
)

(princ)
) ; end defun

(cond
( (not
(setq dcl (vl-filename-mktemp nil nil ".dcl")
des (open dcl "w")
) ; end setq
) ; end not
(princ "\nUnable to open DCL for writing.")
)
( (progn
(foreach str '(
"ed : edit_box { alignment = left; width = 20; edit_width = 10; fixed_width = true;}"
""
"pointsin : dialog { spacer; key = \"dcl\";"
" : boxed_column { label = \"Text Style\"; height = 1.0;}"
" : radio_button { height = 1.0; width = 20; is_tab_stop = true;"
" key = \"radio_button01\"; label = \"1. PNEZD (comma delimited)\";"
" }" ; radio_button
" : radio_button { height = 1.0; width = 20; is_tab_stop = true;"
" key = \"radio_button02\"; label = \"2. PNEZD (tab delimited)\";"
" }" ; radio_button
" : radio_button { height = 1.0; width = 20; is_tab_stop = true;"
" key = \"radio_button03\"; label = \"3.PNEZD (white-space delimited)\";"
" }" ; radio_button
" : radio_button { height = 1.0; width = 20; is_tab_stop = true;"
" key = \"radio_button04\"; label = \"4. PENZD (comma delimited)\";"
" }" ; radio_button
" : radio_button { height = 1.0; width = 20; is_tab_stop = true;"
" key = \"radio_button05\"; label = \"5. PENZD (tab delimited)\";"
" }" ; radio_button
" : radio_button { height = 1.0; width = 20; is_tab_stop = true;"
" key = \"radio_button06\"; label = \"6. PENZD (white-space delimited)\";"
" }" ; radio_button
" : row { width = 20;"
" : button { key = \"OK\"; label = \"OK\"; is_default = true;"
" is_cancel = true; fixed_width = true; width = 10; }"
" }" ; end row
" }" ; end dialog
) ;end list
(write-line str des)
) ; end foreach
(setq des (close des)
dch (load_dialog dcl)
) ; end setq
(<= dch 0)
)
(princ "\nUnable to load DCL file.")
)
( (not (new_dialog "pointsin" dch))
(princ "\nUnable to display 'pointsin' dialog.")
)
( t
(set_tile "dcl" "Select file")
(setq FILEFORMAT1)
(action_tile "radio_button01" "(setq FILEFORMAT 1))")
(action_tile "radio_button02" "(setq FILEFORMAT 2))")
(action_tile "radio_button03" "(setq FILEFORMAT 3))")
(action_tile "radio_button04" "(setq FILEFORMAT 4))")
(action_tile "radio_button05" "(setq FILEFORMAT 5))")
(action_tile "radio_button06" "(setq FILEFORMAT 6))")
(action_tile "OK" "(progn (done_dialog 1) FILEFORMAT)")
(start_dialog)
)
) ; end cond
(*error* nil)
(princ)
) ;_ end defun


Thanks

Opie
2024-04-22, 12:47 PM
Your *error* subroutine is being called with a parameter, yet the definition you have created does not include a parameter value. You have also localized variables inside of the *error* subroutine that were set outside of the subroutine. The localized variables will not contain the values you have set outside of the subroutine. I am not saying the changes to this subroutine will fix your overall routine, but those changes will need to be made in the long run.

You appear to have an error on line 69 which is right after the set_tile line. Were you intending to assign a value to the FILEFORMAT variable or the FILEFORMAT1 variable?

garcigj
2024-04-24, 11:41 AM
You can try this:
usage:

(setq OPTION (delimitedDLG))



(defun delimitedDLG ( / FichDlg idxDlg acc delim WriteDlg)

;;___________________________________________________
(defun WriteDlg ( / dir FileDlg openFile)
(setq dir (getvar "TEMPPREFIX"))
(setq FileDlg (strcat dir "$Delimited$.dcl"))
(cond
;;(T ;;Forzar reescribir el cuadro: dejar así en este caso porque tiene argumentos y se tiene que reescribir
((not (findfile FileDlg))
(setq openFile (open FileDlg "w"))
(write-line "//-----------------------------------------//" openFile)
(write-line "// delimiter dialog box //" openFile)
(write-line "//-----------------------------------------//" openFile)
(write-line "delimiter : dialog {" openFile)
(write-line " label = \"Select a file format\";" openFile)
(write-line " : boxed_radio_column {" openFile)
(write-line " key = \"delim\";" openFile)
(write-line " label = \"&Delimiter PNEZD: \";" openFile)
(write-line " : radio_button {vertical_margin = none; label = \"&1. PNEZD (comma delimited)\"; key = \"1\";}" openFile)
(write-line " : radio_button {vertical_margin = none; label = \"&2. PNEZD (tab delimited)\"; key = \"2\";}" openFile)
(write-line " : radio_button {vertical_margin = none; label = \"&3. PNEZD (white-space delimited)\"; key = \"3\";}" openFile)
(write-line " : radio_button {vertical_margin = none; label = \"&4. PENZD (comma delimited)\"; key = \"4\";}" openFile)
(write-line " : radio_button {vertical_margin = none; label = \"&5. PENZD (tab delimited)\"; key = \"5\";}" openFile)
(write-line " : radio_button {vertical_margin = none; label = \"&6. PENZD (white-space delimited)\"; key = \"6\";}" openFile)
(write-line " : spacer { width = 1; }" openFile)
(write-line " } " openFile)
(write-line " : spacer { width = 1; }" openFile)
(write-line " ok_cancel_err;" openFile)
(write-line "}" openFile)
(close openFile)
)
);c.cond
FileDlg
)

;;-------------------------------- MAIN ------------------------------------------
;;default value
(or *delimiterPNEZD* (setq *delimiterPNEZD* "1"))
(setq delim *delimiterPNEZD*)
;;Load the dialog file
(if (null Pos-Dlg) (setq Pos-Dlg '(-1 -1)))
(setq FichDlg (WriteDlg))
(setq idxDlg (load_dialog FichDlg))

;;______________________________________________________________________
;;Abre el cuadro de dialogo
(if (not (new_dialog "delimiter" idxDlg "" Pos-Dlg)) (exit))
;;__________________________________
(set_tile "delim" delim)
;;__________________________________
(action_tile "delim" "(setq delim $value))")
(action_tile "accept" "(setq Pos-Dlg (done_dialog 1))")
(action_tile "cancel" "(setq Pos-Dlg (done_dialog 0))")
(setq acc (start_dialog))
(cond
((= acc 0)
(unload_dialog idxDlg)
nil
)
((= acc 1)
(unload_dialog idxDlg)
(setq *delimiterPNEZD* delim)
;;delim
)
)
)

mhy3sx.
2024-04-24, 03:14 PM
Hi garcigj ,I did this change but gives me this error


trapped error: invalid argument type: listp: "4"