Author Topic: Stretch Mleader  (Read 6341 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Stretch Mleader
« on: September 14, 2017, 09:14:06 AM »
Is there a way to Stretch without selecting the two grips with the shift keyboard, basically like taking the midpoint as in the exploded version?

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Stretch Mleader
« Reply #1 on: September 14, 2017, 10:09:34 AM »
Use the stretch command ( s ) with a crossing window?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Stretch Mleader
« Reply #2 on: September 14, 2017, 10:39:55 AM »
Use the stretch command ( s ) with a crossing window?
Thanks, but sometime there are objects inside the Windows... it is not very fast...

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Stretch Mleader
« Reply #3 on: September 14, 2017, 11:39:03 AM »
When I explode an mleader it is a bunch of pieces ? How are you accomplishing the top image?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Stretch Mleader
« Reply #4 on: September 14, 2017, 11:55:00 AM »
When I explode an mleader it is a bunch of pieces ? How are you accomplishing the top image?
I have exploded Mleader only to show (see DWG), but I do not want explode it...
Somethink like this, but if there are objects on the endpoints they are stretched...:
Code: [Select]
(defun C:zz ( / Pnt000)
  (setq Pnt000 (getpoint "\nSeleziona il primo punto finale della direttrice da stirare: "))
  (prompt "\nSeleziona l'altro punto finale: ")
  (vl-cmdf "_.STRETCH" "_C" Pnt000 "_END" pause "" Pnt000)
  (princ)
)

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Stretch Mleader
« Reply #5 on: September 14, 2017, 04:49:46 PM »
Maybe a combination of grread and modifying the coordinates of the mleader .. stretch seem more applicable though.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Stretch Mleader
« Reply #6 on: September 14, 2017, 06:06:27 PM »
Use the stretch command ( s ) with a crossing window?
Thanks, but sometime there are objects inside the Windows... it is not very fast...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / p q s )
  2.     (if (and (setq p (getpoint "\nSpecify first corner of crossing window: "))
  3.              (setq q (getcorner p "\nSpecify opposite corner: "))
  4.         )
  5.         (if (setq s (ssget "_C" p q '((0 . "MULTILEADER"))))
  6.             (vl-cmdf "_.stretch" s "" "\\" "\\")
  7.             (princ "\nNo multileaders found in crossing window.")
  8.         )
  9.     )
  10.     (princ)
  11. )

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Stretch Mleader
« Reply #7 on: September 15, 2017, 02:05:08 AM »
Use the stretch command ( s ) with a crossing window?
Thanks, but sometime there are objects inside the Windows... it is not very fast...
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / p q s ) ...)
Thank you Lee, you gave me the idea to do two new commands too:
- stretch by filtering from selected object(s)
- stretch by filtering from selected layer(s)
 :-)

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Stretch Mleader
« Reply #8 on: September 15, 2017, 07:14:10 AM »
Way to go Lee. I don't know how many of you use Civil3D. Specially with the Grading Elevation Labels. By changing the filter to that it makes stretching those spot shots a lot easier than clicking / griping.

