Author Topic: Best method to associate two objects  (Read 363 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 937
  • Marco
Best method to associate two objects
« on: October 11, 2018, 04:41:51 PM »
Best method to associate two objects that is simple and visible in some way, which includes the possibility of copying objects, stretch or editing the object linked to the label, reassociate...
The objective is to (for example) select all the labels (ssget ...) and one by one find the object connected to it.
Xdata? Groups? ...

ribarm

  • Water Moccasin
  • Posts: 1928
  • Marko Ribar, architect
Re: Best method to associate two objects
« Reply #1 on: October 12, 2018, 01:40:01 AM »
Connection line should be in specific layer so you don't mess it with other lines for other purposes... Then iterate through all connection lines and acquire end points entities and create association list : ((block-ename1 entity-ename1) (block-ename2 entity-ename2)...)... Then just iterate through list and find point-lower-left and point-upper-right - you have to use (vla-getboundingbox) on both entities - to get ll and ur - something like this (setq ll (apply 'mapcar (cons 'min (list p1ll p1ur p2ll p2ur)))) and (setq ur (apply 'mapcar (cons 'max (list p1ll p1ur p2ll p2ur))))... Then before next iteration loop (vl-cmdf "_.ZOOM" "_W" "_non" ll "_non" ur) and pause (vl-catch-all-apply 'grread (list nil))... Process iteration until you find desired link - hit ESC to terminate routine...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 937
  • Marco
Re: Best method to associate two objects
« Reply #2 on: October 12, 2018, 03:35:20 AM »
Thanks Marko, this is the method that I am, more or less, using now. I'm looking for something safer to avoid mistakes but at the same time do not obliterate the user to procedures complicated and difficult  to keep under control.

Grrr1337

  • Swamp Rat
  • Posts: 648
Re: Best method to associate two objects
« Reply #3 on: October 12, 2018, 04:46:20 AM »
Maybe an assoc or matrix list that contains the handles?  And the list will be a global variable or stored into some dictionary?

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 937
  • Marco
Re: Best method to associate two objects
« Reply #4 on: October 12, 2018, 05:16:29 AM »
Maybe an assoc or matrix list that contains the handles?  And the list will be a global variable or stored into some dictionary?
I thought of connecting the two objects (block and polyline) writing on both a cross 1005 xdata with the respective handles...

ronjonp

  • Needs a day job
  • Posts: 6802
Re: Best method to associate two objects
« Reply #5 on: October 12, 2018, 08:46:09 AM »
Any specific reason you're not using mleaders?

Windows 10 x64 - AutoCAD /C3D 2019

Custom Build PC

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 937
  • Marco
Re: Best method to associate two objects
« Reply #6 on: October 12, 2018, 04:38:55 PM »

Any specific reason you're not using mleaders?
I use mleader in a similar context but where the end of the leader is always on the connected object
(in that case a block). So, working in reverse, starting from each block I find the leader "associated" with:
; _Utils_SsgetMLeader '(1905.13 2043.22 0.0) 1)
(defun _Utils_SsgetMLeader (PntLst FuzFac)
  (ssget "_X"
    (list
      '(0 . "MULTILEADER")
      '(-4 . ">=,>=,>=")
       (cons 15 (mapcar '- PntLst (list FuzFac FuzFac 0)))
      '(-4 . "<=,<=,<=")
       (cons 15 (mapcar '+ PntLst (list FuzFac FuzFac 0)))
    )
  )
)