- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
A while back I had some good help to program a lisp from some awesome people on the form (@ВeekeeCZ & @dlanorh) and since then I have been learning a little a bit. I am now back with some help to figure out a logic problem; at least I think it is.
What I need to do now is prompt the user to select one of three block names (IS0X, COMBINER, SUB_BUS). The combinations can be the following: IS0X and IS0X, IS0X and SUB_BUS, COMBINER and IS0X, COMBINER and COMBINER.
The original code looks at two blocks of pre-determined names, pulls the attribute information and prompts the user to make a polyline to determine the length between the two-insertion point, and last, all the info collected is placed into a block. I am still doing this but the above combinations have become common and I would do them by hand when the lisp could not do it, due to the logic issue.
This is the hard part I have to think like a kid and make sure the user can't select the block in the same location (the blocks that share the same name will be a distance apart).
I will post the blocks for the fun if someone wants to play with them.
This is the code I have thus far and it's not working but I want to try to do as much as u can on my own. As I am trying to learn and not just asking for someone to code for me.
I am pretty sure I would have to make the changes to the :blockselect sub and code below it but i am still a little green on how to approach this.
;--------------------------------------------------------------------------------- ; Block selection function ;--------------------------------------------------------------------------------- ; Block selection - BeekeeCZ ; Prompts user to select a block ; If block doesnt match block names that are accepted will return wrong block ; If block matchs ;--------------------------------------------------------------------------------- (defun :blockselect (flt / done out ens ben) ; flt - the block names put in ; done - (while (not done) (and (setvar 'errno 0) ; needs to be reset (setq ens (entsel (strcat "\nPick block " flt " at side to connect: "))) (setq ben (car ens)) (cond ((= 52 (getvar 'errno)) ; Right click to exit (setq done T)) ((= 7 (getvar 'errno)) ; missed block (princ "\nError: Missed, try again.")) ((/= "INSERT" (cdr (assoc 0 (entget ben)))) ; not a block (princ "\nError: Wrong selection, BLOCK is required.")) ((not (wcmatch (setq bln (strcase (:getBlockName ben))) flt)) ; picked a random block (princ "\nError: Wrong block, a vaild BLOCK is required.")) (T (princ (strcat "\nBlock selected: " bln)) (foreach itm (LM:getattributeswithvalues ben) (princ (strcat ", " (car itm) ": " (cdr itm)))) (setq done T out (list bln ben (osnap (cadr ens) "_mid"))))))) out) ;--------------------------------------------------------------------------------- ; this is the part of code that is confirming my combination (and (setq blk (:blockselect "COMBINER,IS0X,SUB_BUS")) ; select the second point in reff to first (cond ((= (car blk) "IS0X") (setq bl1 (if (= (car blk) "IS0X") blk (:blockselect "IS0X"))) (setq bl2 (if (= (car blk) "IS0X") blk (:blockselect "IS0X"))) ; get name and destination info (setq a11 (LM:getattributevalue (cadr bl1) "T_NUM")) (setq a12 (LM:getattributevalue (cadr bl1) "COMBINER")) (setq a21 (LM:getattributevalue (cadr bl2) "C_NUM")) ) ((= (car blk) "COMBINER") (setq bl1 (if (= (car blk) "COMBINER") blk (:blockselect "COMBINER"))) (setq bl2 (if (= (car blk) "IS0X") blk (:blockselect "IS0X")))
; so forth.
Solved! Go to Solution.