Jump to content

Recommended Posts

Posted

Is there a way for a lisp to go through the entire drawing (without selection) and delete vertical lines from within the block without (those rev clouded in dwg attached)? I have many of these throughout the paper space (multiple tabs) but I did not want to the position of the leader to change - stay where it is and how it is (ONLY that line to be removed). or better yet to make it layer defpoints and colour 30.

so basically this vertical line is extended with the addition in the number of lines but I resorted to a simple Qleader and would like the existing projects (that already have the old block) to match the new leader that has no vertical line.

 

Is there anyone who could give me hand here?

 

Thanks,

Sam

new block.dwg

Posted

Try this:

(defun c:foo (/ c)
  ;; RJP » 2020-07-22
  (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
    (if	(= 0 (vlax-get b 'islayout) (vlax-get b 'isxref))
      (vlax-for	a b
	(and (or (and (= "AcDbPolyline" (vla-get-objectname a))
		      (equal (car (setq c (vlax-get a 'coordinates))) (caddr c) 1e-8)
		 )
		 (and (= "AcDbLine" (vla-get-objectname a))
		      (equal (car (vlax-get a 'startpoint)) (car (vlax-get a 'endpoint)) 1e-8)
		 )
	     )
	     (entmod (append (entget (vlax-vla-object->ename a)) '((8 . "defpoints") (62 . 30))))
	)
      )
    )
  )
  (princ)
)
(vl-load-com)

 

Posted
15 hours ago, ronjonp said:

Try this:


(defun c:foo (/ c)
  ;; RJP » 2020-07-22
  (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
    (if	(= 0 (vlax-get b 'islayout) (vlax-get b 'isxref))
      (vlax-for	a b
	(and (or (and (= "AcDbPolyline" (vla-get-objectname a))
		      (equal (car (setq c (vlax-get a 'coordinates))) (caddr c) 1e-8)
		 )
		 (and (= "AcDbLine" (vla-get-objectname a))
		      (equal (car (vlax-get a 'startpoint)) (car (vlax-get a 'endpoint)) 1e-8)
		 )
	     )
	     (entmod (append (entget (vlax-vla-object->ename a)) '((8 . "defpoints") (62 . 30))))
	)
      )
    )
  )
  (princ)
)
(vl-load-com)

 

Good day @ronjonp,

I did not even come close to what you created but had some similar result whereby all vertical lines on other blocks are now defpoints and #30 - the reason is because I still have a hard time dealing with "dxflist" I believe it is called!

If I were to include these blocks exclusively:

"Tx - Leader avec texte 238 - 11x17"

"Tx - Leader avec texte 165 - 8½x14"

"Tx - Leader avec texte 165 - 8½x11"

 

Would you let me know how to use a list of block names/ items?

 

Thanks

Posted (edited)
4 hours ago, Sambuddy said:

 

Would you let me know how to use a list of block names/ items?

Try something like this:

(defun _foo (blocknames / c)
  ;; RJP » 2020-07-23
  (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
    (if	;; (= 0 (vlax-get b 'islayout) (vlax-get b 'isxref))
	(vl-position (strcase (vla-get-name b)) (mapcar 'strcase blocknames))
      (vlax-for	a b
	(and (or (and (= "AcDbPolyline" (vla-get-objectname a))
		      (equal (car (setq c (vlax-get a 'coordinates))) (caddr c) 1e-8)
		 )
		 (and (= "AcDbLine" (vla-get-objectname a))
		      (equal (car (vlax-get a 'startpoint)) (car (vlax-get a 'endpoint)) 1e-8)
		 )
	     )
	     (entmod (append (entget (vlax-vla-object->ename a)) '((8 . "defpoints") (62 . 30))))
	)
      )
    )
  )
  (princ)
)
(vl-load-com)
(_foo '("Tx - Leader avec texte 238 - 11x17"
	"Tx - Leader avec texte 165 - 8½x14"
	"Tx - Leader avec texte 165 - 8½x11"
       )
)

 

Edited by ronjonp
Posted

Thanks a lot @ronjonp

The only difference between your earlier code and this one is that I now need to physically open the block in block editor for the changes to take effect - whereas on your previous version a simple "regen" would have taken care of the issue.

Would you please let me know if there is a way to get around that?

 

Other than that, it is great and working beautifully!

Posted

The changes are not showing up in the other blocks because they are dynamic and modified. This makes the name different ie *U#. The code above modifies the block definition and not the block references.

Posted

Thanks a lot @ronjonp

 

So to overcome this, I have to open the block in block editor?

 

Thanks

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