Hello,
I am writing a routine whose code and test file is attached. The purpose of this routine is to draw line segments on the boundary of a set of blocks selected by the user.
I managed to work when the block is at 0 ° rotation. But I am not able to run when the block is different from 0 ° rotation. The outline is drawn off the block and in reverse orientation.
I guess I have to change something in the transformation matrix returned by the function Nentselp.
I appreciate any help!
Thanks,
Ari
Hi,
I revised the code. Now the outline is drawn on the block, but in reverse orientation, yet!
can anyone help me?
Thanks
Ari
@Anonymous wrote:Hello,
I am writing a routine whose code and test file is attached. The purpose of this routine is to draw line segments on the boundary of a set of blocks selected by the user.
I appreciate any help!
Thanks,
Ari
I tried your code on a diffrent block, Is it suppose to work on any selected blocks? I honestly have not given a good look at your code. I'm trying to understand what the routine is all about first..
Hi,
You can try my code, if you want draw points result, remove semi-colon :
;(setvar "cmdecho" 0)(foreach n lst_box (foreach el n (command "_.point" "_none" el)))
I hope that can help you, transformation matrix is hard...
(defun l-coor2l-pt (lst flag / ) (if lst (cons (list (car lst) (cadr lst) (if flag (+ (if (vlax-property-available-p ename 'Elevation) (vlax-get ename 'Elevation) 0.0) (caddr lst)) (if (vlax-property-available-p ename 'Elevation) (vlax-get ename 'Elevation) 0.0) ) ) (l-coor2l-pt (if flag (cdddr lst) (cddr lst)) flag) ) ) ) (defun transpts (apt matrix / ) (mapcar '(lambda (arg / ) (+ (apply '+ (mapcar '* (mapcar (eval (quote arg)) matrix) apt)) (cadddr ((eval arg) matrix)) ) ) '(car cadr caddr) ) ) (defun v_matr (dpt alphax alphay alphaz echx echy echz / ) (list (list (* echx (cos alphaz) (cos alphay)) (- (sin alphaz)) (sin alphay) (car dpt) ) (list (sin alphaz) (* echy (cos alphaz) (cos alphax)) (- (sin alphax)) (cadr dpt) ) (list (- (sin alphay)) (sin alphax) (* echz (cos alphax) (cos alphay)) (caddr dpt) ) (list 0.0 0.0 0.0 1.0) ) ) (vl-load-com) (defun c:get-ptdef-in-block ( / js dxf_def def_blk pt_or ename l_pr e_next lst n dxf_ent pt_ins scalex_ins scaley_ins scale_z_ins space_colomn space_raw rot_ins nb_column nb_raw transform lst_pt pt_ori lst_box lst_bbox inc lst_all) (princ "\nClick on the block to identify it: ") (while (not (setq js (ssget "_+.:e:s" '((0 . "INSERT")))))) (princ (strcat "\nChoose " (cdr (setq dxf_def (assoc 2 (entget (ssname js 0))))) " blocks for working")) (while (not (setq js (ssget (list (cons 0 "INSERT") dxf_def ))))) (setq def_blk (tblsearch "BLOCK" (cdr dxf_def)) pt_or (cdr (assoc 10 def_blk))) (setq l_pr (list 'StartPoint 'EndPoint 'Center 'InsertionPoint 'Coordinates 'FitPoints)) (setq e_next (cdr (assoc -2 def_blk)) lst '()) (while e_next (setq ename (vlax-ename->vla-object e_next)) (foreach n l_pr (if (vlax-property-available-p ename n) (setq lst (if (or (eq n 'Coordinates) (eq n 'FitPoints)) (append (if (eq (vla-get-ObjectName ename) "AcDbPolyline") (l-coor2l-pt (vlax-get ename n) nil) (if (and (eq n 'FitPoints) (zerop (vlax-get ename 'FitTolerance))) (l-coor2l-pt (vlax-get ename 'ControlPoints) T) (l-coor2l-pt (vlax-get ename n) T) ) ) lst ) (cons (vlax-get ename n) lst) ) ) ) ) (setq e_next (entnext e_next)) ) (cond (lst (repeat (setq n (sslength js)) (setq dxf_ent (entget (ssname js (setq n (1- n)))) pt_ins (trans (cdr (assoc 10 dxf_ent)) 0 1) Scalex_ins (cdr (assoc 41 dxf_ent)) Scaley_ins (cdr (assoc 42 dxf_ent)) Scalez_ins (cdr (assoc 43 dxf_ent)) space_column (cdr (assoc 44 dxf_ent)) space_raw (cdr (assoc 45 dxf_ent)) rot_ins (- (cdr (assoc 50 dxf_ent)) (atan (/ (cadr (getvar "UCSXDIR")) (car(getvar "UCSXDIR"))))) nb_column (cdr (assoc 70 dxf_ent)) nb_raw (cdr (assoc 71 dxf_ent)) transform (v_matr '(0 0 0) 0.0 0.0 0.0 Scalex_ins Scaley_ins Scalez_ins) lst_pt (mapcar '(lambda (x ) (transpts x transform)) lst) transform (v_matr '(0 0 0) 0.0 0.0 (- rot_ins) 1.0 1.0 1.0) pt_ori (transpts pt_or transform) lst_pt (mapcar '(lambda (x ) (transpts x transform)) lst_pt) transform (v_matr (mapcar '- pt_ins (mapcar '* pt_ori (list scalex_ins scaley_ins scalez_ins))) 0.0 0.0 0.0 1.0 1.0 1.0) lst_pt (mapcar '(lambda (x ) (transpts x transform)) lst_pt) lst_box (cons lst_pt lst_box) ) (cond ((and (not (zerop nb_column)) (not (zerop nb_raw))) (repeat (1- nb_column) (setq lst_box (cons (mapcar '(lambda (x) (polar x rot_ins space_column)) (car lst_box)) lst_box)) ) (setq lst_bbox lst_box inc 1) (foreach n lst_bbox (repeat (1- nb_raw) (setq lst_box (cons (mapcar '(lambda (x) (polar x (+ (* 0.5 pi) rot_ins) (* inc space_raw))) n) lst_box) inc (1+ inc)) ) (setq inc 1) ) ) ) ;(setvar "cmdecho" 0)(foreach n lst_box (foreach el n (command "_.point" "_none" el))) (setq lst_all (append lst_box lst_all) lst_box nil) ) ) ) lst_all )