Replace polyline/line length with a dynamic block

Replace polyline/line length with a dynamic block

nadia.ribeiroXZP64
Participant Participant
936件の閲覧回数
6件の返信
メッセージ1/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 件のいいね
解決済み
937件の閲覧回数
6件の返信
返信 (6)
メッセージ2/7

nadia.ribeiroXZP64
Participant
Participant

Here also, a sample file

0 件のいいね
メッセージ3/7

ronjonp
Advisor
Advisor
解決済み

@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)
)

 

 

メッセージ4/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 件のいいね
メッセージ5/7

ronjonp
Advisor
Advisor
解決済み

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

メッセージ6/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 件のいいね
メッセージ7/7

ronjonp
Advisor
Advisor

@Sea-Haven wrote:

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


Not helpful for AutoCAD users. 🙂

0 件のいいね