rcb007 Posted March 18, 2021 Posted March 18, 2021 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. Quote
BIGAL Posted March 19, 2021 Posted March 19, 2021 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. 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 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))) ) 1 Quote
Dadgad Posted March 19, 2021 Posted March 19, 2021 (edited) 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. Edited March 19, 2021 by Dadgad typo Quote
BIGAL Posted March 19, 2021 Posted March 19, 2021 (edited) 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 March 22, 2021 by BIGAL 1 Quote
rcb007 Posted March 19, 2021 Author Posted March 19, 2021 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. Quote
rcb007 Posted March 19, 2021 Author Posted March 19, 2021 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. Quote
BIGAL Posted March 20, 2021 Posted March 20, 2021 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. Quote
rcb007 Posted March 22, 2021 Author Posted March 22, 2021 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 Quote
BIGAL Posted March 22, 2021 Posted March 22, 2021 (edited) 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. Edited March 22, 2021 by BIGAL 1 Quote
rcb007 Posted March 23, 2021 Author Posted March 23, 2021 This rocks! thank you so much! Just tested it and I can see the same results that you have! Quote
BIGAL Posted March 23, 2021 Posted March 23, 2021 (edited) 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 March 23, 2021 by BIGAL Quote
rcb007 Posted March 24, 2021 Author Posted March 24, 2021 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. Quote
BIGAL Posted March 24, 2021 Posted March 24, 2021 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. Quote
rcb007 Posted March 29, 2021 Author Posted March 29, 2021 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 Quote
Dadgad Posted March 29, 2021 Posted March 29, 2021 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. Quote
rcb007 Posted March 29, 2021 Author Posted March 29, 2021 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.;) Quote
BIGAL Posted March 30, 2021 Posted March 30, 2021 (edited) 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 March 30, 2021 by BIGAL Quote
rcb007 Posted March 30, 2021 Author Posted March 30, 2021 I think i follow you on this. Thank you for sharing the trick! Quote
BIGAL Posted March 31, 2021 Posted March 31, 2021 I changed it and forgot to post see update above. Quote
Recommended Posts
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.