Search the Community
Showing results for tags 'conditionals'.
-
Update Field with Conditional Statement Referencing DWGPROPS
Kyler posted a topic in AutoCAD Drawing Management & Output
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, -
Adding Error Checking or Conditionals (and combining functions)?
ILoveMadoka posted a topic in AutoLISP, Visual LISP & DCL
I have a small app that (with the help of those here) I have pieced together. I don't know how to do add error checking (or conditionals) so that I don't get scrolling errors for the items that are not found. Also, I think some of the items could be combined for my (ssget "x") but I'm not clear on how that works either. Requesting tweaking of my code or guidance. Warning: I am still a novice... Here is my code: (DEFUN C:SW1 () (Prompt "SolidWorks DWG Cleanup:") (setq TEST (tblsearch "LAYER" "Dim")) (if (= TEST nil) (progn (Command "-layer" "n" "Dim" "C" "Red" "Dim" "") ) ) (setq ss1 (ssget "x" '((0 . "INSERT")(2 . "*SW_CENTERMARKSYMBOL_*")))) (Command "Erase" SS1 "") (setq ss2 (ssget "x" '((0 . "INSERT")(2 . "*SW_NOTE_1*")))) (Command "Erase" SS2 "") (setq ss3 (ssget "x" '((0 . "INSERT")(2 . "*SW_TABLEANNOTATION_0*")))) (Command "Erase" SS3 "") (Command "-style" "Romans" "romans" "" "0.9" "" "" "n" "n") (princ "\nRomans Text Style Created:") (command "dimstyle" "r" "standard") (command "dimtxsty" "romans") (Command "dimstyle" "s" "standard" "y" ) (if (setq ss (ssget "x" '((0 . "DIMENSION")))) (repeat (setq i (sslength ss)) (setq sset (ssname ss (setq i (1- i)))) (if (not (eq (cdr (assoc 3 (setq e (entget sset)))) "Standard")) (entmod (subst (cons 3 "Standard") (assoc 3 e) e)) ) ) (princ) ) (setq ss4 (ssget "x" '((0 . "DIMENSION")))) (Command "_CHANGE" SS4 "" "P" "LA" "DIM" "C" "BYLAYER" "") (Command "_LAYER" "C" "GREEN" "X50" "C" "yellow" "TEXT" "") (setq ss5 (ssget "x" '((6 . "PHANTOM")))) (Command "_CHANGE" SS5 "" "P" "LA" "X25" "C" "BYLAYER" "LT" "PHANTOM" "") (setq ss6 (ssget "x" '((6 . "HIDDEN")))) (Command "_CHANGE" SS6 "" "P" "LA" "X25" "C" "BYLAYER" "LT" "HIDDEN" "") (setq ss7 (ssget "x" '((6 . "DASHED")))) (Command "_CHANGE" SS7 "" "P" "LA" "X25" "C" "BYLAYER" "LT" "DASHED" "") (princ)) Thanks to all...