Hi All,
The insertion point of the block created by FLATSHOT seems to be the VIEWCTR (system variable) of
the current view.
But sometimes the insertion point of the FLATSHOT block seems to be random.
I believe that the TARGET system variable is offsetting the VIEWCTR insertion point calculated by
AutoCAD for the FLATSHOT block definition by the X,Y and Z components of the current value of
TARGET.
I've attached a small program for calculating the insertion point of the FLATSHOT block to insert it in the correct location.
It calculates the UCS insertion point from the current values of system variables UCSORG, VIEWCTR
and. TARGET.
I hope my logic is correct and it works for others.
Regards,
Trevor
Thank you for your autolisp, but there is a problem with z insertion point. When i make Flatshot command with your lisp,( XY view), it is not alway insert z 0.
Hi minhtq,
Thank you for the Kudo and your feedback.
I'm glad I got the X and Y values correct, they were the original unknown for the insertion point of the FLATSHOT block .
I've attached an updated copy of this program to fix the insertion point of the FLATSHOT block so that it now inserts correctly with a Z of 0.
I modified the code to change the Z value of TARGET (stored as a UCS coordinate for the current viewport) to be 0.
The X and Y values are the important values of TARGET for calculating the correct insertion point of the FLATSHOT block in the current viewport.
I've renamed the file so it can be attached to this post, just rename it back to .lsp
Thanks again.
Regards,
Trevor
I think that the code is bad... Please, test my version... I did test only a few times, but I think it should perform good in all UCS/Views...
;; FLATSHOTIP.lsp by Marko Ribar (defun c:flatshotip ( / ent entd ang targ vctr r v va an x xo ) (command "_.FLATSHOT" '(0.0 0.0 0.0) "" "" "") (setq ent (entlast)) (setq entd (entget ent)) (setq ang (cdr (assoc 50 entd))) (setq targ (append (mapcar '+ (getvar 'target) '(0.0 0.0)) (list 0.0))) (setq vctr (getvar 'viewctr)) (setq r (distance targ vctr)) (setq v (mapcar '- vctr targ)) (setq va (angle '(0.0 0.0) v)) (setq an (- va ang)) (setq x (polar '(0.0 0.0) an r)) (setq xo (trans x 1 ent)) (setq entd (entget ent)) (setq entd (subst (cons 50 0.0) (assoc 50 entd) entd)) (setq entd (subst (cons 10 xo) (assoc 10 entd) entd)) (entupd (cdr (assoc -1 (entmod entd)))) (princ) );c:flatshotip
Regards, M.R.
HTH.
Here is my newest version - included and perspective views... Only lack that projection plane is "UCS" "View"... But it has to be that way, if your current UCS doesn't match View that may be from everywhere...
;; FLATSHOTIP.lsp by Marko Ribar (defun c:flatshotip ( / ucstmatrix ent obj entd ang targ vctr r v va an x xo )
(vl-load-com) (defun ucstmatrix ( p ) (append (apply 'mapcar (cons 'list (append (list (trans '(1.0 0.0 0.0) 1 0 t) (trans '(0.0 1.0 0.0) 1 0 t) (trans '(0.0 0.0 1.0) 1 0 t) ) (list p) ) ) ) (list '(0.0 0.0 0.0 1.0)) ) ) (if (eq (getvar 'perspective) 1) (progn (command "_.UCS" "_V") (command "_.UCS" "_W") (command "_.FLATSHOT" '(0.0 0.0 0.0) "" "" "") (setq ent (entlast)) (setq obj (vlax-ename->vla-object ent)) (command "_.UCS" "_P") (vla-transformby obj (vlax-tmatrix (ucstmatrix '(0.0 0.0 0.0)))) (setq entd (entget ent)) (setq entd (subst (cons 10 (trans (getvar 'target) 1 ent)) (assoc 10 entd) entd)) (entupd (cdr (assoc -1 (entmod entd)))) (command "_.UCS" "_P") ) (progn (command "_.UCS" "_V") (command "_.FLATSHOT" '(0.0 0.0 0.0) "" "" "") (setq ent (entlast)) (setq entd (entget ent)) (setq ang (cdr (assoc 50 entd))) (setq targ (append (mapcar '+ (getvar 'target) '(0.0 0.0)) (list 0.0))) (setq vctr (getvar 'viewctr)) (setq r (distance targ vctr)) (setq v (mapcar '- vctr targ)) (setq va (angle '(0.0 0.0) v)) (setq an (- va ang)) (setq x (polar '(0.0 0.0) an r)) (setq xo (trans x 1 ent)) (setq entd (entget ent)) (setq entd (subst (cons 50 0.0) (assoc 50 entd) entd)) (setq entd (subst (cons 10 xo) (assoc 10 entd) entd)) (entupd (cdr (assoc -1 (entmod entd)))) (command "_.UCS" "_P") ) ) (princ) );c:flatshotip
HTH, M.R.
minhtq, thanks for kudo... Hope you'll find it useful in your ACAD usage...
Regards, enjoy... It took me a while to figure out this task, it was very interesting...
Thanks again, M.R.
I have a similar problem with my “ copy base lips”. It help me copy objects from a drawing to another with same position X, Y, z
But It does not always work. When the the drawing have line with Center linetype it is wrong.
Please help me, Thank a lot.
This is my lips
(defun c:c0 () (command "copybase" "0,0,0")(princ))
(defun c:p0 () (command "pasteclip" "0,0,0")(princ))
Can't find what you're looking for? Ask the community or share your knowledge.