Code: [Select]
      (defun c:test ( / p q s )

    (if (and (setq p (getpoint "\nSpecify first corner of crossing window: "))

             (setq q (getcorner p "\nSpecify opposite corner: "))

    )

;;        (if (setq s (ssget "_C" p q '((0 . "MULTILEADER"))))

        (if (setq s (ssget "_C" p q '((0 . "AECC_SURFACE_ELEVATION_LABEL") (8 . "0-SRF-LBL"))))

            (vl-cmdf "_.stretch" s "" "\\" "\\")

            (princ "\nNo multileaders found in crossing window.")

        )

    )

    (princ)

Civil3D 2020

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Stretch Mleader
« Reply #9 on: September 15, 2017, 07:53:43 AM »
Good stuff guys, glad I could help.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Stretch Mleader
« Reply #10 on: September 15, 2017, 07:54:59 AM »
Lee. . . Man! You always Help!
Civil3D 2020

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Stretch Mleader
« Reply #11 on: September 15, 2017, 08:11:59 AM »
I know this is another off the wall question. With this scenario the user has to window the object. Works great.

But how would a user select an object and it react the same?

Like an MLeader default we click once and then click again on the grip or type in the command to stretch it.

lol save a click. Thoughts?
Civil3D 2020

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Stretch Mleader
« Reply #12 on: September 18, 2017, 05:08:10 PM »

Stretch by filtering from selected object(s):
Code: [Select]
(defun C:ALE_Edit_StretchOnlySelected ( / p q Ss_Tot Ss_Str Countr EntNam)
  (if
    (and
      (princ "\nSelect Objects to Stretch: ")
      (setq Ss_Str (ssget))
      (setq p (getpoint "\nSpecify first corner of Crossing Window: "))
      (setq q (getcorner p "\nSpecify opposite corner: "))
    )
    (progn
      (if (setq Ss_Tot (ssget "_C" p q))
        (progn
          (repeat (setq Countr (sslength Ss_Tot))
            (or
              (ssmemb (setq EntNam (ssname Ss_Tot (setq Countr (1- Countr)))) Ss_Str)
              (ssdel EntNam Ss_Tot)
            ) 
          )         
          (if (> (sslength Ss_Str) 0)
            (progn
              (princ "\nBase point: ")
              (vl-cmdf "_.STRETCH" Ss_Tot "" "\\")
              (princ "\nSecond point: ")
              (vl-cmdf "\\")
            )
            (princ "\nNo Objects to Stretch found in Crossing Window.")
          )
        )
        (princ "\nNo Objects to Stretch found in Crossing Window.")
      )
    )
  )
  (princ)
)

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Stretch Mleader
« Reply #13 on: September 18, 2017, 05:43:31 PM »
Good extension of the idea Marc  :-)

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Stretch Mleader
« Reply #14 on: September 19, 2017, 03:28:12 AM »

Good extension of the idea Marc  :)
New "extension"  8) :
Code: [Select]
(defun C:ALE_Edit_StretchOnlyLayerSel ( / Pnt001 Pnt002 Ss_Tot Ss_Str Countr EntNam LyrLst LyrStr LyrNam)
  (if
    (and
      (princ "\nSelect Objects on Layer to Stretch: ")
      (setq Ss_Str (ssget))
      (setq Pnt001 (getpoint "\nSpecify first corner of Crossing Window: "))
      (setq Pnt002 (getcorner Pnt001 "\nSpecify opposite corner: "))
    )
    (progn
      (repeat (setq Countr (sslength Ss_Str))
        (or
          (member (setq LyrNam (cdr (assoc 8 (entget (ssname Ss_Str (setq Countr (1- Countr))))))) LyrLst)
          (setq LyrLst (cons LyrNam LyrLst))
         ) 
      )
      (if (setq Ss_Tot (ssget "_C" Pnt001 Pnt002 (list (cons 8 (vl-string-trim "()" (vl-string-translate " " "," (vl-princ-to-string LyrLst)))))))
        (progn
          (princ "\nBase point: ") (vl-cmdf "_.STRETCH" Ss_Tot "" "\\") (princ "\nSecond point: ") (vl-cmdf "\\")
        )
        (princ "\nNo Objects to Stretch found in Crossing Window.")
      )
    )
  )
  (princ)
)

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Stretch Mleader
« Reply #15 on: September 19, 2017, 03:14:22 PM »

In Bricscad is not possible to stretch with "closed" Windows (x p1 = x p2) for perpendicular lines, see:  (Bricscad need a Window outside end point):
Code: [Select]
(defun C:ALE_Edit_StretchMleaders ( / Pnt001 Pnt002 Ss_Str)
  (if

    (and
      (setq Pnt001 (getpoint "\nSpecify first corner of Crossing Window (Start point of Stretch): "))
      (setq Pnt002 (getcorner Pnt001 "\nSpecify opposite corner (Bricscad need a Window outside end point): "))
    )
    (if (setq Ss_Str (ssget "_C" Pnt001 Pnt002 '((0 . "MULTILEADER"))))
      (progn (princ "\nSecond point: ") (vl-cmdf "_.STRETCH" Ss_Str "" "_NONE" Pnt001 "\\"))
      (princ "\nNo Multileaders found in Crossing Window.")
    )
  )
  (princ)
)

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Stretch Mleader
« Reply #16 on: September 20, 2017, 01:51:32 PM »
Just thinking outloud, haven't written any code yet, but how about this idea?

  • Enter command
  • Select line to stretch using nEntsel
  • Create a stretch window based on the boundary of the object, see Lee Mac's Bounding Box function: http://www.lee-mac.com/boundingbox.html
  • Filter to only included the selected leader
  • Stretch as applicable

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Stretch Mleader
« Reply #17 on: September 20, 2017, 03:51:31 PM »
Just thinking outloud, haven't written any code yet, but how about this idea?

  • Enter command
  • Select line to stretch using nEntsel
  • Create a stretch window based on the boundary of the object, see Lee Mac's Bounding Box function: http://www.lee-mac.com/boundingbox.html
  • Filter to only included the selected leader
  • Stretch as applicable
I had thought of this solution but maybe not so simple, if i use NENTSEL on my MULTILEADER I get:
Code: [Select]
(
   (-1 . <Nome entità: 7ff7bd02ef00>)
   (0 . "MULTILEADER")
   (5 . "70328")
   (102 . "{ACAD_REACTORS")
   (330 . <Nome entità: 7ff7bd02ef50>)
   (102 . "}")
   (330 . <Nome entità: 7ff7bd211820>)
   (100 . "AcDbEntity")
   (67 . 0)
   (410 . "Model")
   (8 . "$PRC_NORM")
   (100 . "AcDbMLeader")
   (270 . 2)
   (300 . "CONTEXT_DATA{")
   (40 . 25.0)
   (10 100253.0 -4310.54 0.0)
   (41 . 100.0)
   (140 . 100.0)
   (145 . 50.0)
   (174 . 1)
   (175 . 6)
   (176 . 0)
   (177 . 0)
   (290 . 0)
   (296 . 1)
   (341 . <Nome entità: 7ff7bd02ebe0>)
   (14 0.0 0.0 1.0)
   (15 100678.0 -4345.54 0.0)
   (16 25.0 25.0 25.0)
   (46 . 0.0)
   (93 . -1073741824)
   (47 . 25.0)
   (47 . 0.0)
   (47 . 0.0)
   (47 . 0.0)
   (47 . 0.0)
   (47 . 25.0)
   (47 . 0.0)
   (47 . 0.0)
   (47 . 0.0)
   (47 . 0.0)
   (47 . 25.0)
   (47 . 0.0)
   (47 . 0.0)
   (47 . 0.0)
   (47 . 0.0)
   (47 . 1.0)
   (110 100678.0 -4345.54 0.0)
   (111 1.0 0.0 0.0)
   (112 0.0 1.0 0.0)
   (297 . 0)
   (302 . "LEADER{")
   (290 . 1)
   (291 . 1)
   (10 101153.0 -4310.54 0.0)
   (11 -1.0 0.0 0.0)
   (90 . 0)
   (40 . 50.0)
   (304 . "LEADER_LINE{")
   (10 102568.0 -4770.16 0.0)
   (10 102568.0 -4310.54 0.0)
   (91 . 0)
   (170 . 1)
   (92 . -1056964608)
   (340 . <Nome entità: 0>)
   (171 . -2)
   (40 . 0.0)
   (341 . <Nome entità: 0>)
   (93 . 0)
   (305 . "}")
   (271 . 0)
   (303 . "}")
   (272 . 9)
   (273 . 9)
   (301 . "}")
   (340 . <Nome entità: 7ff7bd02ec80>)
   (90 . 6816768)
   (170 . 1)
   (91 . -1023410155)
   (341 . <Nome entità: 7ff7bd2119e0>)
   (171 . -2)
   (290 . 1)
   (291 . 1)
   (41 . 2.0)
   (342 . <Nome entità: 7ff7bd02c4a0>)
   (42 . 4.0)
   (172 . 1)
   (343 . <Nome entità: 7ff7bd2119c0>)
   (173 . 1)
   (95 . 6)
   (174 . 1)
   (175 . 0)
   (92 . -1056964608)
   (292 . 0)
   (344 . <Nome entità: 7ff7bd02ebe0>)
   (93 . -1056964608)
   (10 1.0 1.0 1.0)
   (43 . 0.0)
   (176 . 0)
   (293 . 0)
   (330 . <Nome entità: 7ff7bd02ec40>)
   (177 . 1)
   (44 . 0.0)
   (302 . "80401")
   (330 . <Nome entità: 7ff7bd02ec50>)
   (177 . 2)
   (44 . 0.0)
   (302 . "")
   (294 . 0)
   (178 . 0)
   (179 . 1)
   (45 . 25.0)
   (271 . 0)
   (272 . 9)
   (273 . 9)
   (295 . 1)
)



cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Stretch Mleader
« Reply #18 on: October 02, 2017, 07:55:35 PM »
It is possible to get the coordinates, I have a command that liens up leaders, so it is possible, my code at: https://www.theswamp.org/index.php?topic=46576.msg516569#msg516569

It has been a while since I have updated it, so I am sure there are bugs in the code at this point, but it should give you a jumping off point at least.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Stretch Mleader
« Reply #19 on: October 03, 2017, 07:42:33 AM »
It is possible to get the coordinates, I have a command that liens up leaders, so it is possible, my code at: https://www.theswamp.org/index.php?topic=46576.msg516569#msg516569

It has been a while since I have updated it, so I am sure there are bugs in the code at this point, but it should give you a jumping off point at least.
Thanks for the answer, I need some time to examine your code...  :?

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Stretch Mleader
« Reply #20 on: October 23, 2017, 12:09:04 PM »

It is possible to get the coordinates, I have a command that liens up leaders, so it is possible, my code at: https://www.theswamp.org/index.php?topic=46576.msg516569#msg516569

It has been a while since I have updated it, so I am sure there are bugs in the code at this point, but it should give you a jumping off point at least.
Sorry for delay...


I have modified this:
(command "._-layer" "_n" "LEADER" "_color" "_WHITE" "" "_lweight" "DEFAULT" "" "_ltype" "CONTINUOUS" "" "")
(command "._-layer" "_n" "LEADER" "_color" "_WHITE" "" "_lweight" "DEFAULT" "" "_ltype" "CONTINUOUS" "" "_pstyle" "BLACK" "" "")
(command "._mleaderalign" SS "" "_O" "_P" ML)
for my italian version, but I still have errors:
Code: [Select]
Comando: L2M

Traccia all'indietro:
[0.48] (VL-BT)
[1.44] (ERRDUMP "tipo di argomento errato: numberp: nil")
[2.39] (_call-err-hook #<SUBR @00000000374a9548 ERRDUMP> "tipo di argomento errato: numberp: nil")
[3.33] (sys-error "tipo di argomento errato: numberp: nil")
:ERROR-BREAK.28 nil
[4.25] (+ nil 8)
[5.19] (C:L2M)
[6.15] (#<SUBR @0000000037705250 -rts_top->)
[7.12] (#<SUBR @00000000030f8700 veval-str-body> "(C:L2M)" T #<FILE internal>)
:CALLBACK-ENTRY.6 (:CALLBACK-ENTRY)
:ARQ-SUBR-CALLBACK.3 (nil 0)
Comando:
Comando: ul
** Error: tipo di argomento errato: numberp: nil **


cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Stretch Mleader
« Reply #21 on: October 24, 2017, 04:35:07 PM »
Sorry, I was out on vacation, it looks like you are calling the L2M command, that is designed to convert lines and text to leaders, sorry I forgot there are multiple commands, look more at the UL command within that file.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Stretch Mleader
« Reply #22 on: October 25, 2017, 02:46:04 AM »

Sorry, I was out on vacation, it looks like you are calling the L2M command, that is designed to convert lines and text to leaders, sorry I forgot there are multiple commands, look more at the UL command within that file.
I have tested also UL:
Comando: UL
** Error: tipo di argomento errato: numberp: nil **

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Stretch Mleader
« Reply #23 on: October 25, 2017, 04:23:40 PM »
How strange, it works ok on my system (English admittedly, but there shouldn't be anything language dependent).

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Stretch Mleader
« Reply #24 on: October 26, 2017, 04:40:54 AM »

How strange, it works ok on my system (English admittedly, but there shouldn't be anything language dependent).
I have found the error on Lines: 575 and 1211
Code: [Select]
(setq  *path* (getvar "dwgprefix"))
(setq pos (vl-string-position (ascii "\\") *Path* (+ (vl-string-position (ascii "\\") *path* 5) 1)))


Comando: (setq  *path* (getvar "dwgprefix"))
"Z:\\Temp\\"


Comando: (setq pos (vl-string-position (ascii "\\") *Path* (+ (vl-string-position (ascii "\\") *path* 5) 1)))
nil


pos is nil so in
(If (or (= (strcase (substr *path* (+ pos 8) 1)) "C") (= (getvar "USERS5") "CIVIL"))
(+ nil 8) > ** Error: tipo di argomento errato: numberp: nil **

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Stretch Mleader
« Reply #25 on: October 26, 2017, 04:48:00 PM »
Hmm, that would mean you don't have a \ in your drawing path? How is that possible?

But try adding something like the following after that line and see if it works then for you:
Code: [Select]
(if (= pos nil)
(setq pos 1)
)

or change the line:
Code: [Select]
(If (or (= (strcase (substr *path* (+ pos 8) 1)) "C") (= (getvar "USERS5") "CIVIL"))To:
Code: [Select]
(if (/= pos nil)
(If (or (= (strcase (substr *path* (+ pos 8) 1)) "C") (= (getvar "USERS5") "CIVIL"))
)

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Stretch Mleader
« Reply #26 on: October 27, 2017, 02:26:46 AM »

Hmm, that would mean you don't have a \ in your drawing path? How is that possible?

...
I have a path, read my post:
>>> Comando: (setq  *path* (getvar "dwgprefix"))
"Z:\\Temp\\"

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Stretch Mleader
« Reply #27 on: October 27, 2017, 01:18:41 PM »
So, what would cause POS to be set to nil in that line then? It should set it to the position of the \

What am I missing? Any ideas?

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Stretch Mleader
« Reply #28 on: October 27, 2017, 01:26:35 PM »
So, what would cause POS to be set to nil in that line then? It should set it to the position of the \

What am I missing? Any ideas?

Because vl-string-position is instructed to look for a backlash at position 5 onwards (which in this case returns the last backlash at position 7); and then vl-string-position is instructed to look for a backslash at position 8 (which returns nil):
Code - Auto/Visual Lisp: [Select]
  1. _$ (setq *path* "Z:\\temp\\")
  2. "Z:\\temp\\"
  3. _$ (setq pos (vl-string-position (ascii "\\") *path* (+ (vl-string-position (ascii "\\") *path* 5) 1)))
  4. nil
  5. _$ (vl-string-position (ascii "\\") *path* 5)
  6. 7
  7. _$ (vl-string-position (ascii "\\") *path* 8)
  8. nil


Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Stretch Mleader
« Reply #30 on: October 28, 2017, 10:49:40 AM »

So, what would cause POS to be set to nil in that line then? It should set it to the position of the \

What am I missing? Any ideas?
I have removed these lines:
Code: [Select]
(If (> (strlen *path*) 5)
  (progn
   (setq pos (vl-string-position (ascii "\\") *Path* (+ (vl-string-position (ascii "\\") *path* 5) 1)))
   (If (or (= (strcase (substr *path* (+ pos 1)) "C") (= (getvar "USERS5") "CIVIL"))
     (setq *IsCivil* T)
   )
  )
 )
but I can not make it work:

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Stretch Mleader
« Reply #31 on: October 30, 2017, 12:54:07 PM »
Because it is meant to line up the leaders, you need to click on one of the leaders that you want to line up to the selected leader. My point was that you could look at this code to see how I accomplished this so that you could incorporate that into your own code for stretching the leader.

You can see the attached GIF for an example of how it works.
« Last Edit: October 30, 2017, 12:57:40 PM by cmwade77 »

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Stretch Mleader
« Reply #32 on: November 03, 2017, 05:52:06 AM »
D
id you try with my Mleader.dwg on post #0?

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Stretch Mleader
« Reply #33 on: November 03, 2017, 01:05:04 PM »
Honestly, I am not sure, I would have to look at the mleader style definition in the drawing you are testing with, as I haven't tested with anything quite like that one, but I think that is getting off topic here, I would post that question back in the original thread, as I said, my point of linking to it was so you could see how to get the points of the mleader.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Stretch Mleader
« Reply #34 on: November 03, 2017, 01:33:30 PM »
Honestly, I am not sure, I would have to look at the mleader style definition in the drawing you are testing with, as I haven't tested with anything quite like that one, but I think that is getting off topic here, I would post that question back in the original thread, as I said, my point of linking to it was so you could see how to get the points of the mleader.
Ok, thanks.  :)