Jump to content

Recommended Posts

Posted

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

Posted

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
Posted

Thanks very much ...so this may work ?

Posted

hello i tested your modification, not work sorry

Posted

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
Posted

Thanks i will try ..but i need Aldo outside blocks . Is this lisp work ?

Posted

The program works only for polylines inside the block.

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

Posted

sorry have patience, but i need that works even for polylines outside blocks.

Posted

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

 

Posted

sorry nothing happen, not work i am so sorry,

Posted

For my it works!

Please test the program on the attached dwg.

Depending on your CAD program, maybe a regeneration of the drawing might be necessary (?)

Test.dwg

Posted

@mhupp

Replace

(vla-put-constantwidth Itm 0)

with

(vl-catch-all-apply (function vla-put-constantwidth) (list Itm 0))

Posted
;;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 !

Posted

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?

Posted

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.

Posted (edited)

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
Posted
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 ?

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