justin1974 Posted February 25, 2003 Share Posted February 25, 2003 I'm tring to get my script to search through the symbol folder, look for a symbol and add it if not there. So far I have: Procedure BlockWall200; Var Need1: Boolean; Need, nosym,N,hx,hy:integer; Symh: HANDLE; Procedure drawsymbol; {DRAWS SYMBOL} BEGIN; BeginSym('symbolname'); Rect(0,0,200,200); EndSym; END; Procedure CheckSymbol; {CHECK TO SEE IF SYMBOL EXISTS} BEGIN; Need:=0; {ASSUME NEEDED} SymH:=Fsymdef; {SELECTS FIRST SYMBOL IN LIST} WHILE (SymH<>Nil) DO {LOOPS THROUGH LIST LOOKING FOR SYMBOL} Begin; Setselect(symH); IF GetSymName(symH)='Symbolname' THEN Need:=need+1 {IF FOUND THEN NOT NEED} ELSE Symh:=nextsymdef(symH); End; If Need=0 THEN Drawsymbol ELSE END; Procedure Drawwall; Begin; N:=(pheight DIV 200)-1; {SET NO OF BLOCKS TO DRAW} dselectall; Symbol('symbol',0,0,0); WHILE (N<>0) do Begin Setselect(lnewObj); Duplicate(0,200); N:=N-1; End; End; BEGIN; CheckSymbol; Drawwall; setzoom(getzoom); END; Run (blockwall200); If the symbol is not there then it adds it. If it is it causes VW to crash. Any suggestions?. Quote Link to comment
ccroft Posted February 26, 2003 Share Posted February 26, 2003 The script as you show it runs in 8.5.2 on mac os 9.2.2 with a couple of tweaks: I had to put a number in for "pheight". And change 'symbol' to 'symbolname' at some point. I also deleted the else after "then drawsymbol", but it ran either way. What value is pheight getting and from where? A value of 0 and you're in big trouble. 600 worked here. Make sure you have "offset duplicates" selected in prefs or they'll just pile up at 0x0y. I think you should call it "bricklayer". [ 02-25-2003, 10:03 PM: Message edited by: ccroft ] Quote Link to comment
justin1974 Posted February 26, 2003 Author Share Posted February 26, 2003 Thats intersting that you made it work. I'm running VW9.5. It still causes crashes. I'm using the script as a linear tool PIO so Pheight is the line length. I noticed the duplicate problem I made it much cleaner using: REPEAT Symbol(Symbolname,N*200,y,-90); N:=N-1; UNTIL (N=-1); When I use the tool the first time it will add the symbol if not there. Second time I use the tool VW crashes. If you wouldn't mind trying the following I'd be interested if; You are able to use the tool repeatedly?. What happens if you edit the symbol and use again. Does the tool redraw the symbol or leave the existing one as it was?. Thanks Quote Link to comment
ccroft Posted February 27, 2003 Share Posted February 27, 2003 Justin I can use the tool repeatedly. If I edit the symbol and run again, the script replaces 'symbolname' with the original as would be expected. I still suspect pheight. If it takes a value less than 200 the result of(pheight DIV 200)-1 will be -1. This will cause (and did on my machine) an infinite loop, since each iteration subtracts 1 from N. N will always be <> 0. If pheight is defined by a line you are likely to get a value less than 200 if units is set to meters or feet....a line 9 feet long (a common wall height) will set pheight to 9 and cause the infinite loop. You could remedy this in your original script by using: WHILE (N>0) do Begin In this case if the result of (pheight DIV 200)-1 is 0 or less, the loop will not be entered and no harm will be done. You could also add some code to set units to millimeters while the script runs. Quote Link to comment
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.