Author Topic: Matching Another Mleader Attribute Values  (Read 6736 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2599
  • I can't remeber what I already asked! I need help!
Matching Another Mleader Attribute Values
« on: January 20, 2016, 11:23:37 AM »
Is it possible to select a MLeader that has a block with an Attributed Value to another MLeader? Where it can match the same MLeader Style and Overwrite the existing Attribute?

I have found Lee's Awesome Routine

http://www.lee-mac.com/copytext.html

But I thought this would do the job, but maybe I am missing something?

Thanks for the help.
Civil3D 2020

Lee Mac

  • Seagull
  • Posts: 12910
  • London, England
Re: Matching Another Mleader Attribute Values
« Reply #1 on: January 20, 2016, 11:56:43 AM »
I haven't yet incorporated compatibility for MLeader Attributes into my Copy/Swap Text program.

MSTG007

  • Gator
  • Posts: 2599
  • I can't remeber what I already asked! I need help!
Re: Matching Another Mleader Attribute Values
« Reply #2 on: January 20, 2016, 12:01:09 PM »
Notta problem. I just wanted to make sure I wasn't nutts. Thanks for letting me know!
Civil3D 2020

tedg

  • Swamp Rat
  • Posts: 811
Re: Matching Another Mleader Attribute Values
« Reply #3 on: January 20, 2016, 01:30:24 PM »
I haven't yet incorporated compatibility for MLeader Attributes into my Copy/Swap Text program.
Slacker...
(JK...you are the MAN!! ..you share so much I had to kid)
Windows 10 Pro 64bit, AutoCAD 2023, REVIT 2023

Lee Mac

  • Seagull
  • Posts: 12910
  • London, England
Re: Matching Another Mleader Attribute Values
« Reply #4 on: January 20, 2016, 06:34:38 PM »
I haven't yet incorporated compatibility for MLeader Attributes into my Copy/Swap Text program.
Slacker...
(JK...you are the MAN!! ..you share so much I had to kid)

 :evil:

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Matching Another Mleader Attribute Values
« Reply #5 on: January 26, 2016, 05:19:58 PM »
Lee may not have incorporated mLeaders into his routine yet, but here is what I have. Please note that this will not copy mleaderstyles, but it will copy text to and from mleaders, tables, attributes, dtext, mtext and dimensions. In short if it contains text, this routine should handle it fairly well. You can also copy a text item to multiple pieces of text, set increments for numbers and even type text to enter instead.

Please note that this code heavily relies on code from Lee Mac and a few others, which should all be documented as far as I am aware. That being said, if you do see code of yours in this routine and it is not documented, please let me know so I can fix it.

Also, if you find bugs, please let me know that as well.

MSTG007

  • Gator
  • Posts: 2599
  • I can't remeber what I already asked! I need help!
Re: Matching Another Mleader Attribute Values
« Reply #6 on: January 26, 2016, 05:29:59 PM »
Hey, Thank you for sharing. I am messing around with one now. With the Mleaders I am at do the text side of things but not with the attached attributed block. I will keep plugging around with it, (lol maybe its my machine)!
Civil3D 2020

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Matching Another Mleader Attribute Values
« Reply #7 on: January 27, 2016, 03:03:08 PM »
@ cmwade77:
Thanks for sharing your code. I am particularly interested in the way you determine which Mleader attribute is selected.

Your approach in a nutshell: You calculate a box around a selected point and then check if the (translated) insertion point of the attribute falls inside that box. This is a bit tricky as the user can easily click a point that is further away.

Another approach would be to calculate the textbox of the attribute and determine if the selected point falls inside. This would be my preference, although there is then the issue of Mtext formatting.

To improve your approach:
Use the height of the attribute when calculating the box.
Take the block scaling into account.

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Matching Another Mleader Attribute Values
« Reply #8 on: January 27, 2016, 07:01:23 PM »
@ cmwade77:
Thanks for sharing your code. I am particularly interested in the way you determine which Mleader attribute is selected.

Your approach in a nutshell: You calculate a box around a selected point and then check if the (translated) insertion point of the attribute falls inside that box. This is a bit tricky as the user can easily click a point that is further away.

Another approach would be to calculate the textbox of the attribute and determine if the selected point falls inside. This would be my preference, although there is then the issue of Mtext formatting.

To improve your approach:
Use the height of the attribute when calculating the box.
Take the block scaling into account.
The problem is how the block and attributes gets attached to the mLeader, basically, it treats it as though the mleader and block are always at 0,0 if you don't use my approach, which then makes it near impossible to accurately determine if the selected point works or not.

As for selecting a point further away, my routine does account for that in that if you do not click on an object of any sort, it will create a crossing window to paste the text into.

Admittedly, it's not the prettiest way to do it, in fact my method with the crossing window is flat out brute force, but it gets the job done. Admittedly this method is based off of code that was in this office long before I ever came to work here, I believe the part of the code that this is based on is over 20 years old, so there are indeed probably better ways to handle it, if you can figure out the insertion issues.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Matching Another Mleader Attribute Values
« Reply #9 on: January 28, 2016, 03:31:49 AM »
As for selecting a point further away, my routine does account for that in that if you do not click on an object of any sort, it will create a crossing window to paste the text into.
In the situation where you select an Mleader attribute but the picked point does not fall inside the 'insertion point box' this does not occur I think.

MSTG007

  • Gator
  • Posts: 2599
  • I can't remeber what I already asked! I need help!
Re: Matching Another Mleader Attribute Values
« Reply #10 on: January 28, 2016, 07:29:41 AM »
Could I ask if this works with a MLeader Attributed Block; do you have a dwg Mleader style that works with your routine? I can get the MLeader to work with Text, but I do not know if there is something wrong with the Attached Block. I have noticed if I Explode the MLeader and then CT on the Attributed Block it does work.
Civil3D 2020

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Matching Another Mleader Attribute Values
« Reply #11 on: January 28, 2016, 10:25:18 AM »
@ MSTG007:
I think the code was created with 'imperial' units in mind. The diagonal of the box referred to before is only 0.26.

MSTG007

  • Gator
  • Posts: 2599
  • I can't remeber what I already asked! I need help!
Re: Matching Another Mleader Attribute Values
« Reply #12 on: January 28, 2016, 10:33:32 AM »
Well, This is kinda what I am playing around with.
Civil3D 2020

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Matching Another Mleader Attribute Values
« Reply #13 on: January 28, 2016, 11:25:07 AM »
The problem is related to the alignment of the attribute.
Change (2x):
Code: [Select]
(setq TestPt1
  (polar
    (vlax-safearray->list
      (vlax-variant-value (vla-get-insertionpoint Att))
    )
    (angle '(0 0 0) InsPt1)
    (distance '(0 0 0) InsPt1)
  )
)
To:
Code: [Select]
(setq TestPt1
  (mapcar
    '+
    (vlax-get Att (if (zerop (vla-get-alignment Att)) 'insertionpoint 'textalignmentpoint))
    InsPt1
  )
)

Note: Your Mleader is annotative. I expect there will be additional issues with certain anno scales.

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Matching Another Mleader Attribute Values
« Reply #14 on: January 28, 2016, 01:04:21 PM »
Could I ask if this works with a MLeader Attributed Block; do you have a dwg Mleader style that works with your routine? I can get the MLeader to work with Text, but I do not know if there is something wrong with the Attached Block. I have noticed if I Explode the MLeader and then CT on the Attributed Block it does work.
Here are the leader styles that we work with.