Jump to content

dialog box that changes custom prop


dcokken

Recommended Posts

Hello,

 

I am having a problem/difficulty with the autolisp that I made for my dcl. I know very little about autolisp and I don’t know how the make what I want work through autolisp and could use serious help with the code.

 

The lisp-dcl needs to do the following:

1. When opening the dcl with lisp it needs to automatically import the values of the custom properties (see dwgprops custom tap in dwg, or pictures in dwg). At first values could be blank.

2. Fill or change values in dialog box.

3. By pressing OK update values in dwgprop

 

Any help what so ever is very welkom

As attachment: Project.dcl, Project.lsp and Pdata.dwg

 

Ps; I use fields so it might be import that de lisp does not delete and replace custom prop entirely

So not name, only (update) value. Or else it might be possible that fields change to ####

Pdata.dwg

Project.DCL

Project.lsp

Link to comment
Share on other sites

Saw those treads to. still dont understand how to make the lisp work with a dcl as user interface.

would be great is someone could alter the lisp code so that the values of the 2 custom props can be imported/exported to dcl.

(or an sample code that is somewhat more specific to this subject with dcl)

 

the actuall dcl is much bigger with way more editboxes, popup_lists ect. with the first two custom props working i'll probably manage with the rest.

 

in the meantime i'll still be trying to do it myself. if i succeed, i"ll post immediately.

Link to comment
Share on other sites

This is all you need to add a value by key:

 

(defun _add:custom:value (key val)
 ;; Tharwat 31.08.2015  ;;
 (vla-setcustombykey (vla-get-summaryinfo (vla-get-activedocument (vlax-get-acad-object))) key val)
 (princ)
)

 

Usage:

 

(_add:custom:value "Project" "1")

 

or this for multiple keys and values:

 

