Jump to content

Change scales of circle blocks selecting by window - without moving from center


wimal

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

(defun c:test (/ scl int sel ent obj lft rgt)...

 

 

To use a quote from the previous thread : slick coding Tharwat (as allways) :beer:

 

 

Just wondering , why would one put the insertion point on such an odd place??? Import error? Maybe better fix the block?

Link to comment
Share on other sites

To use a quote from the previous thread : slick coding Tharwat (as allways) :beer:

Thank you. :beer:

 

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 :shock: so to have an insertion point in the wrong place is a bonus compared to others. :lol::lol:

 

Sorry for this off topic.

Link to comment
Share on other sites

Thank you. :beer:

 

 

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 :shock: so to have an insertion point in the wrong place is a bonus compared to others. :lol::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.

Link to comment
Share on other sites

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 by BIGAL
Link to comment
Share on other sites

(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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :thumbsup:

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

 

alNZcxU.gif

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...