flowerrobot Posted June 9, 2009 Share Posted June 9, 2009 Ive being useing the program for quite some time. I wrote it early start of year, (thanks amsi for a tad of code) But all of a sudden it give's me a error. not as in an error error. but not doing exscatly what i want it to do, basicly the distance is random. but randomly close to what it should be, but not quite. ;;;;;;;;;;; ;Welcome to the item bubble lisp ;;;;;;;;;;; ;;;;;;;;;;; ;Verson 0.01 ;;;;;;;;;;; ;;;;;;;;;;; ;Created on 17 Feb 2009 ;;;;;;;;;;; ;;;;;;;;;;; ;Last edited by Flower on ;;;;;;;;;;; ;;;;;;;;;;; ;7 april 2009 ;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:IT (/ *error* Mypoint1 Mypoint2 itemang tOldLayer oldosmode bl itemdist) (vl-load-com) (defun my_error (errormsg) (if (not (member ERRORMSG '("console break" "Function Cancelled"))) (princ (strcat "\nError:" errormsg)) ) (setvar "osmode" oldosmode) (setq *error* temperr) (setvar "cmdecho" 1) (princ) ) (defun PutDynamicProperty(Block Property Value / oVal cVal) (if(= 'ENAME(type Block)) (setq Block(vlax-ename->vla-object Block)) ); end if (if(= :vlax-true(vla-get-IsDynamicBlock Block)) (foreach p (vlax-safearray->list (vlax-variant-value (vla-GetDynamicBlockProperties Block) ) ) (if(=(strcase Property)(strcase(vla-get-PropertyName p))) (progn (setq cVal(vlax-make-variant Value vlax-vbDouble)) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Value(list p cVal) ) ) (setq oVal nil) (setq oVal Value) ); end if ); end progn ); end if ); end foreach ); end if ; oVal ) ; (setvar "cmdecho" 0) (setq tOldLayer (getvar "CLAYER") oldosmode (getvar "osmode") temperr *error* *error* my_error ) (command "osmode" "512") (setq Mypoint1 (getpoint "\nSelect tip of Arrow : ") Mypoint2 (getpoint "\nSelect Centrepoint of Bubble: " Mypoint1) ) (command "osmode" oldosmode) (if (not(tblsearch "block" "ITEMBALLOON")) (progn (command "-insert" "ITA" Mypoint2 "1" "1" "0") (COMMAND "ERASE" (ENTLAST) "") ) ) (setq itemdist (rtos (distance Mypoint1 Mypoint2)2 0) itemang (angle Mypoint2 Mypoint1) ds (getvar "dimscale") ) (if (= itnumba nil) (setq itnumba nxtitno) ) (if (= nxtitno nil) (setq nxtitno 1) (setq nxtitno (+ itnumba +1)) ) (setq itemnumba (rtos nxtitno 2 0) itnumba (getINT (STRCAT "\nWhat number? <" itemnumba "> :")) ) (if (or (= itnumba nil)(= itnumba "")) (setq insertnumba nxtitno) (setq insertnumba (rtos itnumba 2 0)) ) (command "ATTDIA" 0) (setvar "CLAYER" "dim") (command "-insert" "ITEMBALLOON" Mypoint2 DS DS "0" insertnumba) (if (= tOldLayer "dim") (setvar "CLAYER" "YELLOW") (setvar "CLAYER" tOldLayer) ) (command "ATTDIA" 1) (setq bl (entlast)) (PutDynamicProperty bl "itemdistance" itemdist) (PutDynamicProperty bl "ANGLE" itemang) ;(PutDynamicProperty bl "Visibility" "Pointer") (setvar "cmdecho" 1) (princ) ) Also how do you creat folders like "c:\Program Files\Flowers folder" easy enought to wright a file to a folder and the like, but not make a propper folder ITA.dwg Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 9, 2009 Share Posted June 9, 2009 Make sure snap and grid is off, also if your using osmode settings these can do weird things at some zoom scales pulled my hair trying to find out why 1 program did not work all the time zoom scale was problem have found various lisp bugs over the years that are just part of Autocad and have to write around them. Quote Link to comment Share on other sites More sharing options...
flowerrobot Posted June 9, 2009 Author Share Posted June 9, 2009 Indeed, I have seen the zoom error, now and then. Osmode, grid is off, and it happening on a few drawing, hence my worrie, it has screwed up a few time over the time. Do you suggest a better method that an osmode, to get nearest? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 9, 2009 Share Posted June 9, 2009 This should sort you out for the mean time hopefully, but if I had more time, I would like to re-write it ;;;;;;;;;;; ;Welcome to the item bubble lisp ;;;;;;;;;;; ;;;;;;;;;;; ;Verson 0.01 ;;;;;;;;;;; ;;;;;;;;;;; ;Created on 17 Feb 2009 ;;;;;;;;;;; ;;;;;;;;;;; ;Last edited by Flower on ;;;;;;;;;;; ;;;;;;;;;;; ;7 April 2009 ;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:IT (/ *error* Mypoint1 Mypoint2 itemang tOldLayer oldosmode bl itemdist) (vl-load-com) (defun my_error (errormsg) (if (not (member errormsg '("console break" "Function Cancelled"))) (princ (strcat "\nError:" errormsg))) (setvar "osmode" oldosmode) (setq *error* temperr) (setvar "cmdecho" 1) (princ)) (defun PutDynamicProperty (Block Property Value / oVal cVal) (if (= 'ENAME (type Block)) (setq Block (vlax-ename->vla-object Block))) (if (= :vlax-true (vla-get-IsDynamicBlock Block)) (foreach p (vlax-safearray->list (vlax-variant-value (vla-GetDynamicBlockProperties Block) ) ) (if(=(strcase Property)(strcase(vla-get-PropertyName p))) (progn (setq cVal(vlax-make-variant Value vlax-vbDouble)) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Value(list p cVal) ) ) (setq oVal nil) (setq oVal Value) ); end if ); end progn ); end if ); end foreach ); end if ; oVal ) ; (setvar "cmdecho" 0) (setq tOldLayer (getvar "CLAYER") oldosmode (getvar "osmode") temperr *error* *error* my_error ) (command "osmode" "512") (setq Mypoint1 (getpoint "\nSelect tip of Arrow : ") Mypoint2 (getpoint "\nSelect Centrepoint of Bubble: " Mypoint1) ) (command "osmode" oldosmode) (if (not(tblsearch "block" "ITEMBALLOON")) (progn (command "-insert" "ITA" Mypoint2 "1" "1" "0") (COMMAND "ERASE" (ENTLAST) "") ) ) (setq itemdist (rtos (distance Mypoint1 Mypoint2) 2 0) itemang (angle Mypoint2 Mypoint1) ds (getvar "dimscale") ) (or itemnumba (setq itemnumba 1)) (setq tmp (getINT (STRCAT "\nWhat number? <" itemnumba "> :")) ) (or (not tmp) (Setq itemnumba tmp)) (command "ATTDIA" 0) (setvar "CLAYER" "dim") (setvar "OSMODE" 0) (command "-insert" "ITEMBALLOON" Mypoint2 DS DS "0" itemnumba) (if (= tOldLayer "dim") (setvar "CLAYER" "YELLOW") (setvar "CLAYER" tOldLayer) ) (command "ATTDIA" 1) (setq bl (entlast)) (PutDynamicProperty bl "itemdistance" itemdist) (PutDynamicProperty bl "ANGLE" itemang) ;(PutDynamicProperty bl "Visibility" "Pointer") (setvar "cmdecho" 1) (Setvar "OSMODE" oldosmode) (princ) ) Quote Link to comment Share on other sites More sharing options...
flowerrobot Posted June 9, 2009 Author Share Posted June 9, 2009 I would like to re-write it As would i, But as you said, time.... Basicly all you have done , apart from changed the item number squence, Is place osmode to "0" Surly, this should be the cause as its being inserted to a point, and shouldnt snap? Thanks for the help. Any one know how to create folder's tho? Quote Link to comment Share on other sites More sharing options...
ronjonp Posted June 9, 2009 Share Posted June 9, 2009 Look into vl-mkdir to create a folder. Quote Link to comment Share on other sites More sharing options...
flowerrobot Posted June 10, 2009 Author Share Posted June 10, 2009 cheers "10 char long" Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 11, 2009 Share Posted June 11, 2009 Re nearest problem maybe use "entsel" it can give you the pick point will have to look that up in code. Found (SETQ TP1 (entsel "\nSelect wall: ")) (setq tpp1 (entget (car tp1))) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 11, 2009 Share Posted June 11, 2009 You could OSNAP the point return of the ENTSEL to "nearest": (setq ent (entsel "\nSelect Something... ") pt (osnap (cadr ent) "_nea")) Or, alternatively, (and more reliable): (setq ent (entsel "\nSelect Something...") pt (vlax-curve-getClosestPointto (car ent) (cadr ent))) Quote Link to comment Share on other sites More sharing options...
flowerrobot Posted June 12, 2009 Author Share Posted June 12, 2009 They may be more reliable but, It is to much hassel tho. Basicly all the input that should be is, leader point, center of circle and what number. Its quick simple and easy thanks for your help.. Saddly its getting worse, i pulled it out of the lisp routines i have for my mates at work. Thanks Quote Link to comment Share on other sites More sharing options...
flowerrobot Posted June 12, 2009 Author Share Posted June 12, 2009 I have find the error, But not the cause it sets the distance to 22.9043 no matter what. But it sets the angle fine Why?? Quote Link to comment Share on other sites More sharing options...
flowerrobot Posted June 12, 2009 Author Share Posted June 12, 2009 FFs, i did a find and replace for Dist, and it placed Itemdistance in stead of distance. What an idiot Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.