Jump to content

Recommended Posts

Posted

Thank you guys on the forum for helping me process the series like the content and wishes in the drawing I attached. Thank you

Test.dwg

Posted

@mdchuyen

This lisp can replace all blocks with a horizontal one.
But these blocks will have the same name as the horizontal block.

replac.lsp

  • Like 1
Posted (edited)

For that simple example try this. Be aware that the new block names will be "P2B" rather than "P2B#"

(defun c:foo (/ s)
  (cond	((null (tblobjname "block" "P2B"))
	 (entmake '((0 . "BLOCK")
		    (100 . "AcDbEntity")
		    (67 . 0)
		    (8 . "0")
		    (100 . "AcDbBlockReference")
		    (2 . "P2B")
		    (10 0. 0. 0.)
		    (70 . 0)
		   )
	 )
	 (entmake '((0 . "LWPOLYLINE")
		    (100 . "AcDbEntity")
		    (67 . 0)
		    (8 . "DC-PHU")
		    (100 . "AcDbPolyline")
		    (90 . 4)
		    (70 . 1)
		    (43 . 0.)
		    (38 . 0.)
		    (39 . 0.)
		    (10 23.87326421258058 13.68140906092549)
		    (10 -23.87326421258058 13.6814090609255)
		    (10 -23.87326421258058 -13.68140906092547)
		    (10 23.87326421258058 -13.68140906092549)
		   )
	 )
	 (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0")))
	)
  )
  (if (setq s (ssget ":L" '((0 . "INSERT") (2 . "P2B*"))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (entmod (append (entget e) '((2 . "P2B"))))
    )
  )
  (princ)
)

 

Edited by ronjonp
  • Like 1
Posted
4 hours ago, ronjonp said:

For that simple example try this. Be aware that the new block names will be "P2B" rather than "P2B#"

(defun c:foo (/ s)
  (cond	((null (tblobjname "block" "P2B"))
	 (entmake '((0 . "BLOCK")
		    (100 . "AcDbEntity")
		    (67 . 0)
		    (8 . "0")
		    (100 . "AcDbBlockReference")
		    (2 . "P2B")
		    (10 0. 0. 0.)
		    (70 . 0)
		   )
	 )
	 (entmake '((0 . "LWPOLYLINE")
		    (100 . "AcDbEntity")
		    (67 . 0)
		    (8 . "DC-PHU")
		    (100 . "AcDbPolyline")
		    (90 . 4)
		    (70 . 1)
		    (43 . 0.)
		    (38 . 0.)
		    (39 . 0.)
		    (10 23.87326421258058 13.68140906092549)
		    (10 -23.87326421258058 13.6814090609255)
		    (10 -23.87326421258058 -13.68140906092547)
		    (10 23.87326421258058 -13.68140906092549)
		   )
	 )
	 (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0")))
	)
  )
  (if (setq s (ssget ":L" '((0 . "INSERT") (2 . "P2B*"))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (entmod (append (entget e) '((2 . "P2B"))))
    )
  )
  (princ)
)

 

Great, thanks for your help

Posted
10 minutes ago, ronjonp said:

Glad to help :beer:

If the object is not a block but a rectangle, can you help me fix it?

Posted
28 minutes ago, mdchuyen said:

If the object is not a block but a rectangle, can you help me fix it?

Probably not sorry.

Posted (edited)

Try this, note you need to do the is it a block "INSERT" or a "LWPOLYLINE" choice.

 

(defun c:wow ( / oldsnap d1 d2 plent)
(setq oldsnap (getvar 'osmode))

(setvar 'osmode 1)

(while (setq pt (getpoint "\nPick control corner Enter to exit "))
  (setq ss (ssget pt))
  (setq plent (ssname ss 0))
  (setq lay (cdr (assoc 8 (entget plent))))
  (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget plent))))
  (setq d1 (distance (car co-ord) (cadr co-ord)))
  (setq d2 (distance (cadr co-ord) (caddr co-ord)))
  (if (< d2 d1)
   (command "rectang" "D" d1 d2 pt (getvar 'extmax))
   (command "rectang" "D" d2 d1 pt (getvar 'extmax))
)
(command "erase" plent "")
)
           
(setvar 'osmode oldsnap)
    
(princ)
)
(c:wow)

 

Edited by BIGAL
  • Like 1
Posted
2 hours ago, BIGAL said:

Try this, note you need to do the is it a block "INSERT" or a "LWPOLYLINE" choice.

 

(defun c:wow ( / oldsnap d1 d2 plent)
(setq oldsnap (getvar 'osmode))

(setvar 'osmode 1)

(while (setq pt (getpoint "\nPick control corner Enter to exit "))
  (setq ss (ssget pt))
  (setq plent (ssname ss 0))
  (setq lay (cdr (assoc 8 (entget plent))))
  (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget plent))))
  (setq d1 (distance (car co-ord) (cadr co-ord)))
  (setq d2 (distance (cadr co-ord) (caddr co-ord)))
  (if (< d2 d1)
   (command "rectang" "D" d1 d2 pt (getvar 'extmax))
   (command "rectang" "D" d2 d1 pt (getvar 'extmax))
)
(command "erase" plent "")
)
           
(setvar 'osmode oldsnap)
    
(princ)
)
(c:wow)

 

I want to rotate these viewports horizontally. The center of rotation is the center of this rectangle. Thank you

Test1.dwg

Posted (edited)

Yes can be done I make layouts and use a UCS method so each mview matches the layout angle. There is walk a long a pline so rectangs rotate and other version more a copy but all rectangs horizontal.

 

Multiradio2col34.png.e8f8746b7256073461193bead0dea7a0.png

 

Hint (command "UCS" "Z" ang "plan" "")

 

There is a little bit more than just take the rectang angle as shown in image above the correct title block is used for the layout generation. It normally needs a bit of customisation to suit your company so its not free but real cheap like the price of a cup of coffee.

 

image.png.08d01cedefe49d959841d2671fb3e674.png

 

 

 

 

 

 

 

 

Edited by BIGAL

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