Jump to content

Blocks to MLeader Styles


rcb007

Recommended Posts

I have a ton of blocks that are traffic signs. Each block has the traffic sign name. I did not know if there is a routine that can help take each block and turn it into a mleader style, where the mleader style name is the name of the block.

 

Thank you for any direction! I am hoping that i dont have to do them manually! lol.

Link to comment
Share on other sites

I am lucky and here in AUS we have HFS fonts hundreds of traffic signs as TTF so a stop sign is say "A" using correct font.

image.thumb.png.073f49d276afb4eda9c26c94ccff3367.png

 

Anyway back to question, there may be a way of using a reactor to run a lisp that creates a mleader but puts correct block as answer. You would type say TSTOP or tgiveway tchevron1 I have used this before for doing offset fillet circles plus some other stuff Block insert is Bblockname. The reactor detects the error TSTOP is invalid command and pulls it apart so would know the block name is "STOP"

 

I dont think making hundreds of mleaders styles is the way to go. Have you looked at selecting the sign from a dcl

 

image.png.bf8e06a811c66b3b101d2b723150b080.png

Here is the reactor code you could have a go using "T" rather than "F" will have a think about a mleader. You need to rewrite the defun filletrad for a mleader.

 

; Fillet rad uses Frad eg f100 puls the 100 from the F and then runs fillet
; BY Alan H 2015
; great assistance from Lee-mac to make it work.

