boundary problem

Discussion in 'AutoCAD' started by felixlee, Nov 22, 2004.

  1. felixlee

    felixlee Guest

    I am using boundary command to create a boundary. I do know I have already specified a point inside the boundary( named pt17). However, boundary command cant detect any alive boundary after several rounds. I have a area command to determine the area of that boundary. So if there is no boundary, area command asks me for a boundary. Because I am using "repeat" to do the loop, when area command breaks, the loop dies.
    PS. boundary command works fine in the beginning.
    Here is my lisp, thanks for your help.
    (setq spacing (getint "\n Input distance of grid:"))
    (setq layer5m (getstring "\n Input the layer name of contour-5m:"))
    (setq layer1m (getstring "\n Input the layer name of contour-1m:"))
    (setq pt0 (getpoint "\n Input the left-bottom point"))
    (setq ptend (getpoint "\n Input the upper-right point"))
    (setq totallength (distance pt0 ptend))
    (setq tempangle (angle pt0 ptend))
    (setq oriangle (getangle "\n Input angle between base line:"))
    (command "layer" "n" "å¡åº¦åˆ†æž" "S" "å¡åº¦åˆ†æž" "")
    (setq tempangle1 (- tempangle oriangle))
    (setq mmmm (/ (* totallength (cos tempangle1)) spacing))
    (setq mm (fix mmmm))
    (setq nnnn (/ (* totallength (sin tempangle1)) spacing))
    (setq nn (fix nnnn))
    (if (= spacing 10) (setq fontheight 1.5))
    (if (= spacing 25) (setq fontheight 3.75))
    (setq n 0)
    (setq m 0)
    (setq radian (atan n m))
    (setq length1 (* (sqrt (+ (* n n) (* m m))) spacing))
    (setq INTH1 0)
    (setq VALUEINTH1 0)
    (setq INTV1 0)
    (setq VALUEINTV1 0)
    (setq INTH2 0)
    (setq VALUEINTH2 0)
    (setq INTV2 0)
    (setq VALUEINTV2 0)
    (setq VALUEINT 0)
    (setq pt1 (polar pt0 (+ radian oriangle) length1))
    (setq pt2 (polar pt1 oriangle spacing))
    (setq pt3 (polar pt1 oriangle (/ spacing 2)))
    (setq pt4 (polar pt1 (+ (/ pi 2) oriangle) spacing))
    (setq pt5 (polar pt1 (+ (/ pi 2) oriangle) (/ spacing 2)))
    (setq pt6 (polar pt4 oriangle spacing))
    (setq pt7 (polar pt4 oriangle (/ spacing 2)))
    (setq pt8 (polar pt2 (+ (/ pi 2) oriangle) (/ spacing 2)))
    (setq pt9 (polar pt3 (+ (/ pi 2) oriangle) (/ spacing 5)))
    (setq pt10 (polar pt3 (+ (/ pi 2) oriangle) (/ spacing 2.5)))
    (setq pt11 (polar pt3 (+ (/ pi 2) oriangle) (/ spacing 1.67)))
    (setq pt12 (polar pt3 (+ (/ pi 2) oriangle) (/ spacing 1.25)))
    (setq pt13 (polar pt1 (+ (atan 1) oriangle) 0.01))
    (setq pt14 (polar pt13 (+ (/ pi 2) oriangle) (- spacing 0.02)))
    (setq pt15 (polar pt14 oriangle (- spacing 0.02)))
    (setq pt16 (polar pt13 oriangle (- spacing 0.02)))
    (setq pt21 (polar pt1 oriangle (* spacing 0.25)))
    (setq pt22 (polar pt1 oriangle (* spacing 0.75)))
    (setq pt23 (polar pt1 (+ (/ pi 2) oriangle) (* spacing 0.25)))
    (setq pt24 (polar pt1 (+ (/ pi 2) oriangle) (* spacing 0.75)))
    (setq pt25 (polar pt4 oriangle (* spacing 0.25)))
    (setq pt26 (polar pt4 oriangle (* spacing 0.75)))
    (setq pt27 (polar pt2 (+ (/ pi 2) oriangle) (* spacing 0.25)))
    (setq pt28 (polar pt2 (+ (/ pi 2) oriangle) (* spacing 0.75)))
    (setq myfilter (list '(-4 . "<or") (cons 8 layer5m) (cons 8 layer1m) '(-4 . "or>") ))
    (setq INTH11 (ssget "F" (list pt1 pt21) myfilter ))
    (if (= INTH11 nil) (setq VALUEINTH11 0) (setq VALUEINTH11 (sslength INTH11)))
    (setq INTH12 (ssget "F" (list pt21 pt3) myfilter ))
    (if (= INTH12 nil) (setq VALUEINTH12 0) (setq VALUEINTH12 (sslength INTH12)))
    (setq INTH13 (ssget "F" (list pt3 pt22) myfilter ))
    (if (= INTH13 nil) (setq VALUEINTH13 0) (setq VALUEINTH13 (sslength INTH13)))
    (setq INTH14 (ssget "F" (list pt22 pt2) myfilter ))
    (if (= INTH14 nil) (setq VALUEINTH14 0) (setq VALUEINTH14 (sslength INTH14)))
    (setq VALUEINTH1 (+ VALUEINTH11 VALUEINTH12 VALUEINTH13 VALUEINTH14))
    (setq INTH21 (ssget "F" (list pt4 pt25) myfilter ))
    (if (= INTH21 nil) (setq VALUEINTH21 0) (setq VALUEINTH21 (sslength INTH21)))
    (setq INTH22 (ssget "F" (list pt25 pt7) myfilter ))
    (if (= INTH22 nil) (setq VALUEINTH22 0) (setq VALUEINTH22 (sslength INTH22)))
    (setq INTH23 (ssget "F" (list pt7 pt26) myfilter ))
    (if (= INTH23 nil) (setq VALUEINTH23 0) (setq VALUEINTH23 (sslength INTH23)))
    (setq INTH24 (ssget "F" (list pt26 pt6) myfilter ))
    (if (= INTH24 nil) (setq VALUEINTH24 0) (setq VALUEINTH24 (sslength INTH24)))
    (setq VALUEINTH2 (+ VALUEINTH21 VALUEINTH22 VALUEINTH23 VALUEINTH24))
    (setq INTV11 (ssget "F" (list pt1 pt23) myfilter ))
    (if (= INTV11 nil) (setq VALUEINTV11 0) (setq VALUEINTV11 (sslength INTV11)))
    (setq INTV12 (ssget "F" (list pt23 pt5) myfilter ))
    (if (= INTV12 nil) (setq VALUEINTV12 0) (setq VALUEINTV12 (sslength INTV12)))
    (setq INTV13 (ssget "F" (list pt5 pt24) myfilter ))
    (if (= INTV13 nil) (setq VALUEINTV13 0) (setq VALUEINTV13 (sslength INTV13)))
    (setq INTV14 (ssget "F" (list pt24 pt4) myfilter ))
    (if (= INTV14 nil) (setq VALUEINTV14 0) (setq VALUEINTV14 (sslength INTV14)))
    (setq VALUEINTV1 (+ VALUEINTV11 VALUEINTV12 VALUEINTV13 VALUEINTV14))
    (setq INTV21 (ssget "F" (list pt2 pt27) myfilter ))
    (if (= INTV21 nil) (setq VALUEINTV21 0) (setq VALUEINTV21 (sslength INTV21)))
    (setq INTV22 (ssget "F" (list pt27 pt8) myfilter ))
    (if (= INTV22 nil) (setq VALUEINTV22 0) (setq VALUEINTV22 (sslength INTV22)))
    (setq INTV23 (ssget "F" (list pt8 pt28) myfilter ))
    (if (= INTV23 nil) (setq VALUEINTV23 0) (setq VALUEINTV23 (sslength INTV23)))
    (setq INTV24 (ssget "F" (list pt28 pt6) myfilter ))
    (if (= INTV24 nil) (setq VALUEINTV24 0) (setq VALUEINTV24 (sslength INTV24)))
    (setq VALUEINTV2 (+ VALUEINTV21 VALUEINTV22 VALUEINTV23 VALUEINTV24))
    (setq VALUEINT (+ VALUEINTH1 VALUEINTH2 VALUEINTV1 VALUEINTV2))
    (setq oriangledegree (* (/ oriangle pi) 180))
    (command "text" "j" "mc" pt3 fontheight oriangledegree VALUEINTH1)
    (command "text" "j" "mc" pt5 fontheight oriangledegree VALUEINTV1)
    (command "text" "j" "mc" pt7 fontheight oriangledegree VALUEINTH2)
    (command "text" "j" "mc" pt8 fontheight oriangledegree VALUEINTV2)
    (setq INTOFBOUND (ssget "F" (list pt13 pt14 pt15 pt16 pt13) '((8 . "邊界"))))
    (if (= INTOFBOUND nil) ()
    (progn (command "layer" "off" "*" "y" "")
    ;(if (= T (<= m (/ mm 2)) (<= n (/ nn 2))) (setq pt17 pt15))
    ;(if (= T (<= m (/ mm 2)) (>= n (/ nn 2))) (setq pt17 pt16))
    ;(if (= T (>= m (/ mm 2)) (>= n (/ nn 2))) (setq pt17 pt13))
    ;(if (= T (>= m (/ mm 2)) (<= n (/ nn 2))) (setq pt17 pt14))
    (setq pt17 pt10)
    (command "layer" "S" "å¡åº¦åˆ†æž" "on" "å¡åº¦åˆ†æž" "")
    (command "layer" "on" "邊界" "on" "方格" "")
    (command "boundary" pt17 "")
    (command "area" "o" "l")
    (setq ans_area (getvar "area"))
    (setq areaamount (strcat (rtos ans_area 2 2) "㎡"))
    (command "text" "j" "mc" pt9 (* fontheight 0.8) oriangledegree areaamount)
    ;(command "text" "j" "mc" pt10 fontheight oriangledegree slopegrade)

    ;(command "text" "j" "c" pt11 fontheight oriangledegree slopeaverage)
    (setq char (+ m 65))
    (if (> char 91) (setq char2 (- char 26)) (setq char2 0))
    (if (< char2 91) (setq row (strcat "A" (chr char2) (itoa n) "(" (itoa VALUEINT) ")")))
    (if (< char 91) (setq row (strcat (chr char) (itoa n) "(" (itoa VALUEINT) ")")))
    (command "text" "j" "mc" pt12 (* fontheight 1.2) oriangledegree row)
    (command "layer" "on" "*" "")
    ) ;progn之下括號
    ) ;(if (= INTOFBOUND nil) ()之下括號
    ;)
    ;)
     
    felixlee, Nov 22, 2004
    #1
  2. felixlee

    CAB2k Guest

    Without getting into your code, let me offer this.
    I believe the boundary command requires all of the boundary to be
    visible in the screen to work properly, so you might have to zoom
    out to get the results you want.
     
    CAB2k, Nov 22, 2004
    #2
  3. felixlee

    Douglas Barr Guest

    You can also specify and pick a new selection set instead of using the default sset
    (display). This allows the new bpoly to go outside the display area. It does work.
     
    Douglas Barr, Nov 22, 2004
    #3
  4. felixlee

    felixlee Guest

    I have zoomed out the screen. Actually, the screen status is zoom extent. The problem is, sometimes it can detect the boundary, but sometimes it cant. I still cant determine why this would happen.
    Thanks for your help anyway.:)
     
    felixlee, Nov 22, 2004
    #4
  5. felixlee

    felixlee Guest

    Dear Douglas,

    Would you please explain your solution more clearly? I cant find any document about sset in the autocad help file. Also, I can't get what you mean by "display". Could you write down the command? Thank you!
     
    felixlee, Nov 22, 2004
    #5
  6. felixlee

    Fatfreek Guest

    We have no idea how many closed polylines you have on your screen, but
    consider this:
    Zoom so that only the entity you wish to do Boundary upon fills your screen
    and that you can see its entire outline. Then perform a Regen command (if I
    recall, Zooming Extents no longer automatically Regens). Then, making sure
    Osnap is turned OFF, try your Boundary command.

    Len Miller

    The problem is, sometimes it can detect the boundary, but sometimes it cant.
    I still cant determine why this would happen.
     
    Fatfreek, Nov 23, 2004
    #6
  7. felixlee

    Douglas Barr Guest

    My apologies for not being more clear. When I said 'sset', I meant the 'selection
    set' of entities that are used to define the boundary.

    By 'display', I meant the 'Current Viewport', which is the default 'boundary set'
    offered when you execute the 'Boundary' command.

    Intead of simply using the Current Viewport for your boundary set, hit the New
    button. It then asks you to select entities to define the boundary (you are creating
    a selection set). You may type 'all', selecting everything in the drawing, rather
    than simply the entities in the current viewport.

    I'm not sure this is what you're after, though. If you can't see the entities
    defining your boundary, because they're off screen, you may not get the result
    you're after. But it does offer you a way to expand the limited boundary offered by
    the entities in 'current viewport'.

    If you're automating this through lisp, and want your routine to bypass the dialog
    box, this little routine does what I described:

    (defun c:bp ()
    (setq yourpoint (getpoint))
    (command "-boundary" "A" "B" "N" "ALL" "" "" yourpoint "")
    )

    I suggest you explore the -boundary command for yourself and see if it offers what
    you're aftrer.
    -doug


    about sset in the autocad help file. Also, I can't get what you mean by "display".
    Could you write down the command? Thank you!
     
    Douglas Barr, Nov 23, 2004
    #7
  8. felixlee

    felixlee Guest

    It is weird. I have already zoomed out to see all the entity I want to boundary (command "zoom" pt1 pt6), which pt1 is the left-bottom corner and pt6 is the upper-right corner. However, when I run the command (command "boundary" "_non" pt11 ""), sometimes it wont get any boundary. If I use zoom out 4 times (command "zoom" "1/4x"), that boundary can be created. The number 1/4x is an appropriate number I use in computer after trial and error.
    Now I can get all boundary set. However, I still feel very weird why Autocad would produce different results.
    Thanks for your kind reply, Fatfreek.
     
    felixlee, Nov 24, 2004
    #8
  9. felixlee

    felixlee Guest

    Douglas, thanks for your help.
    Here my boundary would be the visible objects in the screen. So your solution wont work here. anyway, thanks. Or is there any other way that I can specify the layer in the select set?
    Also, one thing very strange here is that when I zoom in to certain status, it can detect the boundary. However, if I zoom in or zoom out, there is no boundary detected. I think mayve the current screen plays a very important role in detecting the boundary.
    Thank you for your help, Douglas.
     
    felixlee, Nov 24, 2004
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.