jim78b Posted October 3, 2019 Share Posted October 3, 2019 (edited) every time I use this routine it puts the lines with the values of the z axes different from 0. could not be done so that they are all on z, arcs circles polylines? and another problem... i see all the lines are not correct as length...i suppose must scale them...0.81649..is possible by lisp? ;;----------------------------------------------------------------------- ;; ;; Command Name - IsoBlock ;; Routine For Transforming a Block to Isometric ;; By WizMan_07Feb10 ;; ;; Version 1.0 - 11May09 ;; Version 1.1 - 06Feb10 - Added Reverse Option and Flatten(Express) ;; Version 1.2 - 07Feb10 - Fixed DText Rotation inside block(by SEANT) ;; ;; ;;----------------------------------------------------------------------- ;; ;; (defun c:isoblock (/ blok_ent counter ent_data ent_pt i sub_func *error* blk_name midtbox midtxt reverseflag rot tbox ) ;; ;;-------------------------------------------------------------------- ;; (defun to_southwest (ent_name base_pt / obj) (vla-TransformBy (setq obj (vlax-ename->vla-object ent_name)) (vlax-tmatrix (list (list (/ (sqrt 2.) 2.) (- (/ (sqrt 2.) 2.)) 0. 0.) (list (/ (sqrt (/ 2. 3.)) 2.) (/ (sqrt (/ 2. 3.)) 2.) (sqrt (/ 2. 3.)) 0. ) (list (- (/ (sqrt 3.) 3.)) (- (/ (sqrt 3.) 3.)) (/ (sqrt 3.) 3.) 0. ) (list 0. 0. 0. 1.) ) ) ) (vla-move obj (vlax-3d-point (trans (cdr (assoc 10 (entget ent_name))) ent_name 0) ) (vlax-3d-point base_pt) ) ) ;; ;;-------------------------------------------------------------------- ;; (defun to_southeast (ent_name base_pt / obj) (vla-TransformBy (setq obj (vlax-ename->vla-object ent_name)) (vlax-tmatrix (list (list (/ (sqrt 2.) 2.) (/ (sqrt 2.) 2.) 0. 0.) (list (- (/ (sqrt (/ 2. 3.)) 2.)) (/ (sqrt (/ 2. 3.)) 2.) (sqrt (/ 2. 3.)) 0. ) (list (/ (sqrt 3.) 3.) (- (/ (sqrt 3.) 3.)) (/ (sqrt 3.) 3.) 0. ) (list 0. 0. 0. 1.) ) ) ) (vla-move obj (vlax-3d-point (trans (cdr (assoc 10 (entget ent_name))) ent_name 0) ) (vlax-3d-point base_pt) ) ) ;; ;;-------------------------------------------------------------------- ;; (defun to_front (ent_name base_pt / obj) (vla-TransformBy (setq obj (vlax-ename->vla-object ent_name)) (vlax-tmatrix (list (list 1. 0. 0. 0.) (list 0. 0. 1. 0.) (list 0. 1. 0. 0.) ;mirrored (list 0. 0. 0. 1.) ) ) ) (vla-move obj (vlax-3d-point (trans (cdr (assoc 10 (entget ent_name))) ent_name 0) ) (vlax-3d-point base_pt) ) ) ;; ;;-------------------------------------------------------------------- ;; (defun to_front_southwest (ent_name base_pt / obj) (to_front ent_name base_pt) (to_southwest ent_name base_pt) ) ;; ;;-------------------------------------------------------------------- ;; (defun to_front_southeast (ent_name base_pt / obj) (to_front ent_name base_pt) (to_southeast ent_name base_pt) ) ;; ;;-------------------------------------------------------------------- ;; (defun dtr (var) (* PI (/ var 180.0)) ) ;; ;;-------------------------------------------------------------------- ;; (defun fix_txt (blk oblang / ins) (vlax-for obj (vla-item (vla-get-Blocks doc) (cdr (assoc 2 (entget blk)))) (if (eq "AcDbText" (vla-get-Objectname obj)) (progn (Setq ins (vlax-get obj 'insertionpoint)) (vla-put-upsidedown obj 0) (vla-put-ObliqueAngle obj (dtr oblang)) (vlax-put obj 'insertionpoint ins) (vla-update (vlax-ename->vla-object (entlast))) ) ) ) ) ;; ;;-------------------------------------------------------------------- ;; (defun *error* (msg) (if blok_ent (progn (load "flattensup.lsp") (acet-flatn (ssadd blok_ent (ssadd)) nil) (cond ((= sub_func (quote to_front_southwest)) (fix_txt (entlast) 30) ) ((= sub_func (quote to_front_southeast)) (fix_txt (entlast) 330) ) (t nil) ) (if reverseflag (vlax-for obj (vla-item (vla-get-Blocks doc) blk_name) (if (eq "AcDbText" (vla-get-Objectname obj)) (vla-rotate obj (vlax-3d-point midtxt) pi) ) ) ) (setq reverseflag nil) ) ) (and doc (vla-endundomark doc)) (setvar 'cmdecho 1) ) ;; ;;-------------------------------------------------------------------- ;; (setq doc (vla-get-activedocument (vlax-get-acad-object) ) ) (vla-EndUndoMark doc) (vla-StartUndoMark doc) (setvar 'cmdecho 0) ;; ;;-------------------------------------------------------------------- ;; (if (setq blok_ent (car (entsel "\n>>>...Pick a block...>>>: "))) (progn (setq ent_data (entget blok_ent)) (setq ent_pt (cdr (assoc 10 ent_data))) (COMMAND "SCALE" blok_ent "" ent_pt "1.22474487") (setq ent_data (entget blok_ent)) (setq ent_pt (cdr (assoc 10 ent_data))) (setq blk_name (cdr (assoc 2 ent_data))) (to_southwest blok_ent ent_pt) (setq counter 1) (while (or (= (setq i (strcase (getstring "\rPress [SpaceBar] to Toggle View, [R]everse or Press any Letter to exit: " ) ) ) "" ) (= i "R") ) (if (/= i "R") (progn (if blok_ent (vla-delete (vlax-ename->vla-object blok_ent)) ) (setq sub_func (nth counter '(to_southwest to_southeast to_front_southwest to_front_southeast ) ) ) (entmake ent_data) (setq blok_ent (entlast)) (if reverseflag (vlax-for obj (vla-item (vla-get-Blocks doc) (cdr (assoc 2 (entget blok_ent))) ) (if (eq "AcDbText" (vla-get-Objectname obj)) (progn (vla-rotate obj (vlax-3d-point midtxt) pi) (vla-update (vlax-ename->vla-object blok_ent)) ) ) ) ) ((eval sub_func) blok_ent ent_pt) (if (< counter 3) (setq counter (1+ counter)) (setq counter 0) ) (setq reverseflag nil) ) (if (not reverseflag) (progn (setq reverseflag t) (setq rot (vla-get-rotation (vlax-ename->vla-object blok_ent))) (vla-put-rotation (vlax-ename->vla-object blok_ent) (+ rot pi) ) (vlax-for obj (vla-item (vla-get-Blocks doc) (cdr (assoc 2 (entget blok_ent)))) (if (eq "AcDbText" (vla-get-Objectname obj)) (progn (setq ins (vlax-get obj 'insertionpoint)) (setq tbox (textbox (entget (vlax-vla-object->ename obj)))) (setq midtbox (mapcar '/ (mapcar '+ (car tbox) (cadr tbox)) '(2. 2. 2.) ) ) (setq midtxt (mapcar '+ ins midtbox)) (vla-rotate obj (vlax-3d-point midtxt) pi) (vla-update (vlax-ename->vla-object blok_ent)) ) ) ) ) ) ) ) ) ) (*error* "") (princ) ) (vl-load-com) ;; ;;-------------------------------------------------------------------- ;; (prompt "\n>>>...IsoBlock.lsp is now loaded. Type 'IsoBlock' to start ...<<<" ) ;_ prompt (princ) ;;-------------------------------------------------------------------- ;; ;; ;;WIZ_07FEB10 Edited October 3, 2019 by jim78b Quote Link to comment Share on other sites More sharing options...
lrm Posted October 3, 2019 Share Posted October 3, 2019 That seems like a lot of code to do a 3d rotation and scale. The error checking adds to the code length. When I used it there was no flattening of the result. Here's a QAD program to do the rotations and scale by using the rotate3d command. There are several possible isometric orientations. I choose the one that was done with isoblock.The block is moved to z = 0 as the OP requested. No error checking is done. (defun C:isoblock2 (/blok_ent ent_data ent_pt dz) ; rotates a block to an isometric orientation for the top view ; and scales it up to create an ismoteric drawing from the projection. ; the block's z position is then moved to z = 0.0 ; lrm 10/3/2019 (setq blok_ent (car (entsel "\n>>>...Pick a block...>>>: "))) (setq ent_data (entget blok_ent)) (setq ent_pt (cdr (assoc 10 ent_data))) (setq dz (* -1 (nth 2 ent_pt))) (command "rotate3d" blok_ent "" "z" ent_pt 45 "") (command "rotate3d" blok_ent "" "x" ent_pt "-54.7356103172" "") (command "SCALE" blok_ent "" ent_pt "1.22474487") (command "_.move" blok_ent "" "_non" '(0. 0. 0.) "_non" (list 0. 0. dz)) (princ) ) Quote Link to comment Share on other sites More sharing options...
jim78b Posted October 3, 2019 Author Share Posted October 3, 2019 So this lisp will work as i want ? Quote Link to comment Share on other sites More sharing options...
jim78b Posted October 3, 2019 Author Share Posted October 3, 2019 don't work tell me: Command: ISOBLOCK2 ; error: too few arguments Command: Quote Link to comment Share on other sites More sharing options...
rlx Posted October 3, 2019 Share Posted October 3, 2019 haven't tried the code itself but probably make sure there's a space between / and the variables ( / blok_ent ent_data ent_pt dz) Quote Link to comment Share on other sites More sharing options...
lrm Posted October 3, 2019 Share Posted October 3, 2019 Rule #1: do not make a last minute edit to code and then not test it. Here's a working version (I hope). Yes, there should be a space between / and blok_ent in line 1. (defun C:isoblock2 (/ blok_ent ent_data ent_pt dz) ; rotates a block to an isometric orientation for the top view ; and scales it up to create an isometric drawing from the projection. ; the block's z position is then moved to z = 0.0 ; lrm 10/3/2019 (setq blok_ent (car (entsel "\n>>>...Pick a block...>>>: "))) (setq ent_data (entget blok_ent)) (setq ent_pt (cdr (assoc 10 ent_data))) (setq dz (* -1 (nth 2 ent_pt))) (command "rotate3d" blok_ent "" "z" ent_pt 45 "") (command "rotate3d" blok_ent "" "x" ent_pt "-54.7356103172" "") (command "SCALE" blok_ent "" ent_pt "1.22474487") (command "_.move" blok_ent "" "_non" '(0. 0. 0.) "_non" (list 0. 0. dz)) (princ) ) Quote Link to comment Share on other sites More sharing options...
jim78b Posted October 3, 2019 Author Share Posted October 3, 2019 Ok thanks tomorrow i will test it .good night Quote Link to comment Share on other sites More sharing options...
jim78b Posted October 4, 2019 Author Share Posted October 4, 2019 sorry don't work. in the original listing i once had the chance to have an isometric view, every time I pressed a key I had a different view. Quote Link to comment Share on other sites More sharing options...
lrm Posted October 4, 2019 Share Posted October 4, 2019 11 hours ago, jim78b said: sorry don't work. in the original listing i once had the chance to have an isometric view, every time I pressed a key I had a different view. It's not clear what "don't work" means. DId you get an error message? I ran the program isoblock2, selected a 3D block that was parallel to the world XY plane and it rotated it to an isometric orientation, scaled it, and the move it to z = 0. Did you want something more than this? If so, please be specific. isoblock2.LSP Quote Link to comment Share on other sites More sharing options...
jim78b Posted October 4, 2019 Author Share Posted October 4, 2019 Yes like my original lisp . It was perfect only i want that all the z values are 0 .try my lisp you see that every time you presso a key it give you a different view .your not Quote Link to comment Share on other sites More sharing options...
lrm Posted October 4, 2019 Share Posted October 4, 2019 I modified the original program to move the shape to z = 0. This should do what you want. See the line: (command "_.move" blok_ent "" "_non" '(0. 0. 0.) "_non" (list 0. 0. (* -1 (nth 2 ent_pt)))) ;; Version 1.0 - 11May09 ;; Version 1.1 - 06Feb10 - Added Reverse Option and Flatten(Express) ;; Version 1.2 - 07Feb10 - Fixed DText Rotation inside block(by SEANT) ;; Version 1.3 - 04Oct19 - Move flattened shape to z = 0 (by LRM) ;; ;; ;;----------------------------------------------------------------------- ;; ;; (defun c:isoblock3 (/ blok_ent counter ent_data ent_pt i sub_func *error* blk_name midtbox midtxt reverseflag rot tbox ) ;; ;;-------------------------------------------------------------------- ;; (defun to_southwest (ent_name base_pt / obj) (vla-TransformBy (setq obj (vlax-ename->vla-object ent_name)) (vlax-tmatrix (list (list (/ (sqrt 2.) 2.) (- (/ (sqrt 2.) 2.)) 0. 0.) (list (/ (sqrt (/ 2. 3.)) 2.) (/ (sqrt (/ 2. 3.)) 2.) (sqrt (/ 2. 3.)) 0. ) (list (- (/ (sqrt 3.) 3.)) (- (/ (sqrt 3.) 3.)) (/ (sqrt 3.) 3.) 0. ) (list 0. 0. 0. 1.) ) ) ) (vla-move obj (vlax-3d-point (trans (cdr (assoc 10 (entget ent_name))) ent_name 0) ) (vlax-3d-point base_pt) ) ) ;; ;;-------------------------------------------------------------------- ;; (defun to_southeast (ent_name base_pt / obj) (vla-TransformBy (setq obj (vlax-ename->vla-object ent_name)) (vlax-tmatrix (list (list (/ (sqrt 2.) 2.) (/ (sqrt 2.) 2.) 0. 0.) (list (- (/ (sqrt (/ 2. 3.)) 2.)) (/ (sqrt (/ 2. 3.)) 2.) (sqrt (/ 2. 3.)) 0. ) (list (/ (sqrt 3.) 3.) (- (/ (sqrt 3.) 3.)) (/ (sqrt 3.) 3.) 0. ) (list 0. 0. 0. 1.) ) ) ) (vla-move obj (vlax-3d-point (trans (cdr (assoc 10 (entget ent_name))) ent_name 0) ) (vlax-3d-point base_pt) ) ) ;; ;;-------------------------------------------------------------------- ;; (defun to_front (ent_name base_pt / obj) (vla-TransformBy (setq obj (vlax-ename->vla-object ent_name)) (vlax-tmatrix (list (list 1. 0. 0. 0.) (list 0. 0. 1. 0.) (list 0. 1. 0. 0.) ;mirrored (list 0. 0. 0. 1.) ) ) ) (vla-move obj (vlax-3d-point (trans (cdr (assoc 10 (entget ent_name))) ent_name 0) ) (vlax-3d-point base_pt) ) ) ;; ;;-------------------------------------------------------------------- ;; (defun to_front_southwest (ent_name base_pt / obj) (to_front ent_name base_pt) (to_southwest ent_name base_pt) ) ;; ;;-------------------------------------------------------------------- ;; (defun to_front_southeast (ent_name base_pt / obj) (to_front ent_name base_pt) (to_southeast ent_name base_pt) ) ;; ;;-------------------------------------------------------------------- ;; (defun dtr (var) (* PI (/ var 180.0)) ) ;; ;;-------------------------------------------------------------------- ;; (defun fix_txt (blk oblang / ins) (vlax-for obj (vla-item (vla-get-Blocks doc) (cdr (assoc 2 (entget blk)))) (if (eq "AcDbText" (vla-get-Objectname obj)) (progn (Setq ins (vlax-get obj 'insertionpoint)) (vla-put-upsidedown obj 0) (vla-put-ObliqueAngle obj (dtr oblang)) (vlax-put obj 'insertionpoint ins) (vla-update (vlax-ename->vla-object (entlast))) ) ) ) ) ;; ;;-------------------------------------------------------------------- ;; (defun *error* (msg) (if blok_ent (progn (load "flattensup.lsp") (acet-flatn (ssadd blok_ent (ssadd)) nil) (cond ((= sub_func (quote to_front_southwest)) (fix_txt (entlast) 30) ) ((= sub_func (quote to_front_southeast)) (fix_txt (entlast) 330) ) (t nil) ) (if reverseflag (vlax-for obj (vla-item (vla-get-Blocks doc) blk_name) (if (eq "AcDbText" (vla-get-Objectname obj)) (vla-rotate obj (vlax-3d-point midtxt) pi) ) ) ) (setq reverseflag nil) ) ) (and doc (vla-endundomark doc)) (setvar 'cmdecho 1) ) ;; ;;-------------------------------------------------------------------- ;; (setq doc (vla-get-activedocument (vlax-get-acad-object) ) ) (vla-EndUndoMark doc) (vla-StartUndoMark doc) (setvar 'cmdecho 0) ;; ;;-------------------------------------------------------------------- ;; (if (setq blok_ent (car (entsel "\n>>>...Pick a block...>>>: "))) (progn (setq ent_data (entget blok_ent)) (setq ent_pt (cdr (assoc 10 ent_data))) ;; move to z = 0 plane (command "_.move" blok_ent "" "_non" '(0. 0. 0.) "_non" (list 0. 0. (* -1 (nth 2 ent_pt)))) (COMMAND "SCALE" blok_ent "" ent_pt "1.22474487") (setq ent_data (entget blok_ent)) (setq ent_pt (cdr (assoc 10 ent_data))) (setq blk_name (cdr (assoc 2 ent_data))) (to_southwest blok_ent ent_pt) (setq counter 1) (while (or (= (setq i (strcase (getstring "\rPress [SpaceBar] to Toggle View, [R]everse or Press any Letter to exit: " ) ) ) "" ) (= i "R") ) (if (/= i "R") (progn (if blok_ent (vla-delete (vlax-ename->vla-object blok_ent)) ) (setq sub_func (nth counter '(to_southwest to_southeast to_front_southwest to_front_southeast ) ) ) (entmake ent_data) (setq blok_ent (entlast)) (if reverseflag (vlax-for obj (vla-item (vla-get-Blocks doc) (cdr (assoc 2 (entget blok_ent))) ) (if (eq "AcDbText" (vla-get-Objectname obj)) (progn (vla-rotate obj (vlax-3d-point midtxt) pi) (vla-update (vlax-ename->vla-object blok_ent)) ) ) ) ) ((eval sub_func) blok_ent ent_pt) (if (< counter 3) (setq counter (1+ counter)) (setq counter 0) ) (setq reverseflag nil) ) (if (not reverseflag) (progn (setq reverseflag t) (setq rot (vla-get-rotation (vlax-ename->vla-object blok_ent))) (vla-put-rotation (vlax-ename->vla-object blok_ent) (+ rot pi) ) (vlax-for obj (vla-item (vla-get-Blocks doc) (cdr (assoc 2 (entget blok_ent)))) (if (eq "AcDbText" (vla-get-Objectname obj)) (progn (setq ins (vlax-get obj 'insertionpoint)) (setq tbox (textbox (entget (vlax-vla-object->ename obj)))) (setq midtbox (mapcar '/ (mapcar '+ (car tbox) (cadr tbox)) '(2. 2. 2.) ) ) (setq midtxt (mapcar '+ ins midtbox)) (vla-rotate obj (vlax-3d-point midtxt) pi) (vla-update (vlax-ename->vla-object blok_ent)) ) ) ) ) ) ) ) ) ) (*error* "") (princ) ) (vl-load-com) ;; ;;-------------------------------------------------------------------- ;; (prompt "\n>>>...IsoBlock.lsp is now loaded. Type 'IsoBlock' to start ...<<<" ) ;_ prompt (princ) ;;-------------------------------------------------------------------- ;; ;; ;;WIZ_07FEB1 isoblock3.lsp Quote Link to comment Share on other sites More sharing options...
jim78b Posted October 4, 2019 Author Share Posted October 4, 2019 sorry i tried it but for the block in image the z values are different from 0. sorry Quote Link to comment Share on other sites More sharing options...
lrm Posted October 4, 2019 Share Posted October 4, 2019 Here's a 3d block at z = 3. After isoblock3 After a fews explodes. I went back and experimented with the original version of isoblock you posted. For the simple shape I used here the properties indicate that the block is at z = 3 but the geometry was flattened to the z = 0 plane. That is, although the block's reference point was not at z = 0 the geometry was. I don't know why you are getting the result you are getting. Was the WCS active when you gave the isoblock3 command? Can you post the file of the block? Quote Link to comment Share on other sites More sharing options...
jim78b Posted October 5, 2019 Author Share Posted October 5, 2019 (edited) Tomorrow or this evenong i will post thanks I don't use a 3d blocchi but a 2d block I use global ucs Edited October 5, 2019 by jim78b Quote Link to comment Share on other sites More sharing options...
jim78b Posted October 6, 2019 Author Share Posted October 6, 2019 attach my block, you see that the lines has the z value different from 0! new block.dwg Quote Link to comment Share on other sites More sharing options...
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.