Jump to content

POLILINES WIDTH


jim78b

Recommended Posts

Hello,

I would need to modify this lisp, currently it brings all polylines thicknesses to 0 (even in blocks).

I should bring to 0 thresholds those polylines that have thickness <0, while those that already have it at 0 or> 0 I leave them as they are.

 

(defun c:polywidthzero ( / doc )
    (vlax-for block (vla-get-blocks (setq doc (vla-get-activedocument (vlax-get-acad-object))))
        (if (eq :vlax-false (vla-get-isxref block))
            (vlax-for obj block
                (if (eq "AcDbPolyline" (vla-get-objectname obj))
                    (vl-catch-all-apply 'vla-put-constantwidth (list obj 0.0))
                )
            )
        )
    )
    (vla-regen doc acallviewports)
    (princ)
)
(vl-load-com) (princ)

thanks to all

Link to comment
Share on other sites

Replace the line

(if (eq "AcDbPolyline" (vla-get-objectname obj))

With the line

(if (and (eq "AcDbPolyline" (vla-get-objectname obj)) (< (vla-get-thickness obj) 0))

NOT tested!!

  • Thanks 1
Link to comment
Share on other sites

Try this

;;Changing the width of all polylines to zero in all blocks in
;;the drawing if the thickness of the polylines is less than zero
(DEFUN C:POLY0 (/ ACDC BNAME LSBLK REGE)
	(setq ACDC (vla-get-activedocument (vlax-get-acad-object)))
	(vlax-for el (vla-get-blocks ACDC)
		(setq BNAME (vla-get-name el))
		(if	(and
				(eq (vla-get-isxref el) :vlax-false)
				(eq (vla-get-islayout el) :vlax-false)
				(/= (substr BNAME 1 1) "*")
				(wcmatch BNAME "~*|*")
				(not (vl-position el LSBLK))
			)
			(setq LSBLK (cons el LSBLK))
		)
	)
	(foreach Obj LSBLK
		(vlax-for Itm Obj
			(if	(and
					(vlax-property-available-p Itm "ObjectName")
					(vlax-property-available-p Itm "Thickness")
					(= (strcase (vla-get-objectname Itm)) "ACDBPOLYLINE")
					(< (vla-get-thickness Itm) 0)
				)
				(vla-put-constantwidth Itm (setq REGE 0))
			)
		)
	)
	(if REGE (vla-regen ACDC acallviewports))
	(princ)
) ;;C:POLY0

 

  • Thanks 1
Link to comment
Share on other sites

The program works only for polylines inside the block.

For the entities polylines, test the thickness with the function vla-get-thickness (see above).

Link to comment
Share on other sites

Try this

;;Changing the width of the polylines to zero if the
;;thickness of the polylines is less than zero
(DEFUN C:POLY1 (/ ACDC SEL)
	(ssget "_X" (list (quote (0 . "*POLYLINE")) (quote (-4 . "<")) (quote (39 . 0))))
	(setq ACDC (vla-get-activedocument (vlax-get-acad-object)) SEL (vla-get-activeselectionset ACDC))
	(vlax-for Itm SEL (vla-put-constantwidth Itm 0))
	(princ)
) ;;C:POLY1

 

Link to comment
Share on other sites

;;Changing the width of the polylines to zero if the
;;thickness of the polylines is less than zero
(DEFUN C:POLY0 (/ ACDC SEL)
	(ssget "_X" (list (quote (0 . "*POLYLINE")) (quote (-4 . "<")) (quote (39 . 0))))
	(setq ACDC (vla-get-activedocument (vlax-get-acad-object)) SEL (vla-get-activeselectionset ACDC))
	(vlax-for Itm SEL (vl-catch-all-apply (function vla-put-constantwidth) (list Itm 0))
	(princ)
) ;;C:POLY0

malformed list function !

Link to comment
Share on other sites

I didn't make myself clear. I mean if I have polylines with thickness greater than 0 (blocks and not) I leave them like this.
If I have polylines with thickness less than 0 (example 0.001) do I take them to 0. Clear?

Link to comment
Share on other sites

Oh i am so sorry !excuse i mean ...values like 0.1/ 0.001/0.0001 must be 0.

But if i have other polylines that has values different from thath value is ok .

 

So from 0.1 to 0.999999 i think must be 0.

Link to comment
Share on other sites

So update lido's code.

 

;;Changing the width of the polylines to zero if the
;;thickness of the polylines is less than zero
(DEFUN C:POLY0 (/ ACDC SEL)
  (ssget "_X" '((0 . "*POLYLINE") (-4 . "<=") (39 . 0.1))) ;only select polylines that have widths less than or equal to 0.1
  (setq ACDC (vla-get-activedocument (vlax-get-acad-object)) SEL (vla-get-activeselectionset ACDC))
  (vlax-for Itm SEL 
    (vla-put-constantwidth Itm 0)
  )
  (princ)
) ;;C:POLY0

 

Edited by mhupp
less than or equal
  • Thanks 1
Link to comment
Share on other sites

41 minutes ago, jim78b said:

Oh i am so sorry !excuse i mean ...values like 0.1/ 0.001/0.0001 must be 0.

But if i have other polylines that has values different from thath value is ok .

 

So from 0.1 to 0.999999 i think must be 0.

Are we talking about THICKNESS or CONSTANTWIDTH ?

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