Jump to content

Change boundary color without using (entlast)


Recommended Posts

Posted (edited)

 

(vl-cmdf "_.-boundary" "_a" "_i" "_n" "" "" "_non" (getpoint) "")

 

How to write ( if boundary created ) change its colour to yellow without using (entlast)

 

 

================================  Also  ================================

 

 

How to check if error using (vl-catch-all-error-p (vl-catch-all-apply For This ssget

 

(ssget "_WP" (pac Poly_Ent) (list (cons 0 "TEXT") (cons 8 "Pr_layer"))))

 

 

Check if there is a text (Layer "Pr_layer") inside the closed polyline Poly_Ent because I got error many times while running the code

bad argument type: lselsetp nil )

 

(defun pac (e / l v d lst)
        (setq lst nil)
        (setq d (- (setq v (/ (setq l (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e))) 100.))))
        (while (< (setq d (+ d v)) l)
            (setq lst (cons (vlax-curve-getPointAtDist e d) lst))
        )
)

 

Edited by Engineer_Yasser
  • Engineer_Yasser changed the title to Change boundary color without using (entlast)
Posted

what is wrong with entlast? if you don't want entlast maybe you should use a window selection (getpoint + getcorner) and after selection set & bounday (lwpoly) is created , you create a second selection set using same points from getpoint / getcorner and substract selection set 1 from selection set 2 and whatever is left should be your boundary. Lots of stuf you should be able to find on this site or with googe but why go this path when entlast is the most direct way?  unless you're a female human, like my wife ... she also defies all logic but that's probably just to irritate me haha

Posted
11 minutes ago, rlx said:

what is wrong with entlast? if you don't want entlast maybe you should use a window selection (getpoint + getcorner) and after selection set & bounday (lwpoly) is created , you create a second selection set using same points from getpoint / getcorner and substract selection set 1 from selection set 2 and whatever is left should be your boundary. Lots of stuf you should be able to find on this site or with googe but why go this path when entlast is the most direct way?  unless you're a female human, like my wife ... she also defies all logic but that's probably just to irritate me haha

 

Because when using (entlast) and the boundary not created .. the Autocad will deal with the previous entity not the boundary .. so i need to check if boundary created or not first

 

 

same like

 

(if (ssget)

       .................

 

if you made selection the ( if ) will continue

Posted (edited)

it's not very pretty (unlike me haha) but maybe this could work for you

 

(defun c:t1 ( / pt cmd fn oqa ocm fp i s)
  (setq fn (getvar 'logfilename))
  (if (findfile fn) (vl-file-delete fn))
  (setq s "" pt (getpoint "\nSelect internal point for boundary : "))
  (setq cmd (list "logfileon" "_.-boundary" "_a" "_i" "_n" "" "" "_non" pt "" "_redraw" "logfileoff"))
  (setq  oqa (getvar 'qaflags) ocm (getvar 'cmdecho)) (setvar 'qaflags 2)(setvar 'cmdecho 1)
  (vl-catch-all-apply 'vl-cmdf cmd)
  (gc)(gc)
  (if (setq fp (open fn "r"))
    (while (setq i (read-line fp))
      (setq s (strcat s i))
    )
  )
  (if fp (close fp))
  (if (and s (wcmatch (strcase s t) "*boundary created*"))
    (progn
      (alert "boundary created")
      ;;; chprop + entlast bladiebla
    )
    (alert "computer says no")
  )
  (setvar 'qaflags oqa)(setvar 'cmdecho ocm)
  (princ)
)

 

 

 

Edited by rlx
  • Like 1
Posted
9 hours ago, rlx said:

it's not very pretty (unlike me haha) but maybe this could work for you

 

(defun c:t1 ( / pt cmd fn oqa ocm fp i s)
  (setq fn (getvar 'logfilename))
  (if (findfile fn) (vl-file-delete fn))
  (setq s "" pt (getpoint "\nSelect internal point for boundary : "))
  (setq cmd (list "logfileon" "_.-boundary" "_a" "_i" "_n" "" "" "_non" pt "" "_redraw" "logfileoff"))
  (setq  oqa (getvar 'qaflags) ocm (getvar 'cmdecho)) (setvar 'qaflags 2)(setvar 'cmdecho 1)
  (vl-catch-all-apply 'vl-cmdf cmd)
  (gc)(gc)
  (if (setq fp (open fn "r"))
    (while (setq i (read-line fp))
      (setq s (strcat s i))
    )
  )
  (if fp (close fp))
  (if (and s (wcmatch (strcase s t) "*boundary created*"))
    (progn
      (alert "boundary created")
      ;;; chprop + entlast bladiebla
    )
    (alert "computer says no")
  )
  (setvar 'qaflags oqa)(setvar 'cmdecho ocm)
  (princ)
)

 

 

 

 

 

Nice Work ✅ .. Thanks for help 🌹

Posted

@rlx

 

How to check if error using (vl-catch-all-error-p (vl-catch-all-apply For This 👇

 

(ssget "_WP" (pac Poly_Ent) (list (cons 0 "TEXT") (cons 8 "Pr_layer"))))

 

 

Check if there is a text (Layer "Pr_layer") inside the closed polyline Poly_Ent because I got error many times while running the code

( bad argument type: lselsetp nil )

Posted

totaly untested...

 

(cond
  ((not (tblsearch "layer" "Pr_layer"))
   (princ "\nLayer 'Pr_layer' not present"))
  ((vl-catch-all-error-p (setq result (vl-catch-all-apply 'ssget (list "_WP" (pac Poly_Ent) (list (cons 0 "TEXT") (cons 8 "Pr_layer"))))))
   (alert (strcat "Computer says no :\n" (vl-catch-all-error-message result))))
  (t (princ "\nNo errors detected"))
)

 

Posted
27 minutes ago, rlx said:

totaly untested...

 

(cond
  ((not (tblsearch "layer" "Pr_layer"))
   (princ "\nLayer 'Pr_layer' not present"))
  ((vl-catch-all-error-p (setq result (vl-catch-all-apply 'ssget (list "_WP" (pac Poly_Ent) (list (cons 0 "TEXT") (cons 8 "Pr_layer"))))))
   (alert (strcat "Computer says no :\n" (vl-catch-all-error-message result))))
  (t (princ "\nNo errors detected"))
)

 

 

Not success ... all I want to (ssget  (list (cons 0 "TEXT") (cons 8 "Pr_layer"))) inside selected closed polyline and if (> sslength 1) delete the selected closed polyline .. in case of error skip and continue

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...