Rain0923 Posted March 31, 2015 Share Posted March 31, 2015 1. calculate total red pline area 2. total red pline area / black pline area How can I calculate area by lisp? test.dwg Quote Link to comment Share on other sites More sharing options...
pBe Posted March 31, 2015 Share Posted March 31, 2015 (edited) 2. total red pline area / black pline area Total RED area value divided by BLACK area value? ---> 0.238058 ?? or the other way around? 4.20066 ?? (defun c:demo ( / _total ss ssd TareaRed TareaBlack ComputedArea) (defun _total (sel / Value) (repeat (setq i (sslength sel)) (setq Value (cons (vlax-curve-getarea (ssname sel (setq i (1- i)))) Value))) (apply '+ Value) ) (defun _Rtos (v)(rtos v 2 2)) (if (and (princ "\nSelect RED pline(s)") (setq ss (ssget '((0 . "LWPOLYLINE")))) (princ "\nSelect Black pline") (setq ssD (ssget '((0 . "LWPOLYLINE")))) ) (progn (setq TareaRed (_total ss)) (setq TareaBlack (_total ssd)) (setq ComputedArea ( / TareaRed TareaBlack)) (alert (strcat "\nTotal area for RED pline(s): " (_rtos TareaRed ) "\nTotal area for BLACK pline(s): " (_rtos TareaBlack ) "\nTotal RED divided by BLACK: " (_rtos ComputedArea) "\nPercentage: " (_rtos (* 100.00 ComputedArea)) "%")) ) ) (princ) ) Edited April 1, 2015 by pBe Quote Link to comment Share on other sites More sharing options...
Rain0923 Posted April 1, 2015 Author Share Posted April 1, 2015 Thanks 0.238058 is right. This lisp is good but the layer is not in CSM then it can't use. Can it change not lock any layer name or color? Total RED area value divided by BLACK area value? ---> 0.238058 ?? or the other way around? 4.20066 ?? (defun c:demo ( / RED ss s TArea RED_TOTAL BLACK) (if (and (princ "\nSelect RED pline(s)") (setq RED nil ss (ssget '((0 . "LWPOLYLINE")(8 . "CSM")))) (princ "\nSelect Black pline") (setq s (ssget "_:S" '((0 . "LWPOLYLINE")))) ) (progn (repeat (setq i (sslength ss)) (setq RED (cons (vlax-curve-getarea (ssname ss (setq i (1- i)))) RED))) (setq TArea (/ (setq RED_TOTAL (apply '+ RED)) (setq BLACK (vlax-curve-getarea (ssname s 0))))) (princ (strcat "\nTotal area for RED pline(s): " (rtos RED_TOTAL 2 2))) (princ (strcat "\nBlack Pline area: " (rtos BLACK 2 2))) (princ (strcat "\nTotal RED divided by BLACK: " (rtos TArea 2 2))) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
pBe Posted April 1, 2015 Share Posted April 1, 2015 But of course, just remove (8 . "CSM") from the code. What other conditions to you need to add? Is the divisor always one entity? Quote Link to comment Share on other sites More sharing options...
Rain0923 Posted April 1, 2015 Author Share Posted April 1, 2015 Great!!It can use now. Is any probably show percentage? No, the divisor is not always one entity.Can it update? Thanks:) But of course, just remove (8 . "CSM") from the code. What other conditions to you need to add? Is the divisor always one entity? Quote Link to comment Share on other sites More sharing options...
pBe Posted April 1, 2015 Share Posted April 1, 2015 Is any probably show percentage? How do you get the percentage Rain0923? Show me so there would be no confusion No, the divisor is not always one entity.Can it update? Thanks:) Yes Quote Link to comment Share on other sites More sharing options...
Rain0923 Posted April 1, 2015 Author Share Posted April 1, 2015 It like show 0.238058 and 23.81%... Thanks How do you get the percentage Rain0923? Show me so there would be no confusion Yes Quote Link to comment Share on other sites More sharing options...
pBe Posted April 1, 2015 Share Posted April 1, 2015 CODE UPDATED: Post#2 Quote Link to comment Share on other sites More sharing options...
Rain0923 Posted April 1, 2015 Author Share Posted April 1, 2015 Sorry!!Where is updating?? CODE UPDATED: Post#2 Quote Link to comment Share on other sites More sharing options...
pBe Posted April 1, 2015 Share Posted April 1, 2015 Post # 2 This thread. UP there ↑ Quote Link to comment Share on other sites More sharing options...
Rain0923 Posted April 1, 2015 Author Share Posted April 1, 2015 Got it!!Many Thanks............ Post # 2 This thread. UP there ↑ [ATTACH=CONFIG]53553[/ATTACH] Quote Link to comment Share on other sites More sharing options...
Rain0923 Posted April 1, 2015 Author Share Posted April 1, 2015 Sorry!!May I ask other question? Can it do like in the attachment? Thanks Post # 2 This thread. UP there ↑ [ATTACH=CONFIG]53553[/ATTACH] teat1.dwg Quote Link to comment Share on other sites More sharing options...
pBe Posted April 1, 2015 Share Posted April 1, 2015 Can it do like in the attachment? YES, but are you aware you can do the ADD/Subtract using the native area command? We can go back and forth on this, so take a deep breath write down ALL the conditions, sample drawings, results and all. Then post it here. You should have done all that from the get-go Rain0923. Quote Link to comment Share on other sites More sharing options...
Rain0923 Posted April 1, 2015 Author Share Posted April 1, 2015 Yes,sorry bother you again.My English is not good so sometimes I don't know how to explain my question.Sorry again..... This is another demand. I want separate to two lisp. 1.You give to me already. 2.So.......ask you this question just now. and I clearly condition more in the attachment.Please (still need all area answers and percentage) YES, but are you aware you can do the ADD/Subtract using the native area command? We can go back and forth on this, so take a deep breath write down ALL the conditions, sample drawings, results and all. Then post it here. You should have done all that from the get-go Rain0923. teat2.dwg Quote Link to comment Share on other sites More sharing options...
pBe Posted April 2, 2015 Share Posted April 2, 2015 (edited) This is another demand... 2.So.......ask you this question just now. and I clearly condition more in the attachment.Please (still need all area answers and percentage) I will look into this, cant seem to wrap my head on how to go about the selection. its definitively doable. EDIT: show us an example where there are two or more green area for divisor. Edited April 2, 2015 by pBe Quote Link to comment Share on other sites More sharing options...
Rain0923 Posted April 7, 2015 Author Share Posted April 7, 2015 Please have the file, I add divisor in the file.Thanks:oops: I will look into this, cant seem to wrap my head on how to go about the selection. its definitively doable. EDIT: show us an example where there are two or more green area for divisor. teat3.dwg Quote Link to comment Share on other sites More sharing options...
pBe Posted April 7, 2015 Share Posted April 7, 2015 Please have the file, I add divisor in the file.Thanks:oops: Still thinking of the best way to select the objects. IMO test3.dwg does not represent the whole picture. We need a real world drawing sample Rain0923 One question: Layers.... It would be loads easier for selection if the objects are set to a specific layer but then again maybe not. We can do pairs then toggle between two boundaries to identify which one is to be subtracted. or even prompt selection with Subtract / ADD /Divide mode, much like the native Area command only more user friendly [ maybe havent really used Area command myself ] Quote Link to comment Share on other sites More sharing options...
neophoible Posted April 7, 2015 Share Posted April 7, 2015 pBe, actually, you could use the AREA command in the routine and retrieve the result using (getvar "AREA"), but I doubt that's your preference. razara, it would be best if you show the output you are expecting for the sample drawing you have provided. Type it in just the way you want it to show. Are you always selecting in pairs, except for the boundary divisors? Can you have more than two divisors? Why not just explain what you are actually trying to accomplish with these calculations? Quote Link to comment Share on other sites More sharing options...
Rain0923 Posted April 8, 2015 Author Share Posted April 8, 2015 -->The objects are not set to a specific layer. -->You are right that is really more friendly. Maybe we can let question more sample that like calculating machine with Subtract / ADD /Divide mode they can use selection by user. lisp can do? Thanks Still thinking of the best way to select the objects. IMO test3.dwg does not represent the whole picture. We need a real world drawing sample Rain0923 One question: Layers.... It would be loads easier for selection if the objects are set to a specific layer but then again maybe not. We can do pairs then toggle between two boundaries to identify which one is to be subtracted. or even prompt selection with Subtract / ADD /Divide mode, much like the native Area command only more user friendly [ maybe havent really used Area command myself ] Quote Link to comment Share on other sites More sharing options...
pBe Posted April 8, 2015 Share Posted April 8, 2015 pBe, actually, you could use the AREA command in the routine and retrieve the result using (getvar "AREA"), but I doubt that's your preference. That is correct neophoible, but might as well use the AREA command itself outside the routine for ADD/SUBTRACT and then run a short code for divide using (getvar 'area) [as you suggested] as an argument. Maybe we can let question more sample that like calculating machine with Subtract / ADD /Divide mode they can use selection by user. lisp can do? Thanks Your maybe onto something there Rain0923. 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.