francois-m Posted May 22, 2014 Posted May 22, 2014 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"))) ) Quote
Tharwat Posted May 22, 2014 Posted May 22, 2014 To ignore the attributed blocks . (ssget '((0 . "INSERT") (-4 . "<NOT") (66 . 1) (-4 . "NOT>"))) Quote
francois-m Posted May 22, 2014 Author Posted May 22, 2014 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. Quote
David Bethel Posted May 22, 2014 Posted May 22, 2014 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 Quote
Tharwat Posted May 22, 2014 Posted May 22, 2014 @ David Is not this enough ? (while (setq ss (ssget '((0 . "INSERT"))))) Quote
Tharwat Posted May 22, 2014 Posted May 22, 2014 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 . Quote
francois-m Posted May 22, 2014 Author Posted May 22, 2014 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. Quote
francois-m Posted May 22, 2014 Author Posted May 22, 2014 Maybe it's more explicite with a sample. francois-m sample.dwg Quote
Tharwat Posted May 22, 2014 Posted May 22, 2014 Try david's suggestion by turning off the attributes (attmode = 0) while you are running the codes then reset them back ( attmode = 1). Quote
David Bethel Posted May 22, 2014 Posted May 22, 2014 (edited) @ David Is not this enough ? (while (setq ss (ssget '((0 . "INSERT"))))) Depends if you want single or multiple loop of selections Edited May 22, 2014 by David Bethel Quote
francois-m Posted May 22, 2014 Author Posted May 22, 2014 (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 May 22, 2014 by francois-m Quote
Tharwat Posted May 23, 2014 Posted May 23, 2014 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) Quote
francois-m Posted May 23, 2014 Author Posted May 23, 2014 thanks a lot. it work verry fine. just for my information why have you force to create a defun error. francois-m Quote
Tharwat Posted May 23, 2014 Posted May 23, 2014 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 . Quote
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.