(   (lambda nil
        (vl-load-com)
        (foreach obj (cdar (vlr-reactors :vlr-command-reactor))
            (if (= "fillet-reactor" (vlr-data obj))
                (vlr-remove obj)
            )
        )
        (vlr-command-reactor "fillet-reactor" '((:vlr-unknowncommand . fillet-reactor-callback)))
    )
)

(defun filletrad ( / rad)
(setq rad (distof (substr com 2) 2))
            (if (<= 0.0 rad)
              (progn        
              (setvar 'filletrad rad)
              (vla-sendcommand fillet-reactor-acdoc "_.fillet ")
              )
              ) 
)

(defun fillet-reactor-callback ( obj com )
(setq com (vl-string-translate "-" "." (strcase (car com))))
    (cond   
        (   (and
            (wcmatch com "~*[~F.0-9]*")
            (wcmatch com "F*")
            (wcmatch com "~F*F*")
            (wcmatch com "~*.*.*")
            ) ; and
            (filletrad) 
         ) 
    ) ; master cond
) ; defun

(or fillet-reactor-acdoc
    (setq fillet-reactor-acdoc (vla-get-activedocument (vlax-get-acad-object)))
)

 

  • Like 1
Link to comment
Share on other sites

The blocks can be used as Default content in the MULTILEADER STYLE dialog.

Please don't be confused by the Spline leader displayed in the screenshot.

That is the one I use for leaders in my work, changes are available on the Leader Format & Leader Structure Tabs.

 

Having just reread your original post, it sounds like this is functionality of which you are already aware.

BIGAL may well be onto something, with his alternate approach.  He has history with

this sort of work, whereas I do not.  :beer:

 

image.thumb.png.925ffc96791e6111272d7d1776499a39.png

Edited by Dadgad
typo
Link to comment
Share on other sites

Hi guys try this just type tblockname uses current mleader style. It uses the first character so could have 52 reactors pretty easy. A is not a.

 

Examples  type  T001, Tnorth, tstop a couple of probs space in block name and does it exist.

 

So that is fillet, circle, offset, copy project and now blocks. It really comes down to how to trap errors, if you type say a user command wrong testisssthisreport it will try to use that description as a block name.

; Big thanks to lee-mac for making it work.
; mlblk uses block name  pulls the name  from the T or t and then runs mlblk
; BY Alan H 2021


(   (lambda nil
        (vl-load-com)
        (foreach obj (cdar (vlr-reactors :vlr-command-reactor))
            (if (= "mlblk-reactor" (vlr-data obj))
                (vlr-remove obj)
            )
        )
        (vlr-command-reactor "mlblk-reactor" '((:vlr-unknowncommand . mlblk-reactor-callback)))
    )
)

(defun mlblk( / str)
  (setq bname (substr (nth 0 com) 2) )
  (if (not (tblsearch "block" bname))
    (alert "no block by that name")
  (progn
    (setq pt1 (getpoint "\nPick landing point ") pt2 (getpoint pt1 "\nPick next point "))
    (setq str (strcat "mLeader _O _C _B " bname (chr 13) "exit !pt1" (chr 13) "!pt2" (chr 13)))
    (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) str)
  )
  )
)


(defun mlblk-reactor-callback ( obj com )
    ( if (= (wcmatch (strcase (car com)) "T*") T)(mlblk ) )
) ; defun

(or mlblk-reactor-acdoc
    (setq mlblk-reactor-acdoc (vla-get-activedocument (vlax-get-acad-object)))
)

 

Edited by BIGAL
  • Thanks 1
Link to comment
Share on other sites

Thank you for sharing this guys! Just another thing i wanted to share. The reason for the Mleaders, is because we want the block Mleader to be Annotative. Its nice when we have the standard scale, and then need to make a larger scale drawing where we just adjust the viewport and then all the blocks mleaders agjust to the scale. Also, We usually use the Leader piece pointing to the location on the Plan. 

 

I hope that makes some sense. But for us, its an easy way to put the plan together.

Link to comment
Share on other sites

Gotta question for you if you dont mind. I started a blank dwg, Created a block called "stop" with text in it. I then dragged the routine in, and typed "tstop". Not sure if i did something wrong with the command reject of _.Mleader or not. But again, thank you.

 

Command: tstop
Pick landing point
Pick next point ; error: AutoCAD command rejected: "_.Mleader"
Unknown command "TSTOP".  Press F1 for help.

 

Link to comment
Share on other sites

It was working so I am not sure why it stopped tested in Bricscad and works fine. Did test also in Autocad will go back and work out why not working today. 

 

I have updated code above it was definitely working yesterday in Autocad. 

 

Blocks can not have spaces in name but there is a way around that, let me know if it is an issue.

 

 

 

 

Link to comment
Share on other sites

I did some testing this morning. I am still getting the same results within Civil3D 2020. I tried the same thing in Civil3D 2018 and Civil3D 2018 as AutoCAD.

I started a new blank Out of the box AutoCAD template. I made sure the current MLeader Style was standard, with Standard text. I created a new block name stop. I ran the routine with a "tstop" and still getting the Autocad command rejected: "_.Mleader". Unknown command "tstop". 

 

Is it possible that i may have setting with my setup that will not allow reactors to work? That is the only this i can think of, that would possibly giving me the error that i see.

 

thanks again and i am not trying to be pain! lol

 

 

Link to comment
Share on other sites

I have double checked the updated code is definitely their now and uses the vla-sendcommand method, not sure why it did not update before I must have clicked wrong button or something, tested in Autocad and Bricscad.

 

Bricscad can be a bit more forgiving when coding and often works where Autocad does not.

 

image.thumb.png.6adc00965d04b8eede8cea21b3a02c5f.png

Edited by BIGAL
  • Like 1
Link to comment
Share on other sites

Glad its working now. If you have blocks with space in name let me know there is a workaround. I did not play with setting mleader style I think that can be added and improve the final product.

Edited by BIGAL
Link to comment
Share on other sites

Right now, the blocks names have a (-) as a spacer. I guess it would make sense to remove the (-) dash and just use a space if possible. I would agree that i think it would improve like you said.

Link to comment
Share on other sites

The - or _ is ok, dont put a space the issue is that Tblock 1 will not work it will stop at Tblock and ignore the " 1". 

 

If you have blocks like Tree 1, Tree 2, Tree 3 there is a work around for the space in the block name. So it will recognize those block names. For any one just post request very simple answer.

Link to comment
Share on other sites

I ran into an issue with a block name as "Water PIV Structure". Could i ask what the simple answer is please? lol. Again, thank you

Link to comment
Share on other sites

It sounds like BIGAL has told you not to use a SPACE in the name of the block, that there may be a workaround,

as yet unsubstantiated.  :|

Link to comment
Share on other sites

I did not know if he was hinting at something else. But worse case scenario is to add "-" or "_" for the spaces within the block name.;)

Link to comment
Share on other sites

Ok there is a simple way around it when using the reactor for circles you may want a decimal value 123.45 so C123.45 errors but autocad detects the period again much like the space so the work around for the circle option was a simple type 123-45 the - meaning decimal.

 

(setq com (vl-string-translate "-" "." (strcase (car com)))) so this would change the error value from 123-45 to 123.45 

 

So for block names with a space must use something else in name "Water PIV Structure" maybe "WaterxPIVxStructure" then 

 

(setq com (vl-string-translate " " "X" (strcase (car com))))

 

Whilst I have suggested "x" as an example its probably better to use a non alpha character one of !@#$%^&*() will have a play.

 

; mlblk uses block name  pulls the name  from the T or t and then runs mlblk
; BY Alan H 2021

last minute check

 

Edited by BIGAL
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...