Jump to content

Recommended Posts

Posted

hello,

 

I need help to select bloc by fence but i want to ignore attributes or just select blocks with base point on the fence.

 

So i've trying to add the dxf code (66.1) on this, but it doesn't work.

 

thank you for any help.

 

francoi-m

 

        (setq
         fence (listpol (ssname js (setq n (1- n))))
         js_ins (ssget "_F" fence '((0 . "INSERT")))
       )

Posted

To ignore the attributed blocks .

 

(ssget '((0 . "INSERT") (-4 . "<NOT") (66 . 1) (-4 . "NOT>")))

Posted

Sorry i explain better

 

I want select all blocks by fence ( with or without attributes) but if the fence cross just an attribute, the block are not selected.

 

Thank you for answer.

Posted

As a kludge, could turn ATTDISP to Off prior to making the selection and reset the value after the selection. It will probably require a REGEN after setting ATTDISP to OFF

(setq om (getvar "ATTMODE"))
(setq "ATTMODE" 0)
(command "_.REGEN")
(while (not ss)
      (setq ss (ssget '((0 . "INSERT"))))
(setvar" ATTMODE" om)
(command "_.REGEN")

 

Very ugly. -David

Posted

@ David

Is not this enough ?

 

(while (setq ss (ssget '((0 . "INSERT")))))

Posted
Sorry i explain better

 

I want select all blocks by fence ( with or without attributes) but if the fence cross just an attribute, the block are not selected.

 

The ssget function does not recognise the attributes in the block while selecting it , so the block object is the one that is considered in this case . ;)

Posted

I have some blocks composed by one point and two attributes on each vertex of many polyline. I wan't select all blocks who have the point on polyline by create a fence with polyline, and ignore blocks who just crossing the polyline by her attributes.

 

On my code when i use ssget function all blocks crossing the polyline was selected.

 

If you have an idea.

Posted

Maybe you should upload a sample DWG.

Posted

Try david's suggestion by turning off the attributes (attmode = 0) while you are running the codes then reset them back ( attmode = 1).

Posted (edited)
@ David

Is not this enough ?

 

(while (setq ss (ssget '((0 . "INSERT")))))

 

Depends if you want single or multiple loop of selections

Edited by David Bethel
Posted (edited)

Hi

 

i've test to put on my lisp but i've an error if you can look

 

 

(defun c:selbloc ( / js om js_all n fence ss nb)
 (princ "\nSélectionnez les polylignes: ")
 (setq js (ssget '((0 . "LWPOLYLINE"))) js_all (ssadd))
 (cond
   (js
     (repeat (setq n (sslength js))
(setq om (getvar "ATTMODE"))
        (setq "ATTMODE" 0)
         (command "_.REGEN")
   (while
     (not ss)
       (setq
         fence (listpol (ssname js (setq n (1- n))))
         ss (ssget "_F" fence '((0 . "INSERT")))
       )
     )
       (cond
         (ss
           (repeat (setq nb (sslength ss))
             (ssadd (ssname ss (setq nb (1- nb))) js_all)
           )
         )
       )
     )
     (sssetfirst nil js_all)
   )
 )
(setvar" ATTMODE" om)
(command "_.REGEN")
)

;;; listpol by Gille Chanteau ;
;;; Returns the vertices list of any type of polyline (WCS coordinates) ;
;;; ;
;;; Argument ;
;;; en, a polyline (ename or vla-object) ;

(defun listpol (en / i p l)
 (setq i
   (if (vlax-curve-IsClosed en)
     (vlax-curve-getEndParam en)
     (+ (vlax-curve-getEndParam en) 1)
   )
 )
 (while (setq p (vlax-curve-getPointAtParam en (setq i (1- i))))
   (setq l (cons (trans p 0 1 ) l))
 )
)

Edited by francois-m
Posted

Try this ...

 

(defun c:Test (/ *error* om ss i sad s n)
 ;;    Tharwat 23.05.2014        ;;
 (defun *error* (msg)
   (if om
     (setvar "ATTMODE" om)
   )
   (command "_.REGEN")
   (if (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")
     (princ msg)
     (princ (strcat "Error : < ** " msg " ** >"))
   )
 )
;;; listpol by Gille Chanteau ;
;;; Returns the vertices list of any type of polyline (WCS coordinates) ;
;;; Argument ;
;;; en, a polyline (ename or vla-object) ;
 (defun listpol (en / i p l)
   (setq i
          (if (vlax-curve-IsClosed en)
            (vlax-curve-getEndParam en)
            (+ (vlax-curve-getEndParam en) 1)
          )
   )
   (while (setq p (vlax-curve-getPointAtParam en (setq i (1- i))))
     (setq l (cons (trans p 0 1) l))
   )
 )
 (princ "\nSélectionnez les polylignes: ")
 (if (setq ss (ssget '((0 . "LWPOLYLINE"))))
   (progn
     (setq sad (ssadd)
           om  (getvar "ATTMODE")
     )
     (setvar "ATTMODE" 0)
     (command "_.REGEN")
     (repeat (setq i (sslength ss))
       (if (setq s (ssget "_F"
                          (listpol (ssname ss (setq i (1- i))))
                          '((0 . "INSERT"))
                   )
           )
         (repeat (setq n (sslength s))
           (ssadd (ssname s (setq n (1- n))) sad)
         )
       )
     )
     (setvar "ATTMODE" om)
     (command "_.REGEN")
   )
 )
 (sssetfirst nil sad)
 (princ)
)(vl-load-com)

Posted

thanks a lot.

 

it work verry fine. just for my information why have you force to create a defun error.

 

francois-m

Posted
thanks a lot.

 

You're welcome .

 

just for my information why have you force to create a defun error.

 

 

To reset the system variable "attmode" if any error took a place while running the codes .

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...