(mapcar '_add:custom:value '("Project" "Status") '("1" "2nd Draft"))

 

Be careful to write the key name correctly to avoid an error message by the function.

Link to comment
Share on other sites

@tharwat:

 

the value "1" or "2nd draft" are variables. Could as well by "233" and "3rd draft" or "8540" and "final". So with your code if previously in the dialog box "1" or "2nd draft" was filled in and i'll change it in the dialog box to "233" and "3rd draft" or whatever,it will automatically change the value in the dwgprops custom tab?

Edited by dcokken
Link to comment
Share on other sites

@tharwat:

 

the value "1" or "2nd draft" are variables. Could as well by "233" and "3rd draft" or "8540" and "final". So with your code if previously in the dialog box "1" or "2nd draft" was filled in and i'll change it in the dialog box to "233" and "3rd draft" or whatever,it will automatically change the value in the dwgprops custom tab?

 

If variables , it should be like the following and they should be strings:

 

(mapcar '_add:custom:value (list key1 key2) (list variable1 variable2))

Link to comment
Share on other sites

found this code by the way. Works but how do i add this in the lisp from fisrt post. code works as command line interface. i need it in the dcl interface. so if i call upon the dcl behind project in the textbox comes the value from the custom prop tab. just as it does in the command line

 

(defun C:Getprop ()
(setq  si (vla-Get-SummaryInfo (vla-Get-ActiveDocument (vlax-Get-Acad-Object))))
(vla-GetCustomByKey si  "Project" 'pval)
(princ pval)
)

 

and if in the dialog box i make a chance i need this?

(vla-SetCustomByKey  si "Project" "New Value") 

this way the new entry is exported back to as value in the customprops?

 

just dont know how to put it all together

Link to comment
Share on other sites

Try this quickie program.

 

(defun c:test (/ id status _add:custom:value v1 v2)
 ;; Tharwat 01.09.2015	;;
 (if (and (< 0 (setq id (load_dialog "Project.dcl")))
          (new_dialog "Project" id)
     )
   (progn
     (defun _add:custom:value (key val)
       (vla-setcustombykey
         (vla-get-summaryinfo
           (vla-get-activedocument (vlax-get-acad-object))
         )
         key
         val
       )
       (princ)
     )
     (setq
       Status (list "1st draft" "2nd draft" "3rd draft" "Final")
     )
     (start_list "Status")
     (mapcar 'add_list Status)
     (end_list)

     (action_tile
       "accept"
       "(if (/= (setq v1 (get_tile \"Project\")) \"\") (_add:custom:value \"Project\" v1))
                            (if (setq v2 (get_tile \"Status\")) (_add:custom:value \"Status\" (nth (atoi v2) Status)))
                            (done_dialog)"
     )
     (action_tile "cancel" "(done_dialog)")
     (start_dialog)
     (unload_dialog id)
   )
   (if (< 0 id)
     (unload_dialog id)
   )
 )
 (princ)
)(vl-load-com)

Link to comment
Share on other sites

@tharwat

 

now this is fine coding.....it totally works!!! thank you very much. could not have done it myself

 

just one question left:

 

The first time i open the dialog, it opens with default values (project=empty and status = 1st draft). If i now fill in different data it's transported to custom props. works perfect.

if i open the dialog for a second time its back to the default values. Can the code be altered so last entry is grabbed back from custom props?

Link to comment
Share on other sites

@tharwat

 

now this is fine coding.....it totally works!!! thank you very much. could not have done it myself

You are welcome :)

 

 

just one question left:

 

The first time i open the dialog, it opens with default values (project=empty and status = 1st draft). If i now fill in different data it's transported to custom props. works perfect.

if i open the dialog for a second time its back to the default values. Can the code be altered so last entry is grabbed back from custom props?

 

 

Try this:

(defun c:test (/ id status in l st v1 v2)
 ;; Tharwat 01.09.2015	;;
 (if (and (< 0 (setq id (load_dialog "Project.dcl")))
          (new_dialog "Project" id)
     )
   (progn
     (setq in     (vla-get-summaryinfo
                    (vla-get-activedocument (vlax-get-acad-object))
                  )
           Status (list "1st draft" "2nd draft" "3rd draft" "Final")
     )
     (mapcar '(lambda (k)
                (vla-getcustombykey in k 'st)
                (setq l (append l (list st)))
              )
             '("Project" "Status")
     )
     (start_list "Status")
     (mapcar 'add_list Status)
     (end_list)
     (set_tile "Project" (car l))
     (set_tile "Status"
               (if (member (cadr l) status)
                 (itoa (vl-position (cadr l) Status))
                 "0"
               )
     )
     (action_tile
       "accept"
       "(if (/= (setq v1 (get_tile \"Project\")) \"\") (vla-setcustombykey in \"Project\" v1))
        (if (setq v2 (get_tile \"Status\")) (vla-setcustombykey in \"Status\" (nth (atoi v2) Status)))
                            (done_dialog)"
     )
     (action_tile "cancel" "(done_dialog)")
     (start_dialog)
     (unload_dialog id)
   )
   (if (< 0 id)
     (unload_dialog id)
   )
 )
 (princ)
)(vl-load-com)

Link to comment
Share on other sites

Tha****,

 

works like a charme!!! thanx. could not have done it without you.

 

i am now starting to modify the code to the bigger dcl. i am adding a seconde list.

everything works fine but i cant get the lisp to remember last enty of the second list. (need to at a total of 4 list) can you take a look at the code and tell me what i did wrong?

 

(defun c:dprop (/ id STA PRO_DEL in l st v1 v2 v3)
 ;; Tharwat 01.09.2015	;;
 (if (and (< 0 (setq id (load_dialog "dprop2.dcl")))
          (new_dialog "dprop2" id)
     )
   (progn
     (setq in     (vla-get-summaryinfo
                    (vla-get-activedocument (vlax-get-acad-object))
                  )
           STA (list "" "Ontwerp" "Voorlopig" "Definitief" "Productie")
    PRO_DEL (list "" "Alleen leveren" "Montage Derden" "Montage Basis" "Montage Compleet")
     )
     (mapcar '(lambda (k)
                (vla-getcustombykey in k 'st)
                (setq l (append l (list st)))
              )
             '("PRO_NU" "STA" "PRO_DEL")
     )

     (start_list "STA")
     (mapcar 'add_list STA)
     (end_list)

     (start_list "PRO_DEL")
     (mapcar 'add_list PRO_DEL)
     (end_list)
     
     (set_tile "PRO_NU" (car l))
     (set_tile "STA"
               (if (member (cadr l) STA)
                 (itoa (vl-position (cadr l) STA))
                 "0"
               )
     )
           (set_tile "PRO_DEL"
               (if (member (cadr l) PRO_DEL)
                 (itoa (vl-position (cadr l) PRO_DEL))
                 "0"
               )
     )
     (action_tile
       "accept"
       "(if (/= (setq v1 (get_tile \"PRO_NU\")) \"\") (vla-setcustombykey in \"PRO_NU\" v1))
        (if (setq v2 (get_tile \"STA\")) (vla-setcustombykey in \"STA\" (nth (atoi v2) STA)))
        (if (setq v3 (get_tile \"PRO_DEL\")) (vla-setcustombykey in \"PRO_DEL\" (nth (atoi v3) PRO_DEL)))
                            (done_dialog)"
     )
     (action_tile "cancel" "(done_dialog)")
     (start_dialog)
     (unload_dialog id)
   )
   (if (< 0 id)
     (unload_dialog id)
   )
 )
 (princ)
)(vl-load-com)

Link to comment
Share on other sites

I have spent a quite sometime to write the two previous posted programs for you and you did not even bother yourself to spend less than a second to write my name correctly nor even completely ? :x

Link to comment
Share on other sites

I’ve been trying to modify the code thuesday evening but with very little success. Probably doing it completely wrong........Please help!

 

v1 2 3 4 5 6 7 and 24 (v7, v24=dcl popup_list) work great in setting them to custom props. But popup_list V27 does not. Somehow a value from popup_list v24 gets placed here as custom value. Value chosen in dcl for popup_list v29 is not set at all.

 

When opening the dialog for second time it needs to grab back (get) the previous entries. But only v1 is set back in dialog box, but is also set in v2 v3 v4 v5 v6.

v7 (“STA”) does nothing, same for v24 v27 and v29

 

I Still need to add to v43. These are all editboxes. Is there a simple way to make the code work (get and set values) for the v's above and easy to modify so I can add all the other values.

 

key=v

PRO_NU= v1, PAR_NU=v2, CLI=v3, CON =v4, PRO_MA =v5, DRA =v6, STA =v7, PRO_DEL =v24, FSC_T =v27 , CAL_CON =v29

 

 

if dcl and dwg (with keys entered in custom prop tab) are needed, please let me know.

 

 ;; ORGINAL BY Tharwat 01.09.2015;;
 ;; see below for variables/values that i still need to enter in code.
 ;; v8 v9 v10 v11 v12 v13 v14 v15 v16 v17 v18 v19 v20 v21 v22 v23
 ;; v25 v26 v28 v30 v31 v32 v33 v34 v35 v36 v37 v38 v39 v40 v41 v42 v43
 ;; these v's are all editboxes

(defun c:dprop (/ id STA PRO_DEL FSC_T CAL_CON in l st v1 v2 v3 v4 v5 v6 v7 v24 v27 v29 )

 (if (and (< 0 (setq id (load_dialog "dprop2.dcl")))
          (new_dialog "dprop2" id)
     )
   (progn
     (setq in     (vla-get-summaryinfo
                    (vla-get-activedocument (vlax-get-acad-object))
                  )
  	STA (list "A" "A1" "A2" "A3" "A4");;v7
  	PRO_DEL (list "B" "B1" "B2" "B3" "B4");;v24
FSC_T (list "C" "C1" "C2 C3" "C4");;v27
 	CAL_CON (list "D" "D1" "D2" "D3");;v29
     )
     (mapcar '(lambda (k)
                (vla-getcustombykey in k 'st)
                (setq l (append l (list st)))
              )
             '("PRO_NU" "PAR_NU" "CLI" "CON" "PRO_MA" "DRA" "STA" "PRO_DEL" "FSC_T" "CAL_CON")
     )
     (set_tile "PRO_NU" (car l))	;;v1
     (set_tile "PAR_NU" (car l))	;;v2
     (set_tile "CLI" (car l))		;;v3
     (set_tile "CON" (car l))		;;v4
     (set_tile "PRO_MA" (car l))	;;v5
     (set_tile "DRA" (car l))		;;v6
     
     (start_list "STA")		;;v7
     (mapcar 'add_list STA)
     (end_list)
     		(set_tile "STA"
               	(if (member (cadr l) STA)
                 		(itoa (vl-position (cadr l) STA))
                 			"0"))
     
     (start_list "PRO_DEL")		;;v24
     (mapcar 'add_list PRO_DEL)
     (end_list)
           	(set_tile "PRO_DEL"
               	(if (member (cadr l) PRO_DEL)
                 		(itoa (vl-position (cadr l) PRO_DEL))
                 			"0"))
     
     (start_list "FSC_T")		;;v27
     (mapcar 'add_list FSC_T)
     (end_list)
           	(set_tile "FSC_T"
               	(if (member (cadr l) FSC_T)
                 		(itoa (vl-position (cadr l) FSC_T))
                 			"0"))
     
     (start_list "CAL_CON")		;;v29
     (mapcar 'add_list CAL_CON)
     (end_list)
           	(set_tile "CAL_CON"
               	(if (member (cadr l) CAL_CON)
                 		(itoa (vl-position (cadr l) CAL_CON))
                 			"0"))
     (action_tile
       "accept"
       "(if (/= (setq v1 (get_tile \"PRO_NU\")) \"\") (vla-setcustombykey in \"PRO_NU\" v1))
        (if (/= (setq v2 (get_tile \"PAR_NU\")) \"\") (vla-setcustombykey in \"PAR_NU\" v2))
        (if (/= (setq v3 (get_tile \"CLI\")) \"\") (vla-setcustombykey in \"CLI\" v3))
        (if (/= (setq v4 (get_tile \"CON\")) \"\") (vla-setcustombykey in \"CON\" v4))
        (if (/= (setq v5 (get_tile \"PRO_MA\")) \"\") (vla-setcustombykey in \"PRO_MA\" v5))
        (if (/= (setq v6 (get_tile \"DRA\")) \"\") (vla-setcustombykey in \"DRA\" v6))
        (if (setq v7 (get_tile \"STA\")) (vla-setcustombykey in \"STA\" (nth (atoi v7) STA)))
        (if (setq v24 (get_tile \"PRO_DEL\")) (vla-setcustombykey in \"PRO_DEL\" (nth (atoi v24) PRO_DEL)))
        (if (setq v27 (get_tile \"FSC_T\")) (vla-setcustombykey in \"FSC_T\" (nth (atoi v27) PRO_DEL)))
        (if (setq v29 (get_tile \"CON_CAL\")) (vla-setcustombykey in \"CAL_CON\" (nth (atoi v29) CAL_CON)))
                            (done_dialog)"
     )
     (action_tile "cancel" "(done_dialog)")
     (start_dialog)
     (unload_dialog id)
   )
   (if (< 0 id)
     (unload_dialog id)
   )
 )
 (princ)
)(vl-load-com)

Edited by dcokken
Link to comment
Share on other sites

I am still making no headway with the code on my own.:cry:

see post above from 2nd Sep...anyone able to help? Tharwat?

 

 

UPDATE:

(few hours later)

 

think i figured it out......please hold

Edited by dcokken
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...