Hello Everyone
I created a dynamic block (light pole) which have a stretch parameter for height adjustments. This can only be done with the pole laying down, so everytime the block is inserted it always needs to be 3d rotated. I found a routine that Lee Mac wrote which works really well. I just need it to include the "insert" part. Please help!
Here's the insert part:
-INSERT "C:\\pole01.dwg" s r
Here's the lisp from Lee
(defun c:bx90r ( / a e i p q r s x ) (setq a (/ pi 2.0)) (if (setq s (ssget "_:L" '((0 . "INSERT")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) x (entget e) p (trans (cdr (assoc 10 x)) e 0) r (cdr (assoc 50 x)) q (trans (mapcar '+ (cdr (assoc 10 x)) (list (cos r) (sin r) 0.0)) e 0) ) (vlax-invoke (vlax-ename->vla-object e) 'rotate3d p q a) ) ) (princ) ) (vl-load-com) (princ)
Thanks in advance!
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Solved by JCprog. Go to Solution.
Or....
(command ".-insert" "C:\\pole01.dwg" pause "")
Without scale and rotate try...
(command ".-insert" "C:\\pole01.dwg" pause "" "" "")
(command ".-insert" "C:\\pole01.dwg" pause 1 "" pause)
EDIT:
"I created a dynamic block (light pole) which have a stretch parameter for height adjustments. This can only be done with the pole laying down, so everytime the block is inserted it always needs to be 3d rotated"
Could you attach your block?
HTH
Henrique
This works in the exception of picking the inserterd block again. After picking the insertion point it should finish up with x rotation rather than picking the block again.
(defun c:bx90r ( / a e i p q r s x ) (command ".-insert" "C:\\pole01.dwg" pause 1 "" pause) (setq a (/ pi 2.0)) (if (setq s (ssget "_:L" '((0 . "INSERT")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) x (entget e) p (trans (cdr (assoc 10 x)) e 0) r (cdr (assoc 50 x)) q (trans (mapcar '+ (cdr (assoc 10 x)) (list (cos r) (sin r) 0.0)) e 0) ) (vlax-invoke (vlax-ename->vla-object e) 'rotate3d p q a) ) ) (princ) ) (vl-load-com) (princ)
Hi JCprog,
if you type at the command line
Command: -INSERT
and finalizing the block insertion, press F2 and copy/paste here the prompts.
EDIT: try
(command "_.-insert" "C:\\pole01.dwg" pause "" pause)
Henrique
Here's what I get:
Command: BX90R .-insert Enter block name or [?] <pole01>: C:\\pole01.dwg Units: Inches Conversion: 0'-1.0000" Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]: Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>: 1 Enter Y scale factor <use X scale factor>: Specify rotation angle <0>: Command: Select objects: 1 found Select objects:
This code is really close:
(defun c:bx90r ( / a e i p q r s x ) (command ".-insert" "C:\\pole01.dwg" pause 1 "" pause) (setq a (/ pi 2.0)) (if (setq s (ssget "_:L" '((0 . "INSERT")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) x (entget e) p (trans (cdr (assoc 10 x)) e 0) r (cdr (assoc 50 x)) q (trans (mapcar '+ (cdr (assoc 10 x)) (list (cos r) (sin r) 0.0)) e 0) ) (vlax-invoke (vlax-ename->vla-object e) 'rotate3d p q a) ) ) (princ) ) (vl-load-com) (princ)
*It's just other users might pick the wrong block at the end of this routine.
(setq pt (getpoint"\nPick Insertion Point: "))
(setq sc (getreal"\nEnter Scale: "))
(setq rt (/ (* (getangle"\nEnter Rotation: ") 180.0) pi))
(command"_.Insert""C:\\pole01.dwg" pt sc rt)