Jump to content
jim78b

isometric block Z value not 0

Recommended Posts

jim78b
Posted (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 by jim78b

Share this post


Link to post
Share on other sites
lrm

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

 

Share this post


Link to post
Share on other sites
jim78b

So this lisp will work as i want ?

Share this post


Link to post
Share on other sites
jim78b

don't work tell me: Command: ISOBLOCK2
; error: too few arguments
Command:

Share this post


Link to post
Share on other sites
rlx

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)

Share this post


Link to post
Share on other sites
lrm

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

 

Share this post


Link to post
Share on other sites
jim78b

Ok thanks tomorrow i will test it .good night

Share this post


Link to post
Share on other sites
jim78b

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.

Share this post


Link to post
Share on other sites
lrm
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

Share this post


Link to post
Share on other sites
jim78b

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

Share this post


Link to post
Share on other sites
lrm

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

Share this post


Link to post
Share on other sites
jim78b

sorry i tried it but for the block in image the z values are different from 0. sorry

Immagine.png

Share this post


Link to post
Share on other sites
lrm

Here's a 3d block at z = 3.

image.png.cd3d0cd40f427f703f44cd43b521ac3b.png

After isoblock3

image.png.f5b6ae4989a0db693d4a6c3fb87cefd5.png

After  a fews explodes.

image.png.3f585fe1bc448a8e28ced08bdc3c64c5.png

 

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?

 

 

 

 

Share this post


Link to post
Share on other sites
jim78b
Posted (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 by jim78b

Share this post


Link to post
Share on other sites
jim78b

attach my block, you see that the lines has the z value different from 0!

new block.dwg

Share this post


Link to post
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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