Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get a block flat with the current UCS plane

6 REPLIES 6
Reply
Message 1 of 7
ChuckEdwards
885 Views, 6 Replies

Get a block flat with the current UCS plane

The scenario is, one of my doofus colleagues has got well along the way of creating a drawing where the UCS wasn't set up properly, so the UCS used to create drawings has not been flat in the same plane compared to the world UCS.

 

As a result, the blocks which have gone in have not been in the same plane as the world UCS either, i.e. they are just ever so slightly tilted relative to it, making a flatten routine a little pointless.

 

Other than manually reinserting every single block in a new, flat UCS in the same plane as the World UCS, is there a way of getting blocks to all sit down flat again?

 

 

6 REPLIES 6
Message 2 of 7
stevor
in reply to: ChuckEdwards

You could try: get all insertion points converted to WCS. set the UCS you want create new inserts at the points translated from the WCS points.
S
Message 3 of 7
ChuckEdwards
in reply to: stevor

Stevor,

 

Getting the insertion points to 0 is a piece of cake, but that will still leave the geometry of the block in a plane other than world UCS.

 

See attached for an example of the problem I'm talking about that I've just created. Block was put into the drawing in a plan not the same as world UCS, the origin however is still at 0,0,0. The right-most line is however at z=89.9.

 

Other than reinsertion, is it possible to flatten the block down to be parallel with the world UCS plane?

 

NB I've come across this too many times, rather frustrating as my colleagues will copy any old drawings and dump them into existing ones, and when you find that even building grids are non-planar and non-parallel you really end up with a problem!

 

Charles.

Message 4 of 7
marko_ribar
in reply to: ChuckEdwards

Chuck, I happen to have Lee Mac's code for reverting rotation of blocks/xrefs... Only thing is that it will revert rotations back to WCS orientation around blocks insertion points... If 3drotation were made along axises that didn't pass insertion points, you may revert rotation correctly, but blocks/xrefs will be slightly displaced from their original positions... So this routine will keep their insertion points where they are and perform revert 3d rotations around insertion points...

This is the only way to do operation correctly, as we don't know how to revert steps that were made before unknown orienatations of blocks/xrefs have happened...

I hope Lee won't be mad at me for posting his code... It's just time saver for searching other sites from where it was obtained...

 

(defun c:revertrotblocks ( / trp mxm mxv ss ang ent enx ins mat nrm )

    (vl-load-com)

    (defun trp ( m )
       (apply 'mapcar (cons 'list m))
    )
     
    (defun mxm ( m n )
       ((lambda ( a ) (mapcar '(lambda ( r ) (mxv a r)) m)) (trp n))
    )

    (defun mxv ( m v )
       (mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m)
    )

    (while (null ss)
        (prompt "\nSelect Blocks or Xrefs")
        (setq ss (ssget '((0 . "INSERT"))))
    )
    (while (> (sslength ss) 0)
        (setq ent (ssname ss 0))
        (setq enx (entget ent)
              ang (cdr (assoc 50  enx))
              nrm (cdr (assoc 210 enx))
              ins (trans (cdr (assoc 10 enx)) nrm 0)
        )
        (vla-transformby (vlax-ename->vla-object ent)
            (vlax-tmatrix
                (append
                    (mapcar '(lambda ( r v ) (append r (list v)))
                        (setq mat
                            (mxm
                                (list
                                    (list (cos ang)     (sin ang) 0.0)
                                    (list (- (sin ang)) (cos ang) 0.0)
                                   '(0.0 0.0 1.0)
                                )
                                (mapcar '(lambda ( v ) (trans v nrm 0 t))
                                   '(
                                        (1.0 0.0 0.0)
                                        (0.0 1.0 0.0)
                                        (0.0 0.0 1.0)
                                    )
                                )
                            )
                        )
                        (mapcar '- ins (mxv mat ins))
                    )
                    '((0.0 0.0 0.0 1.0))
                )
            )
        )
        (ssdel ent ss)
    )
    (princ)
)

 M.R.

 

Thanks, Lee...

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 5 of 7
ChuckEdwards
in reply to: marko_ribar

Thanks,

 

I'll give it a go when I have access to full autocad later...

 

Charles.

Message 6 of 7
Kent1Cooper
in reply to: ChuckEdwards


@ChuckEdwards wrote:

The scenario is, one of my doofus colleagues has got well along the way of creating a drawing where the UCS wasn't set up properly, so the UCS used to create drawings has not been flat in the same plane compared to the world UCS.

 

As a result, the blocks which have gone in have not been in the same plane as the world UCS either, i.e. they are just ever so slightly tilted relative to it, making a flatten routine a little pointless.

 

Other than manually reinserting every single block in a new, flat UCS in the same plane as the World UCS, is there a way of getting blocks to all sit down flat again? 


If the Blocks in question were not defined under the slightly-off UCS, but were defined in the WCS [such as typical drawings in a symbol library, or brought in from another drawing via the Design Center] and just Inserted in the slightly-off UCS, you can simply change their extrusion direction [the 210 entry].  If edata is a variable containing the entity data of a particular Block insertion:

 

(setq edata (subst '(210 0.0 0.0 1.0) (assoc 210 edata) edata))

(entmod edata)

 

You probably also need to change the insertion points to have 0 Z coordinates, but it sounds like you know how to do that.

Kent Cooper, AIA
Message 7 of 7
3wood
in reply to: ChuckEdwards

I agree with Kent, just change its extrusion to (0.0,  0.0, 1.0).

You can try attached CHZ20.vlx, use settings as below:

CHZ20.png

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost