Replace polyline/line length with a dynamic block

Replace polyline/line length with a dynamic block

nadia.ribeiroXZP64
Participant Participant
935 Views
6 Replies
Message 1 of 7

Replace polyline/line length with a dynamic block

nadia.ribeiroXZP64
Participant
Participant

Hello to all

I'm searching for a way to replace a bunch of previously drawn polylines with a specific dynamic block (with a length parameter attached), as it would make the process of counting and adding these materials they represent more easy with DATAEXTRACTION.

Is there a LISP routine that could help me in this task?

Thanks a bunch

 

0 Likes
Accepted solutions (2)
936 Views
6 Replies
Replies (6)
Message 2 of 7

nadia.ribeiroXZP64
Participant
Participant

Here also, a sample file

0 Likes
Message 3 of 7

ronjonp
Advisor
Advisor
Accepted solution

@nadia.ribeiroXZP64 

Try this:

 

(defun c:foo (/ bl ep p s sp spc)
  ;; RJP » 2022-04-27
  (if (tblobjname "BLOCK" "WALL PANNEL")
    (cond
      ((setq s (ssget ":L" '((0 . "LWPOLYLINE") (90 . 2))))
       (setq spc (vlax-ename->vla-object (cdr (assoc 330 (entget (ssname s 0))))))
       (foreach	e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	 (setq sp (vlax-curve-getstartpoint e))
	 (setq ep (vlax-curve-getendpoint e))
	 (setq bl (vlax-invoke spc 'insertblock sp "WALL PANNEL" 1. 1. 1. (angle sp ep)))
	 (vla-put-layer bl (cdr (assoc 8 (entget e))))
	 (vl-some '(lambda (x) (and (= "WALL LENGTH_meters" (vla-get-propertyname x)) (setq p x)))
		  (vlax-invoke bl 'getdynamicblockproperties)
	 )
	 (vlax-put p 'value (distance sp ep))
	 ;; Uncomment the line below if you want to delete the polyline
	 ;; (entdel e)
       )
      )
    )
    (alert "Block 'WALL PANNEL' not defined in this drawing!")
  )
  (princ)
)

 

 

Message 4 of 7

nadia.ribeiroXZP64
Participant
Participant

Worked like a charm!

Thank you so very much

(PS: In case i need to update the parameters and block name, one need only to change the values in " " right?)

0 Likes
Message 5 of 7

ronjonp
Advisor
Advisor
Accepted solution

@nadia.ribeiroXZP64 wrote:

Worked like a charm!

Thank you so very much

(PS: In case i need to update the parameters and block name, one need only to change the values in " " right?)


Glad to help :). You should be able to just change the strings "" for other block names and parameters. 👍

Message 6 of 7

Sea-Haven
Mentor
Mentor

1st comment problem with setproperty using Bricscad, not supported. need say Lee-mac dynamic properties.lsp

 

As the " walls" are basically 3 parallel lines why not just use X scale for length Y is always scale 1.0 so length is x scale.

 

Entmaking new wall widths would be easy. w200-50 etc

0 Likes
Message 7 of 7

ronjonp
Advisor
Advisor

@Sea-Haven wrote:

1st comment problem with setproperty using Bricscad, not supported. 


Not helpful for AutoCAD users. 🙂

0 Likes