Charpzy Posted December 23, 2022 Posted December 23, 2022 How would I create it so when I'm inserting a block, I can change the default angle on its preview before I actually insert it? I've been browsing different the web trying to find anything similar but I cant find anything related to this, I've tried tinkering myself but every time I insert the preview always defaults to 0 for its rotation what I'm trying to do is, insert one block and adjust its rotation from there it create a "ang" variable, any other blocks inserted I want it to default to that "ang" so I can view it on that set rotation and align it accordingly Quote
BIGAL Posted December 23, 2022 Posted December 23, 2022 (edited) What may be easier is insert a block set scale and angle etc then run a lisp pick block that way all settings are the same like layer as well then insert just picking a point. Can also prompt for attributes as well. Me or others can provide some code if happy with that idea, please confirm before everyone gets carried away posting something. Edited December 23, 2022 by BIGAL 1 Quote
Charpzy Posted December 23, 2022 Author Posted December 23, 2022 so it would basically insert the block to (0.0 0.0 0.0) for example, set scale and rotation, then run the move command? The blocks being inserted wouldn't be the same blocks each time, it would have a default "pointer" block which on insert I would select the angle, then after click it would insert the block (a note ) giving a preview of the block and angle before I select where to place it my main thing is to be able to view the the set angle/ scale as I move the cursor around then select where to place it (similar to how to move function works) 9 hours ago, BIGAL said: What may be easier is insert a block set scale and angle etc then run a lisp pick block that way all settings are the same like layer as well then insert just picking a point. Can also prompt for attributes as well. Me or others can provide some code if happy with that idea, please confirm before everyone gets carried away posting something. Quote
Charpzy Posted December 23, 2022 Author Posted December 23, 2022 I've got this so far which is set to a specific block, in future it will be selected from a dialog box the only issue, is the measurement line it shows from the old point the the new point. is it possible to not display this? otherwise its dragging across the screen from (0 0 0) cords, ideally if it was to show id like it to show from the first insert point of "ARROW.dwg" but the only way i can think to do this is to insert the "7010C" block there but preferably want the sign not to insert there until i've selected its move point (I can visualise how it looks but can't put it into words, sorry if this isn't a great explanation) (setq actApp (vlax-get-acad-object) actDoc (vla-get-activedocument actApp)) (if (= (getvar 'tilemode) 1) (setq actSpace (vla-get-ModelSpace actDoc)) (setq actSpace (vla-get-PaperSpace actDoc)) ) (setq sface "C:/BricsCAD Scripts/MACROS/DWG/BLOCKS/ARROW.dwg") (setq lst (load (findfile "DATA\\FSDATA.ini"))) (foreach line lst (if (= (nth 2 line) "7010C") (setq path (strcat "C:/BricsCAD Scripts/" (nth 1 line) "/" (nth 2 line) ".dwg")) ) ) (setq pt (getpoint "\nSpecify point: ")) (setq insrt-face (vla-InsertBlock actSpace (vlax-3D-point pt) sface 0.4 0.4 0.4 0.0)) (setq ent (vlax-ename->vla-object (entlast))) (command "rotate" (entlast) "" pt) (while (= 1 (logand 1 (getvar 'CMDACTIVE))) (command pause)) (setq ang (- (/ (* 180 (cdr (assoc 50 (entget (entlast))))) pi)90) ) (princ(vla-get-Rotation ent)) (vla-InsertBlock actSpace '(0.0 0.0 0.0) path 0.8 0.8 0.8 (* pi (/ ang 180.0))) (command "move" (entlast) "" '(0.0 0.0 0.0) ) ;(command "insert" "CP7010C" pause "0.4" "0.4" ang) (princ) Quote
mhupp Posted December 23, 2022 Posted December 23, 2022 (edited) You could just use regular insert with a pause (command "-.Insert" sface (getpoint "\nSpecify point: ") "0.4" "0.4" "//") -Edit Also I know your going to change it. but you need to test for the block in the drawing. always pulling for the Hard drive could be slow especially if its on a network drive or non ssd drive. (if (tblsearch "BLOCK" "ARROW") (setq sface "ARROW") (setq sface "C:/BricsCAD Scripts/MACROS/DWG/BLOCKS/ARROW.dwg") ) Edited December 23, 2022 by mhupp 1 Quote
Charpzy Posted December 23, 2022 Author Posted December 23, 2022 I've tried it with the insert but it doesn't give the preview angle of the sign, it default the angle to 0 I'd like to be able to use insert but as I move the cursor around and the block displays id like it to display it on the angle I previously used when setting the rotation of "ARROW" 4 hours ago, mhupp said: You could just use regular insert with a pause (command "-.Insert" sface (getpoint "\nSpecify point: ") "0.4" "0.4" "//") -Edit Also I know your going to change it. but you need to test for the block in the drawing. always pulling for the Hard drive could be slow especially if its on a network drive or non ssd drive. (if (tblsearch "BLOCK" "ARROW") (setq sface "ARROW") (setq sface "C:/BricsCAD Scripts/MACROS/DWG/BLOCKS/ARROW.dwg") ) Quote
Steven P Posted December 23, 2022 Posted December 23, 2022 (edited) EDITED and rewritten answer..... Try these: 'tryinsert' LISP to insert a block 'resetrot' to reset the default angle next time you insert a block. Using block "circuitbreaker" which is one I had hanging about for testing The angle is stored as a global variable, rot so take care than this is a unique variable. You might also consider saving this value to the registry if you want to use this anlge over a few drawings or sessions of a drawing (defun c:tryinsert ( / pt ) (setq pt (getpoint "Insertion Point")) ; block insertion point (setq yscale 1) (setq xscale 1) ;; (initget "Y N") ;;tjhis was anoying me so seperated to a reset function below ;; (setq NewRot (strcase (getstring "\nReset Rotation [Y / N]"))) ;; (if (= NewRot "Y")(setq rot nil)) (if (= nil rot) ; if rot (rotation) is nil - no value set yet (progn (command "-insert" "circuitbreaker" pt xscale yscale 0) ; insert block (command "rotate" (entlast) "" pt pause) ; rotate block (setq rot (* 180.0 (/ (cdr (assoc 50 (entget (entlast)))) pi)) ) ; get rotation - it is returned as radians, convert to degrees ) ; end progn (progn (command "-insert" "circuitbreaker" pt xscale yscale rot ) (command "rotate" (entlast) "" pt pause) ) ; end progn ) ; end if ) (defun c:resetrot ( / ) ; reset rot (initget "Y N") ;;tjhis was anoying me so seperated to a reset function below (setq NewRot (strcase (getstring "\nReset Rotation [Y / N]"))) (if (= NewRot "Y")(setq rot nil)) ) Edited December 23, 2022 by Steven P Quote
BIGAL Posted December 23, 2022 Posted December 23, 2022 I think using (setenv rot ang) and (setq ang (getenv rot)) is a good idea in this case saving the angle Quote
Charpzy Posted December 24, 2022 Author Posted December 24, 2022 managed to find something similar and implement (setq pt (getpoint "\nPick symbol insert point: ")) (vla-InsertBlock actSpace (vlax-3D-point pt) sface 0.4 0.4 0.4 0.0) (command "rotate" (entlast) "" pt) (while (= 1 (logand 1 (getvar 'CMDACTIVE))) (command pause)) (setq ang (- (/ (* 180 (cdr (assoc 50 (entget (entlast))))) pi) 90)) (setq loop t) (while loop (setq gr (grread t 5)) (cond ((= (car gr) 5) (setq pt (cadr gr)) (if (null oldpt) (setq oldpt pt) ) (if en (progn (vla-move (vlax-ename->vla-object en) (vlax-3d-point (trans oldpt 1 0)) (vlax-3d-point (trans pt 1 0)) ) ) (progn (command "_insert" "CP7010C" pt 0.4 0.4 ang) (setq en (entlast)) ) ) (setq oldpt pt) ) ((= 3 (car gr)) (setq loop nil) ) ) ) (if en (entdel en) ) (command "_insert" "CP7010C" pt 0.4 0.4 ang) (while (= 1 (getvar "cmdactive")) (vl-cmdf pause) ) (princ) Quote
asos2000 Posted December 28, 2022 Posted December 28, 2022 Did you try to use a dynamic Block with alignment parameter? Quote
Recommended Posts
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.