halam Posted October 18, 2016 Share Posted October 18, 2016 Hi all For scaling purposes i tweaked a routine to let me scale a selectionset in Z direction. Works good, but the disadvantage is that it will not work in 'Refedit mode'. Since in 3D i a lot of work is within blocks i really am looking for a other methode than this -insert / purge method. Idea to do this with some kind of vla call? (defun C:SXYZ (/ SS IP XS YS ZS RA) (setvar "cmdecho" 0) (setq SS (ssget) IP (getpoint "Enter Base point (temp. blockname 'xstemp' will be used :") ) ;_ end of setq (initget 6) (setq XS (getreal "Enter X scale factor <1>:")) (initget 6) (setq YS (getreal "Enter Y scale factor (default=X):")) (setq ZS (getreal "Enter Z scale factor (default=X):") RA (getreal "Enter Rotation angle <0>:") ) ;_ end of setq (if (= XS NIL) (setq XS 1) ) ;_ end of if (if (= YS NIL) (setq YS XS) ) ;_ end of if (if (= ZS NIL) (setq ZS XS) ) ;_ end of if (if (= RA NIL) (setq RA 0) ) ;_ end of if (command "block" "xstemp" IP SS "" "insert" "xstemp" IP "xyz" XS YS ZS RA "explode" "l" "purge" "b" "xstemp" "n" ) ;_ end of command ) Quote Link to comment Share on other sites More sharing options...
Luís Augusto Posted October 18, 2016 Share Posted October 18, 2016 Hi allIdea to do this with some kind of vla call? (vl-load-com) (defun c:test() (if (setq p2 (getpoint "\nSpecify the insertion point:\n ")) (progn (setq _blkName "PONTO" _scaleX 1.0 _scaleY 1.0 _scaleZ 1.0 _rotation 0 ) ;_ >setq (setq vla-obj (vla-insertblock ( (if (eq (getvar "cvport") 1) vla-get-paperspace vla-get-modelspace ) ;_ >if (vla-get-ActiveDocument (vlax-get-acad-object) ) ;_ >vla-get-ActiveDocument ) (vlax-3d-point p2) _blkName _scaleX _scaleY _scaleZ _rotation ) ;_ >vla-insertblock ) ;_ >setq (redraw (entlast) 1) vla-obj ) ;_ >progn ) ;_ >if ) ;_ >defun I hope this code will help you. Best regards Luís Augusto Quote Link to comment Share on other sites More sharing options...
halam Posted October 18, 2016 Author Share Posted October 18, 2016 (edited) Thanks Luis! I will give it a try.. code sure looks pretty EDIT: :test no result in AutoCAD ; error: Automation Error. Filer error I think the part (vlax-3d-point p2) What also doesn't work is this.. (vla-insertblock ( (if (eq (getvar "cvport") 1) vla-get-paperspace vla-get-modelspace ) ;_ >if (vla-get-ActiveDocument (vlax-get-acad-object) ) ;_ >vla-get-ActiveDocument ) (vlax-3d-point IP) xstemp ; is this correct? how to call a name by block? XS YS ZS RA ) Edited October 18, 2016 by halam Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 19, 2016 Share Posted October 19, 2016 Another suggestion use a cond for multiple if's (cond ((= XS NIL)(setq XS 1)) ((= YS NIL)(setq YS XS)) ((= ZS NIL)(setq ZS XS)) ((= RA NIL)(setq RA 0)) ) Quote Link to comment Share on other sites More sharing options...
Luís Augusto Posted October 19, 2016 Share Posted October 19, 2016 (edited) That was the reference I used. I hope it helps you. http://www.afralisp.net/archive/methods/lista/insertblock_method.htm (defun c:test () ;---------------{sub function}---------------; (defun insBlock ( _blkName ;string _scaleX ;real _scaleY ;real _scaleZ ;real _rotation ;real / _blkInsertPoint *error* ) (defun *error* (errmsg) (princ "\nAn error has occurred in the programme.\n ") (prompt errmsg) (princ) ) ;_ >defun (setq thisdrawing (vla-get-activedocument (vlax-get-acad-object) ) ;_ >vla-get-activedocument ) ;_ >setq (setq mspace (vla-get-modelspace thisdrawing)) (setq util (vla-get-utility thisdrawing)) (if (not (tblsearch "BLOCK" _blkName)) (if (and (setq filePath (findfile (strcat _blkName ".dwg"))) (progn (command "_.-insert" filePath nil) t) ) ;_ >and (setq blkFlag t) (setq blkFlag nil) ) ;_ >if (setq blkFlag t) ) ;_ >if (if blkFlag (progn (setq _blkInsertPoint (vla-GetPoint util nil "\nInsertion Point: ")) (setq vla-obj (vla-insertblock mspace _blkInsertPoint _blkName _scaleX _scaleY _scaleZ _rotation ) ;_ >vla-insertblock ) ;_ >setq (redraw (entlast) 1) vla-obj ) ;_ >progn (alert "Block not found.") ) ;_ >if ) ;_ >defun ;---------------{sub function}---------------; (setq vla-obj ;get-vlaObject (insBlock ;call sub function "blkName" ;your block name 1.0 ;scale x 1.0 ;scale y 1.0 ;scale z 0.0 ;rotation ) ;_ >insBlock ) ;_ >setq ) ;_ >defun Edited October 19, 2016 by Luís Augusto Quote Link to comment Share on other sites More sharing options...
Grrr Posted October 19, 2016 Share Posted October 19, 2016 Heres another example: (defun C:test ( / acDoc AcSpc MyBlockName XS YS ZS Rot insPt BlkRefObj ) (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (setq AcSpc (vlax-get acDoc (if (= acModelSpace (vla-get-ActiveSpace acDoc)) 'ModelSpace (if (= (vla-get-mSpace acDoc) :vlax-true) 'ModelSpace 'PaperSpace ) ) ) )'; setq (setq MyBlockName "MyBlock" XS 1.0 YS 1.0 ZS 1.0 Rot 0.0 ; Value in degrees ); setq (if (and (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list (vla-get-Blocks acDoc) MyBlockName)))) (setq insPt (getpoint (strcat "\nSpecify \"" MyBlockName "\" insertion point: "))) ) (setq BlkRefObj (vla-InsertBlock AcSpc (vlax-3D-point insPt) MyBlockName XS YS ZS (* pi (/ Rot 180)))) ) (princ) );| defun |; (or (vlax-get-acad-object) (vl-load-com)) (princ) Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted October 19, 2016 Share Posted October 19, 2016 AFAIK the problem of the original code is the use of the _BLOCK command and not the _INSERT command. Creating alternative insert code, although interesting, will not solve the OP's problem. Quote Link to comment Share on other sites More sharing options...
Luís Augusto Posted October 19, 2016 Share Posted October 19, 2016 .... Quote Link to comment Share on other sites More sharing options...
halam Posted October 19, 2016 Author Share Posted October 19, 2016 Thanks for your replies guys Luis' is very nice but works only in 'normal' mode, not inside the block editor. Command: # Command: ** Self reference detected: 1 block reference not added to the work set. I think .. - there is no other way to 'deform' XYZ other than manipulate 'as block' - one way as workaround for it.. 1. 'refset' => remove selected => 2. 'refclose' 3. SXYZ selected 4. 'refedit' previous block you where working in.. 5. 'refset' => add the selected (scaled) . done. This is just what would be done manually... faster if automated Some good 'refset' add / remove & Refedit function... searching _.-REFEDIT Quote Link to comment Share on other sites More sharing options...
Luís Augusto Posted October 20, 2016 Share Posted October 20, 2016 Have you tried to use the entmod function? I think maybe my little knowledge will not be enough to help you. Is it possible you post a sample drawing so we can try? Quote Link to comment Share on other sites More sharing options...
Grrr Posted October 20, 2016 Share Posted October 20, 2016 Hans, Its not possible to add block reference inside that same block's definition, thats why you have this error. Command: ** Self reference detected:1 block reference not added to the work set. Usually when I attempt such thing my ACAD crashes (for example try LM's program, called "AddObjects2Block" and pick for a source and destination objects two block references of the same block name). Simply said its like trying to nest "BlockA" inside of "BlockA". Another example is if you have 2 blocks and "BlockB" is nested inside "BlockA", then you can not nest "BlockA" inside "BlockB". Quote Link to comment Share on other sites More sharing options...
halam Posted October 20, 2016 Author Share Posted October 20, 2016 I will look at the a entmod method later, thanks for that Luis. ALso for the suggested routine that Lee Mac has made. @Grrr. I don't think you clearly see the problem i have while working in blockedit mode. The routine only temporary uses a block. It gets purged after the scaling has taken place. My problem is that the (default) commands (methods i can think of) for creating blocks are blocked in the first place. Beacuse of the fact that you cannot define or a block while working in a block. I think there is a reason for that but i'm not that deep into de logic behind dwg hyrarchy. Why is that? .. Still, i would be very happy of have a way to scale XY(Z) WHILE i am defining 3D blocks that have multiple parts and inserted in many places... Kind regards hans Quote Link to comment Share on other sites More sharing options...
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.