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

FLATSHOT Insertion Point

12 REPLIES 12
Reply
Message 1 of 13
trevor.bird.au
3964 Views, 12 Replies

FLATSHOT Insertion Point

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

12 REPLIES 12
Message 2 of 13
Anonymous
in reply to: trevor.bird.au

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. 

Message 3 of 13
trevor.bird.au
in reply to: Anonymous

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

 

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

Message 4 of 13
Anonymous
in reply to: trevor.bird.au

Perfect, it is very useful!
Message 5 of 13
marko_ribar
in reply to: Anonymous

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.

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 6 of 13
marko_ribar
in reply to: marko_ribar

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.

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

It perform good in all UCS/Views,
Message 8 of 13
marko_ribar
in reply to: Anonymous

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.

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 9 of 13
Anonymous
in reply to: marko_ribar

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

Message 10 of 13
ВeekeeCZ
in reply to: Anonymous

Maybe this.
(defun c:c0 () (command "_.copybase" "_none" "0,0,0" (princ))
(defun c:p0 () (command "_.pasteclip" "_none" "0,0,0" (princ))
Message 11 of 13
Anonymous
in reply to: ВeekeeCZ

Thank you!
Message 12 of 13
Anonymous
in reply to: Anonymous

(defun c:cc () (command "_copybase" "none" "0,0,0" )(princ))
(defun c:pp () (command "_pasteclip" "none" "0,0,0")(princ))


exactly it is
(defun c:cc () (command "_copybase" "none" "0,0,0" )(princ))
(defun c:pp () (command "_pasteclip" "none" "0,0,0")(princ))

It is always right !
Message 13 of 13
Anonymous
in reply to: marko_ribar

Can you modify this so the line weight is set to bylayer?

 

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report