help with an output

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
I am editting someone else's code and trying to break it down and simplify it, however I am stuck trying to figure out what some parts of the code do.
I've added notes in all the parts I can figure out, but there are a few parts that don't really make sense to me and are not putting out the results I'm expecting.
what the code does is when you select a block in CAD, it will read the dynamic properties and label it and give it a capacity rating according to your input or the list provided.
originally, it would also run a calculation to get it's vertical forces depending what angle the block was at, but I am removing that portion. part of this exercise is also to clean up the code a bit as it tends to crash unexpectedly every so often.
here is the code:
(defun polyslingratingcheck (/ test polysling slinglength userdatalabel sset sset1 ) (if (not userdata) ;;if userdata has been previously set in this session, it is set to blank or "" (setq userdata "") ) ;;this portion grabs the length of the poly sling via block properties and asks for the size/capacity and stores it to userdatalabel (setq test T polytext "" polysling nil slinglength (getdynpropvalue (vlax-ename->vla-object name) "Sling Length" ) userdatalabel (getstring (strcat "Enter polyround size designation or capacity in KIP(__K) <" userdata ">: " ) ) ) ;;if one of the below is typed in, it will use the far right numbers for a capacity (if (= userdatalabel "") (setq userdata userdata) (setq userdata userdatalabel) ) (while test (setq polyslingcap (cond ((wcmatch (strcase userdata) "A3") 3000) ((wcmatch (strcase userdata) "A6") 6000) ((wcmatch (strcase userdata) "A9") 9000) ((wcmatch (strcase userdata) "A12") 12000) ((wcmatch (strcase userdata) "A14") 14000) ((wcmatch (strcase userdata) "A17") 17000) ((wcmatch (strcase userdata) "A23") 23000) ((wcmatch (strcase userdata) "A26") 26000) ((wcmatch (strcase userdata) "A32") 32000) ((wcmatch (strcase userdata) "A40") 40000) ((wcmatch (strcase userdata) "A54") 54000) ((wcmatch (strcase userdata) "A68") 68000) ((wcmatch (strcase userdata) "A70") 70000) ((wcmatch (strcase userdata) "A90") 90000) ((wcmatch (strcase userdata) "LL1") 2600) ((wcmatch (strcase userdata) "LL2") 5300) ((wcmatch (strcase userdata) "LL3") 8400) ((wcmatch (strcase userdata) "LL4") 10600) ((wcmatch (strcase userdata) "LL5") 13200) ((wcmatch (strcase userdata) "LL6") 16800) ((wcmatch (strcase userdata) "LL7") 21200) ((wcmatch (strcase userdata) "LL8") 25000) ((wcmatch (strcase userdata) "LL9") 31000) ((wcmatch (strcase userdata) "LL10") 40000) ((wcmatch (strcase userdata) "LL11") 53000) ((wcmatch (strcase userdata) "LL12") 66000) ((wcmatch (strcase userdata) "LL13") 90000) ((/= (atof userdata) 0) (atof userdata)) (nil) ) ) ;;i don't know what this portion is for, but it is seems to be required for the code to work (if polyslingcap (setq polysling (cond ((<= 90000 polyslingcap) (list polyslingcap 5.22 7.38 polyslingcap 7000) ) ((> 5300 polyslingcap) (list polyslingcap 0.97 1.37 polyslingcap 7000) ) ((> 8400 polyslingcap) (list polyslingcap 1.29 1.82 polyslingcap 7000) ) ((> 10600 polyslingcap) (list polyslingcap 1.66 2.34 polyslingcap 7000) ) ((> 13200 polyslingcap) (list polyslingcap 1.78 2.52 polyslingcap 7000) ) ((> 16800 polyslingcap) (list polyslingcap 2.00 2.80 polyslingcap 7000) ) ((> 21200 polyslingcap) (list polyslingcap 2.13 3.00 polyslingcap 7000) ) ((> 25000 polyslingcap) (list polyslingcap 2.62 3.71 polyslingcap 7000) ) ((> 31000 polyslingcap) (list polyslingcap 2.85 4.00 polyslingcap 7000) ) ((> 40000 polyslingcap) (list polyslingcap 3.15 4.45 polyslingcap 7000) ) ((> 53000 polyslingcap) (list polyslingcap 3.57 5.06 polyslingcap 7000) ) ((> 66000 polyslingcap) (list polyslingcap 4.00 5.62 polyslingcap 7000) ) ((> 90000 polyslingcap) (list polyslingcap 4.60 6.50 polyslingcap 7000) ) ) ) ) (if polysling (setq test nil) (setq userdatalabel (getstring (strcat "Polysling not supported. Enter polyround size designation or capacity in KIP(__K) <" userdata ">: " ) ) ) ) (if (= userdatalabel "") (setq userdata userdata) (setq userdata userdatalabel) ) ) ;;Poly Round sling labels that are entered in the leader (setq sltext (strcat "POLYESTER ROUND SLING, " (strcase userdatalabel) " x " (rtos (/ slinglength 25.4) 4) "\n" (rtos (/ (float (nth 0 polysling)) cvtonne2lb) 2 1) " Te (" (flakenum (rtos (nth 0 polysling) 2 0)) " lbs) CAP" ) ) )
thanks