Author Topic: Retrieve info about a lwpolyline in a dynamic block.  (Read 302 times)

0 Members and 1 Guest are viewing this topic.

Kycau

  • Mosquito
  • Posts: 2
Retrieve info about a lwpolyline in a dynamic block.
« on: February 22, 2023, 09:56:59 AM »
Hello,

I have a dynamic block, with Visibility parameter, Lookup parameter and plenty of Linear parameters with stretch actions.
A certain LWPOLYLINE inside my dynamic block, is stretch by around 7-8 stretch parameters, with different opposite directions (like 180 to each other). Some are with different ratio.

I have multiple blocks like this in my DWG, and for each, individual settings for parameters are set.
I need to retrieve this certain lwpolyline's length, from every dynamic block.
I can't do it through info of linear parameters, because they do not always behave correctly.

Lets name the length of this specific LWPOLYLINE = X.
I need from selection of 10 dynamic blocks, retrieve length of X for each case.

Any tips how to do it?

ribarm

  • Gator
  • Posts: 3003
  • Marko Ribar, architect
Re: Retrieve info about a lwpolyline in a dynamic block.
« Reply #1 on: February 22, 2023, 10:18:32 AM »
Have you tried EXPLODE temporarily, iterate through newly appended entities, find LWPOLY - get info, store info, do UNDO before EXPLODE... This all from iteration through all dynamic blocks...

If not working - set visibility correctly, iterate, but firstly convert dynamic to static, again temp. EXPLODE, and so on, so on, ...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

dexus

  • Newt
  • Posts: 122
Re: Retrieve info about a lwpolyline in a dynamic block.
« Reply #2 on: February 22, 2023, 11:04:08 AM »
You could also duplicate the block and explode that one. That way you don't have to rely on undo.

Here is a function to explode an object and then retrieve the resulting objects.
Seems like a good place to start if you ask me.
Code - Auto/Visual Lisp: [Select]
  1. (defun _explode->ss (obj / ent rtn) ; Explode function, return selection set of resulting objects
  2.   (setq ent (entlast)               ; Get startpoint
  3.         rtn (ssadd))                ; Empty selection set
  4.   (command  "_explode" obj "")      ; Explode object
  5.   (while (setq ent (entnext ent))   ; Loop through all changed objects since startpoint
  6.     (ssadd ent rtn)                 ; Add items to selection set
  7.   )
  8.   rtn                               ; return selection set
  9. )

Lee Mac

  • Seagull
  • Posts: 12781
  • London, England
Re: Retrieve info about a lwpolyline in a dynamic block.
« Reply #3 on: February 22, 2023, 02:41:04 PM »
An explode operation is not necessary, you can simply iterate over the components held by the anonymous block definition generated when the dynamic parameters are changed.

steve.carson

  • Newt
  • Posts: 99
Re: Retrieve info about a lwpolyline in a dynamic block.
« Reply #4 on: February 22, 2023, 03:11:34 PM »
If you just need the number, you can add a field to the block definition to always display the length of the polyline.