Jump to content

Recommended Posts

Posted

Hello,

 

I have some title blocks and PO sheets that contain company information like address, phone, etc. However, in my company the CAD for all branches is done in one location, so this information will need to change depending on which branch the project is for.

 

Right now we use DWGPROPS to fill out job specific information such as JobName, Client, SiteAddress, etc. I would like to include the "Branch Name" in here as well (ie. Vancouver, Calgary, etc), with other fields referencing this entry to fill out the office phone, address, fax, etc, so that we don't need to fill in all of that info manually for every new project.

 

However, I can't find any way to use a custom property in a conditional, ie, something like:

    if CustomDP.Branch=="CALGARY" then [Phone number]="XXX-XXX-XXXX",
elseif CustomDP.Branch=="VANCOUVER" then [Phone number]="YYY-YYY-YYYY"

 

It seems that a "formula" field is able to include nested fields, but is unable to handle conditional statements or branching paths.

 

A DIESEL expression may work, but seems to be completely unable to reference custom DWGPROPS.

DIESEL seems unable to reference object properties either, so I also can't do an intermediate attribute that is then referenced by a DIESEL expression.

 

Is there any way to get this functionality? If possible I would really prefer to do it with fields or with some other method that stays self-contained within the template drawing, rather than requiring me to run VB code on every CAD machine in the office. Right now my workaround is is to rename the user profile with the branch name, as that is an easily editable acad variable that is accessible by DIESEL. It kind of works but the issue is that the profile name is global, not saved per project, so I often see POs going out with the wrong "Ship To" address when guys forget to change their profile between projects.

 

Thanks,

Posted (edited)

If you save in dwgprops custom details these are exposed and can be used as a field. The same can be done that when you start a new project you fill in the details so would ask for details, if Calgary is chosen then all details are known and filled in. You could set up this multi radio buttons.lsp to select a town and use a cond to set all the variables, then fill in the custom details.

image.png.dff4dbe23981e13e1a8f41b2dfbddf1c.png

