wimal Posted May 26, 2018 Share Posted May 26, 2018 In this attached drawing grid bubbles are blocks.Insertion point is not in the center of the block. By selecting a window I need to change the scale of grid bubbles without moving from the center of bubbles. It can do by LISP.But difficult thing is find out the center points of grid bubbles.Please can you help me to win this task. TEST11.dwg Quote Link to comment Share on other sites More sharing options...
dlanorh Posted May 26, 2018 Share Posted May 26, 2018 Please attach file in 2010 format as i cannot open the attached Quote Link to comment Share on other sites More sharing options...
wimal Posted May 26, 2018 Author Share Posted May 26, 2018 attached in 2010 format TEST12.dwg Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 26, 2018 Share Posted May 26, 2018 (defun c:test (/ scl int sel ent obj lft rgt) (and (setq scl (getdist "\nSpecify scale factor :")) (setq int -1 sel (ssget "_:L" '((0 . "INSERT") (2 . "test"))) ) (while (setq ent (ssname sel (setq int (1+ int)))) (vla-getboundingbox (setq obj (vlax-ename->vla-object ent)) 'lft 'rgt ) (vlax-invoke obj 'scaleentity (mapcar '(lambda (q p) (/ (+ q p) 2.0)) (vlax-safearray->list lft) (vlax-safearray->list rgt) ) scl ) ) ) (princ) ) (vl-load-com) Quote Link to comment Share on other sites More sharing options...
rlx Posted May 26, 2018 Share Posted May 26, 2018 (defun c:test (/ scl int sel ent obj lft rgt)... To use a quote from the previous thread : slick coding Tharwat (as allways) Just wondering , why would one put the insertion point on such an odd place??? Import error? Maybe better fix the block? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 26, 2018 Share Posted May 26, 2018 To use a quote from the previous thread : slick coding Tharwat (as allways) Thank you. Just wondering , why would one put the insertion point on such an odd place??? Import error? Maybe better fix the block? Entirely agree with you, a few weeks back I did many interviews for AutoCAD draughtsmen and all of them did not know what is the use of AutoCAD blocks other than gathering objects so to have an insertion point in the wrong place is a bonus compared to others. :lol: Sorry for this off topic. Quote Link to comment Share on other sites More sharing options...
rlx Posted May 26, 2018 Share Posted May 26, 2018 Thank you. Entirely agree with you, a few weeks back I did many interviews for AutoCAD draughtsmen and all of them did not know what is the use of AutoCAD blocks other than gathering objects so to have an insertion point in the wrong place is a bonus compared to others. :lol: Sorry for this off topic. In the end the client doesn't really care what goes on under the 'hood' , as long as the hardcopy looks good so sometimes it hard to explain the skills needed. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 27, 2018 Share Posted May 27, 2018 (edited) Is this part 2 of http://www.cadtutor.net/forum/showthread.php?104211-Circle-inside-the-Block For me I would redo block center point and then pick block, new scale, pick line, so it would move the block and rescale. Checking the center to end point would give the direction, pulling the circle rad using post above. Is this part 3 ? Depending on how many I would cheat and use this pt num bubble erasing the old ones and making new ones. getval.lsp pt num bubble.lsp Edited May 27, 2018 by BIGAL Quote Link to comment Share on other sites More sharing options...
wimal Posted May 27, 2018 Author Share Posted May 27, 2018 (defun c:test (/ scl int sel ent obj lft rgt) (and (setq scl (getdist "\nSpecify scale factor :")) (setq int -1 sel (ssget "_:L" '((0 . "INSERT") (2 . "test"))) ) (while (setq ent (ssname sel (setq int (1+ int)))) (vla-getboundingbox (setq obj (vlax-ename->vla-object ent)) 'lft 'rgt ) (vlax-invoke obj 'scaleentity (mapcar '(lambda (q p) (/ (+ q p) 2.0)) (vlax-safearray->list lft) (vlax-safearray->list rgt) ) scl ) ) ) (princ) ) (vl-load-com) Thanks. That is the code that I excepted.There is nothing to do myself. Quote Link to comment Share on other sites More sharing options...
wimal Posted May 27, 2018 Author Share Posted May 27, 2018 Is this part 2 of http://www.cadtutor.net/forum/showthread.php?104211-Circle-inside-the-Block For me I would redo block center point and then pick block, new scale, pick line, so it would move the block and rescale. Checking the center to end point would give the direction, pulling the circle rad using post above. Is this part 3 ? Depending on how many I would cheat and use this pt num bubble erasing the old ones and making new ones. Exactly. Every thins I have completed for nun block grid bubbles.But when I found this kind of odd blocks I could not proceed.Thanks for all advise. Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted May 28, 2018 Share Posted May 28, 2018 Is this part 2 of http://www.cadtutor.net/forum/showthread.php?104211-Circle-inside-the-Block For me I would redo block center point and then pick block, new scale, pick line, so it would move the block and rescale yes, agree if the block is centered ,it's easy to modify the X & Y scale properties or lisp. (mapcar ''((x) (vlax-put obj (strcat x "Effectivescalefactor") scl)) '("X" "Y")) Checking the center to end point would give the direction, pulling the circle rad using post above both good idea & Tharwat's bounding box idea here's the test [color="green"];rescale bubble test[/color] (defun c:bubsc (/ bn scl ss blk bo scl s2 dp p i ip lo st isblk) ;hanhphuc 28.05.2018 (initget 7) (and (setq bn [color="purple"][b]"test"[/b][/color][color="green"] ; <-- block name to modify [/color] scl (getreal "\nSpecify scale factor : ")) (setq blk ((lambda (doc) (foreach x '(ActiveDocument Blocks) (setq doc (vlax-get doc x)))) (vlax-get-acad-object) ) ss (ssget "X" (list '(-4 . "<OR")'(-4 . "<AND")'(0 . "INSERT")(cons 2 bn)'(66 . 1)'(-4 . "AND>") '(0 . "LINE")'(-4 . "OR>")'(410 . "Model") ) ) ) (progn (setq s2 (vl-remove-if-not ''((x) (= "LINE" (cdr (assoc 0 (entget x))))) (acet-ss-to-list ss))); grid line (repeat (setq i (sslength ss)) (and (setq bo (vlax-ename->vla-object (ssname ss (setq i (1- i))))) ;(= (vla-get-Name bo) bn ) (setq isblk (= (vla-get-ObjectName bo) "AcDbBlockReference")) (vlax-invoke bo 'scaleentity (setq ip ((lambda (obj / a b) (vla-getboundingbox obj 'a 'b) (apply 'mapcar (cons ''((a b) (/ (+ a b) 2.0)) (mapcar 'vlax-safearray->list (list a b))) ) ) bo ) ) scl ) ;_ end of vlax-invoke ) ;_ end of and (foreach x s2 (setq lo (vlax-ename->vla-object x) dp (vl-sort (mapcar ''((x) (cons (distance ip (setq p (vlax-get lo x))) p)) '(StartPoint EndPoint)) ''((a b) (< (car a) (car b))) ) ) (if (and isblk (equal (angle (setq st (cdar dp)) ip) (apply 'angle (reverse (mapcar 'cdr dp))) 0.1 ) ) (vlax-invoke bo 'move st (polar st (angle st ip) (- (* scl (caar dp)) (caar dp))) ) ) ) ) ) ;_ end of progn ) ;_ end of and (princ) ) ;_ end of defun 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.