Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/16/2022 in all areas

  1. Give this a try ;;----------------------------------------------------------------------------;; ;; Condence Drawing to one layer (defun C:OOF (/ SS) (setq SS (ssget "_X" '((410 . "Model")))) ;select everything in model space ;change selection set SS to current layer and color to bylayer (vl-cmdf "_Chprop" SS "" "LA" (getvar 'clayer) "C" "Bylayer" "") (repeat 3 (vl-cmdf "_.Purge" "A" "*" "N")) ;purge 3 times (princ) )
    3 points
  2. Just spent most of today wrestling with and trying to find examples of: Extracting single character From Drawing Name. I needed the 7th character of the Autocad drawing name to use as a conditional. Per standards, it will always be either the letter A or the number 0 (zero). IF 7th character is A, run program 1. ELSE run program 2. As simple as that. But I couldn't find examples of or figure how to extract a drawing name character. Then I thought, maybe, I could put spaces between the drawing name characters. That would make it a list and I could use: (nth 6 '(0 1 2 3 4 5 A 7 )) after removing the ".dwg" with: (setq dname (getvar "DWGNAME")); get drawing name (setq strleg (strlen dname)) ; get the length of it (setq strleg1 (- strleg 4)) ; hack off the last 4 characters (setq drawname (substr dname 1 strleg1)) ; what's left? But I couldn't find instructions or an example of making that happen, either. Then I remembered an old program to display the outline of named views. Just coincidentally, our one Model Space named view is the drawing name without the .DWG. The program finds the named view using: (setq vname (strcase (dxf 2 tbdata))) ;extract view name (if (wcmatch vname "??????A*"); ? = any single character (OutlineTheBorder)) so after some thievery and a quick and easy modification to: (if (wcmatch (getvar "DWGNAME") "??????A*") ;IF this (PROGRAM-1) ; THEN do this (PROGRAM-2) ; ELSE do this ) (There won't always be a named view, but there will always be DWGNAME.) Works like a charm. So in the end: 1. I didn't need to extract from the drawing name, although I really wanted to use that method. 2. I didn't need to convert the drawing name to a list, if that's even possible, to use the nth thingy. That would have been a neat, but convoluted and unconventional way to do it. 3. After trying too hard most of the day, the answer turned out to be simple and something I already had examples of. All I needed was wcmatch. Just wanted to share, and hope this is helpful info. Thanks for listening, Steve
    2 points
  3. here are three (vla-load (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object))) "LineTypeName" "FileName.lin" ) http://www.lee-mac.com/loadlinetype.html
    2 points
  4. Saying up too late. I misplaced at ) will work now. --edit You fixed it already. Do you have two instances of autocad open? one has read/write permisson for TEXTFILE.TXT and the other your tying to use the code? if not restart autocad because this might be where StevenP was saying if you exit the lisp before close it would error. if you ran it with the misplaced )
    1 point
  5. Beaten to it by MHUPP... but you have done all the hard work by writing out the process you want to follow - an internet search would give you all the components of what you want to do and then all you need is to put it all together. OK might not be as pretty as above, but it should work out. Might want to add something like this https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/change-all-to-0-layer-by-layer-including-block-and-block-in/td-p/5376995 to set all block contents to layer 0, with options from KentClark and Lee Mac - I tend to favour Lees code through experience it works well.
    1 point
  6. Yes sometimes we over think things and do things that are not necessary, I'm glad you found a solution after all, but maybe this could be easier (if (= (substr (getvar 'dwgname) 7 1) "a") ;;; Then ... Maybe you could have asked there are so many great people here that can help you and with so many post we keep learning a lot.
    1 point
  7. The struggle was real for me starting out. what helped me was being a lurker on these forums for a long time. Come here daily and reading over most posts. Then I would test out code posted to see what its doing. After a while things just started to click. The stuff I liked (even if it was a little snippet) I would put into a text file with a description. can't tell you how many times I needing it months later. like this Strips the extension off the filename (setq fn (vl-filename-base (getvar 'dwgname))) Depending on what program-2 does their is a third option for the file name and might want to use a conditional statement. https://www.afralisp.net/autolisp/tutorials/cond-vs-if.php (cond ((wcmatch (getvar "DWGNAME") "??????A*") ;IF this A ;((eq (vl-string-position (ascii "A") (getvar "DWGNAME") 6) 6) ;is the 7th position char A in this string returns 6 if true (PROGRAM-1) ; THEN do this ) ((wcmatch (getvar "DWGNAME") "??????#*") ;IF this # (PROGRAM-2) ; THEN do this ) (t ;if nither option 1 or option 2 are true do this (alert "Drawing name doesn't match Standards") ) ) --edit need (vl-load-com) at the start of your lisp for visual lisp code to work
    1 point
  8. Why not just enter EX to select & extend the red line, then shift+select to trim the yellow one?
    1 point
  9. I explain the difference in my post here: http://www.theswamp.org/index.php?topic=44700.msg499322#msg499322
    1 point
  10. I invite you to consult Olivier Eckmann's proposal on the AutocadMap3D forum, his plugin installed, you will have access to the MQSELECT command which allows you to make filtered selections on Map object data. The general subject of the post is also interesting to consult...
    1 point
  11. Hello Have to do a job that involves around 3000 loops + 2500 connection diagrams & IO-lists. Bottom line was, either I do it in half of the time and half of the money or else... (the job goes overseas) For example a loop diagram has a transmitter , connected to a Junction Box , then to a control panel + IO panel. Loops have to be made as-built (update revision, remove clouds etc). Ok already have an app for that. But I also have to check each loop against JB and CP channel (oh crap...) So I came up with the idea to first read all the titleblock titles in the project folder and save this to a (txt) file. Then, having the loop open in AutoCad , I wanted to be able to either type in part of the title in the search list box or select the JB or CP symbol and open the drawing. And that's when I decided to create my very own BFF (Bulk File Finder) App is still in its beta but so far it seems to be doing what I hoped it to do. (but some little points may yet come to surface , but hey , baby is only one weekend old so gimme a break) Make sure you put in (1) blockname of your (title)block , (2) name(s) of attributes with the titles in it, separated by comma's , (3) select your drawing source folder and (4) choose create (don't forget to save it afterwards) In the top left listbox (green) you can put in some search strings and you can also save this. When all this is done and you press ok , it should find all the drawing (titles) matching the search criterea. Some of the Select and Find buttons (purple section) are not working yet because those will involve some company special ops. Most of my time went into the interface and progress bar thats activated when scanning for folders, drawings & titles. Maybe it will be helpfull to others , maybe not because it might be too specific to my own situation but I present it on an as-it-is basis and because its been a while I posted something and posting on CadTutor seems to be getting rarer. If its not working or helpfull : trashcan , yes you can , because of my workload I don't have much time to do user request's RlxMyBFF.lsp
    1 point
×
×
  • Create New...