(if (not AH:Butts)(load "Multi radio buttons.lsp")) 			; loads the program if not loaded already
(setq ans (ah:butts 1 "V"   '("Choose " "Calgary" "Vancouver" "Sydney" "Melbourne" ))) 	; ans holds the button picked value as a string

(cond
((= "Calgary" ans)(setq address "1 Fred st" pcode "4321" ph "123-456-789"))
((= "Vancouver" ans)(setq address "12 Barney st" pcode "1234" ph "987-654-321"))
((= "Sydney" ans)(setq address "3 Bond st" pcode "2000" ph "789"))
((= "Melbourne" ans)(setq address "1 James st" pcode "3000" ph "456789"))
)
; update or create custom info.

Do you have a add custom info to DWGprops lisp ?

Multi radio buttons.lsp

Edited by BIGAL
Posted

Thanks for the reply.

 

This is a good idea.

I do not have a lisp to fill out DWGPROPS custom info, we have been manually entering directly into the DWGPROPS window.

 

A lisp to fill out that information, incorporating your radio buttons would be perfect for this. I have written some lisp commands in the past, but I am entirely unfamiliar with how to use it to create dialog boxes. Do you know any good reference materials that I could use?

Posted (edited)

Ok 2 questions so 2 answers.

 

This is code for add custom values to the Dwgprops.

 

; by CodeDing

;key - string, representing key value of custom dwgprop to create
  ;val - string, representing custom value to be used for the "key" custom dwgprop
(defun CDP-Create (key val / docProps return num keyVal propVal)
  (if (and (eq 'STR (type key)) (eq 'STR (type val)))
    (progn
      (setq docProps (vla-get-SummaryInfo (vla-get-ActiveDocument (vlax-get-acad-object))))
      (vla-AddCustomInfo docProps key val)
    )
  )
  (princ)
)

Ok now need a front end as already suggested pick office and get some of the custom values required. Then run another dcl and can add the Key and Val. For me I would use my Multi getvals as it gives you a nice dcl to fill in.

(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter new value  " "Key " 12 11 "Key" "Val" 12 11 "Val")))
(setq key (car ans) val (cadr ans))

image.png.bec6578ad8cf5b96f66eed012e06e041.png

Press cancel to exit

 

Ok now part 2 how do we put it all together. That needs a lisp and a dcl. The multi lisps are not for someone learning rather use them. Leaning dcl can be a bit long winded but once you understand it can be fairly simple to create custom dcl's. The multi lisps are based on what a dcl should look like but take advantage of loops to make the buttons etc and return answers. If you edit the output file line to a directory and file name you will see the DCL code, the vl-filename-mktemp makes a temporary file and erases it when finished with it.

 

Re learning DCL there is help just google, I have an old Autocad Customization Manual yeah paper copy with dcl examples. Need to Google my self to find.

 

Ok now for your task need to know for each office what is required, dont need real address or phone numbers, just need order of items,

name address phno whatever1 whatever2 andso on

 

 Only need say 3 then can make the office choice DCL choose then the add key's and values DCL will appear choose cancel to stop entering.

 

Multi GETVALS.lsp

Edited by BIGAL
  • 1 month later...
Posted

Thank you for the response, sorry for late reply. Work got too busy and I had no time to devote to this.

 

I will look in to creating a DCL and see if I can figure it out.

 

We use dwg props for a number of items, as in my attached image. These would all be filled manually on a per job basis with the exception of "Template version" which is for reference only. Also to be included and filled automatically by the lisp routine would be "Branch address, Branch post code, Branch phone, Branch fax" as selected by radio button.

 

297050101_dwgprops.png.fca32911410f74eed7a0e14b9b1d0226.png

 

I will play around with the example program you provided and see what I can do when I have some free time. Thanks,

Posted (edited)

Ok my multi getvals will do about 20 lines, you have way more than that, so I would suggest multi getvals 2col.lsp. I have to finish it but will try to do it in next few days. The default stuff will use the multi radio buttons.lsp as choose office. I did start on it but did not finish.

 

 

image.thumb.png.2c8dc7802efff3737f1271654ef83f07.png

 

 

Thinking more it is feasible to have child dcl's so when you click on a item you get choices to select from this would mean no incorrect sizes. eg Glass thickness.

 

For moment just a double enter values, the dcl will have default values that you can set.

 

 

 

 

Edited by BIGAL
Posted (edited)

Our custom Properties panel has several macros for adding or modifying custom properties.

You could modify this lisp & dcl file that allows us to pick the "Engineer" to put their name and PE number in the signature box to select the "Branch Name".

SignedBy.dcl SignedBy.lsp

Edited by tombu
Posted

This is all your values displayed on a screen for input, the next step is to just do the add to Custom properties fairly straight forward. 

image.thumb.png.0cbf2c4fcdfd8fb61a3ff71f19400803.png

 

A better way to go though is to change some of the input to a "Button"  so when you press a child dcl will pop up and it has default values to choose from.

 

image.thumb.png.627f6d88394a8ac301b0c4a3478985dd.png

 

Here is code for the simple version.

; https://www.cadtutor.net/forum/topic/76318-update-field-with-conditional-statement-referencing-dwgprops/#comment-606324

; Getvals multi allows multiple line inputs
; By Alan H Feb 2019 info@alanh.com.au
; 
; code examples
; the input box size can be bigger just change the two values tetsed with 145 145 and worked ok.


(defun AH:getvalsm2col (heading dcllst1 dcllst2 / x y num fo fname keynum key_lst v_lst)

(setq x 0)
(setq y 0)
(setq fo (open (setq fname "D:\\acadtemp\\get2col.dcl") "w"))
(write-line "ddgetvalAH2col : dialog {" fo)
(write-line (strcat "	label =" (chr 34) heading (chr 34) " ;") fo)
(write-line "	: row	{" fo)
(write-line " : boxed_column {" fo)
(write-line " width = 35;" fo)
(repeat (/ (- (length dcllst1) 1) 4)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(setq keynum (strcat "key" (rtos (setq y (+ Y 1)) 2 0)))
(write-line (strcat "    key = " (chr 34) keynum (chr 34) ";") fo)
(write-line (strcat " label = " (chr 34) (nth (+ x 1) dcllst1) (chr 34) ";") fo)
(write-line (strcat "     edit_width = " (rtos (nth (+ x 2) dcllst1) 2 0) ";") fo)
(write-line (strcat "     edit_limit = " (rtos (nth (+ x 3) dcllst1) 2 0) ";") fo)
(write-line "   is_enabled = true ;" fo)
(write-line "   allow_accept=true ;" fo)
(write-line "    }" fo)
(setq x (+ x 4))
)
(write-line "    }" fo)
(setq x 0)
(write-line " : boxed_column {" fo)
(write-line " width =45;" fo)
(repeat (/ (- (length dcllst2) 1) 4)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(setq keynum (strcat "key" (rtos (setq y (+ Y 1)) 2 0)))
(write-line (strcat "    key = " (chr 34) keynum (chr 34) ";") fo)
(write-line (strcat " label = " (chr 34) (nth (+ x 1) dcllst2) (chr 34) ";") fo)
(write-line (strcat "     edit_width = " (rtos (nth (+ x 2) dcllst2) 2 0) ";") fo)
(write-line (strcat "     edit_limit = " (rtos (nth (+ x 3) dcllst2) 2 0) ";") fo)
(write-line "   is_enabled = true ;" fo)
(write-line "   allow_accept=true ;" fo)
(write-line "    }" fo)
(setq x (+ x 4))
)
(write-line "    }" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line "ok_cancel;}" fo)
(close fo)
(setq dcl_id (load_dialog fname))
(if (not (new_dialog "ddgetvalAH2col" dcl_id))
(exit)
)
(setq x 0)
(setq y 0)
(setq v_lst '())
(repeat (/ (- (length dcllst1) 1) 4)
(setq keynum (strcat "key" (rtos (setq y (+ Y 1)) 2 0)))
(setq key_lst (cons keynum key_lst))
(set_tile keynum (nth (setq x (+ x 4)) dcllst1))
)
(setq x 0)
(repeat (/ (- (length dcllst2) 1) 4)
(setq keynum (strcat "key" (rtos (setq y (+ Y 1)) 2 0)))
(setq key_lst (cons keynum key_lst))
(set_tile keynum (nth (setq x (+ x 4)) dcllst2))
)
(mode_tile "key1" 2)
(action_tile "accept" "(mapcar '(lambda (x) (setq v_lst (cons (get_tile x) v_lst))) key_lst)(done_dialog)")
(action_tile "cancel" "(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)
 ; (vl-file-delete fname)
(princ v_lst)
)



(setq lst1 (list "Enter values " 
"Template version" 20 19 "4.1.2.3"
"Branch" 20 19 "1"
"Job Number" 20 19 "123456"
"Job Name" 20 19 "ABCDEFGH"
"Builder" 20 19 "BoB"
"ADDRESS" 20 19 "x Street"
"City" 20 19 "Melbourne"
"Building permit #" 20 19 "####"
"Contact" 20 19 "Who"
"Contact Phone" 20 19 "xxxx xxx xxx"
"Cad Tech" 20 19 "me"
"Project Coordinator" 20 19 "Big Boss"
"Project Manager" 20 19 "BIG BIG Boss"
"Measurer" 20 19 "Got Tape"
"Salesman" 20 19 "Sales 1"
"Estimator" 20 19 "Estimator 1"
))
(setq lst2 (list "Enter values " 
"Drawing date" 20 19 "Today" 
"Date Req Glass" 20 19 "Tomorrow"
"Date req hardware" 20 19 "Day after"
"Glass Type" 20 19 "Smoky"
"Glass layers" 20 19 "Doubel Glazed"
"Glass Thickness" 20 19 "1 inch OA"
"Glass Composition" 20 19 "6mm Solarban"
"Glass Polish" 20 19 "Arris All"
"Hardware Finish" 20 19 "Clear Anodized Class II"
"Hardware Finish Code" 20 19 "C"
"Door Hardware Finish" 20 19 "Clear Anoized Class II"
"Hardware Finish Code" 20 19 "Clear Anoized Class 11"
))
(setq ans (AH:getvalsm2col "Please choose" lst1 lst2))

 

If you want to go down this path let me know, need to know all the child answers eg

Glass thickness

1" 2" 3"

 

Glass Finish

Smoky Black Clear Blasted

 

Re office once you select that child info the values will be updated in the parent dcl.

  • 3 weeks later...
Posted

This is fantastic, thank you! I wasn't expecting anyone to put together this extensive of a prototype for me.

 

The button for Branch selection is awesome! I think buttons for the other options would be a bit overkill though. For glass types and hardware finishes there are far too many options, combinations, paint colours, etc. for it to be feasible to list them all out, and we can usually copy/paste that info from the estimate sheet so text boxes would still work best.

 

Oh also question, Is it possible for text boxes to be autofilled with default values, or is that beyond the capabilities of dcl? Could it maybe autofill from the existing customprops so if the command is run a second time, it will display the currently entered values?

Posted

The 2 column getvals dcl has default values as part of the input. The code I posted above does that just try it when you look at lst1 and lst2, the last value is the defualt value. 

 

"Template version" 20 19 "4.1.2.3"

"Template version" is the description, the 20 19 is the edit box size , the "4.1.2.3" is default setting.

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...