Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/27/2023 in all areas

  1. Just quickly searches through table listing and returns all that is found... if you put a * in the search term as a wild card too.... (defun c:testthis( / MyLayersList acount result ) (defun Table (s / d r) (while (setq d (tblnext s (null d))) (setq r (cons (cdr (assoc 2 d)) r)) ) ) (setq result (list)) ; make a blank list (setq MyLayersList (Table "layer") ) ; get list of all layers (setq Mystring (getstring "\nEnter Seach term" T)) (setq acount 0) (while ( < acount (length MyLayersList)) (if (= (wcmatch (nth acount MyLayersList) Mystring) nil) (princ "\n not Matched") (setq result (append result (list (nth acount MyLayersList)) )) ) ; end if (setq acount (+ acount 1)) ) ; end while result ) Might need to do a loop from the result to rename the layers? ... and because dinner is still cooking, the same thing with a foreach loop (slightly shorter code) (defun c:testthis( / MyLayersList result ) (defun Table (s / d r) (while (setq d (tblnext s (null d))) (setq r (cons (cdr (assoc 2 d)) r)) ) ) (setq result (list)) ; make a blank list (setq MyLayersList (Table "layer") ) ; get list of all layers (setq Mystring (getstring "\nEnter Seach term" T)) (foreach x MyLayersList (if (= (wcmatch x Mystring) nil) (princ "\n not Matched") (setq result (append result (list x) )) ) ; end if ) ; for each result )
    2 points
  2. A couple of simple changes. (setq val (getint "\nNew scale - Enter = 50 ")) (if (= val nil) (setq val 50)) (command "_.cannoscale" (strcat "1\" =" (rtos val 2 0) "'")) (command "_.zoom" "scale" (strcat "1/" (rtos val 2 0) "xp")) version 2 this will pop a dcl without you doing any code. (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (setq ans (atoi (ah:butts 3 "V" '("Choose a scale" "10" "20" "50" "100" "200" "250" "500" )))) ; ans holds the button picked as an integer value Multi radio buttons.lsp
    2 points
  3. Yeah, I will do, i'm just finishing up for the evening but i'll try to adapt it over the weekend edit: I got this to work for my needs Changed (setq MyLayersList (Table "layer") ) ; get list of all layers To setq MyBlocksList (Table "Block") ) ; get list of all Blocks And (setq Mystring (getstring "\nEnter Seach term" T)) To (setq Mystring "Chamfer*") ; at tthe moment, this is all i need, so rather than keep typing it in.. And then adding (foreach x result (COMMAND ".-INSERT" x "E" "Y" "S" "1" "R" "0" "0,0") ) I agree, it is the best way to learn. I'm getting comfortable now being able to edit to suit my needs. I do however struggle to think of the best approach when creating my own from scratch. They tend to start off very large and cumbersome, and as I learn or see how someone else has tackled a similar issue, I go back and make them more efficient. Thanks again guys for the help (sorry Quinnl, for joining in on this, i hope you get what you need... these guys are awesome)
    1 point
  4. Try it and see... (seriously... it is the best way to learn! and is all I would be doing anyway)
    1 point
  5. I like this StephenP... I've had a similar issue but slightly different with layer naming issues, this will help a lot. Also... Just to make sure i'm reading this code correctly (still new to this coding game) Am I right, that this could be modified to search the "Blocks" table? , and, if i entered Chamfer* (for example) into the search term i could then, after another tweak, using the foreach, have it insert all blocks starting with chamfer (eg chamfer1204, chamfer 2306 etc)
    1 point
  6. Not In BricsCAD, but try it out in AutoCAD. : (tblsearch "layer" "Te*") nil : (tblsearch "layer" "Test") ((0 . "LAYER") (2 . "Test") (70 . 0) (62 . 2) (6 . "Continuous"))
    1 point
  7. A simple way is rather than pick two plines drag a line over and like marko_ribar use intersectwith and compare start and end points to intersect point so if not near say start point swap start and end points. You imply which is start end of the two lines. An example using pick point. (setq tp1 (entsel "\nSelect left side inner wall near end : ")) (setq tpp1 (entget (car tp1))) (setq pt1 (cdr (assoc 10 tpp1))) (setq pt2 (cdr (assoc 11 tpp1))) (setq pt3 (cadr tp1)) (setq d1 (distance pt1 pt3)) (setq d2 (distance pt2 pt3)) (if (> d1 d2) (progn (setq temp pt1) (setq pt1 pt2) (setq pt2 temp) ) )
    1 point
  8. Like Steven P look for certain blocks, get their scale so you can set a window of length and height. You can get insertion point and for title blocks was lower left. Then use a plot window with correct scale. something like this designed for layout use. (cond ((= blkname "TITLE_BLOCK_A0_V4" )(setq sc "1=1" psize "ISO full bleed A1 (841.00 x 1189.00 MM)" ll "-6,-6" ur "1175,837" orien "Landscape")) ((= blkname "TITLE_BLOCK_A1_V4" )(setq sc "1=1" psize "ISO full bleed A1 (594.00 x 841.00 MM)" ll "-6,-6" ur "837,590" orien "Landscape")) ((= blkname "TITLE_BLOCK_A1PORT_V4" )(setq sc "1=1" psize "ISO full bleed A1 (594.00 x 841.00 MM)" ll "-6,-6" ur "577,823" orien "Portrait")) ((= blkname "TITLE_BLOCK_A2PORT_V4")(setq sc "1=1" psize "ISO full bleed A2 (420.00 x 594.00 MM)" ll "-6,-6" ur "416,591" orien "Portrait")) ((= blkname "TITLE_BLOCK_A3PORT_V4")(setq sc "1=1" psize "ISO expand A3 (297.00 x 420.00 MM)" ll "-3,-3" ur "280.4,403.5" orien "Portrait")) ((= blkname "TITLE_BLOCK_A4PORT_V4")(setq sc "1=1" psize "ISO full bleed A4 (210.00 x 297.00 MM)" ll "-6,-6" ur "206,293" orien "Portrait")) ((= blkname "TITLE_BLOCK_A1_V4")(setq sc "1=1" psize "ISO full bleed A1 (841.00 x 594.00 MM)" ll "-6,-6" ur "837,590" orien "Landscape")) ((= blkname "TITLE_BLOCK_A2_V3")(setq sc "1=1" psize "ISO full bleed A2 (594.00 x 420.00 MM)" ll "-6,-6" ur "590,416" orien "Landscape")) ((= blkname "TITLE_BLOCK_A3_V4")(setq sc "1=1" psize "ISO full bleed A3 (420.00 x 297.00 MM)" ll "-6,-6" ur "406.5,283.4" orien "Landscape")) ((= blkname "TITLE_BLOCK_A4_V4")(setq sc "1=1" psize "ISO full bleed A4 (297.00 x 210.00 MM)" ll "-6,-6" ur "293,206" orien "Landscape")) ) Again I would reccomend use layouts so much easier for this problem, I had 88 layouts one dwg. There is other code about making layouts like pick a point in model space and enter a scale and layout is made.
    1 point
  9. Building on what you have done., (setq text1 (cdr (assoc 1 (entget (car ent1))))) Will give you the text string (text 1 here), if you use other assoc numbers you can get the rest, then add them into the entmake mtext. For example: 8 for layer 62 for colour 40 for height 7 for style EDIT: Try this which will take the values from the text1 - see below from MHUPP, if they are different you might want to do some rule to work out what to use. Noting that the order you create an entity with can be important, you can view the entity description with (entget(car(entsel))) and select something - the command line will tell you what it all is and in the order that CAD likes (it isn't numerical order) (defun M-Text ( layer colour pt height str font / ) (entmakex (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 8 layer) (cons 62 colour) (cons 100 "AcDbMText") (cons 10 pt) (cons 40 height) (cons 1 str))) (cons 7 font) ) (defun c:comtext ( / ent1 MyEnt1 text1 layer colour height font ent2 text2 CombinedText point) (setq ent1 (entsel "\nSelect first text entity: ")) (setq MyEnt1 (entget (car ent1))) ;; (princ (setq text1 (cdr (assoc 1 (entget (car ent1))))) ) (princ (setq text1 (cdr (assoc 1 MyEnt1))) ) (setq layer (cdr (assoc 8 MyEnt1))) (setq colour (cdr (assoc 62 MyEnt1))) (setq height (cdr (assoc 40 MyEnt1))) (setq font (cdr (assoc 7 MyEnt1))) (setq ent2 (entsel "\nSelect second text entity: ")) (princ (setq text2 (cdr (assoc 1 (entget (car ent2))))) ) (princ (setq CombinedText (strcat text1 "\P" text2))) (princ (setq point (getpoint "\nSelect location for combined text: "))) (M-Text layer colour point height (strcat text1 "\P" text2) font) (princ) )
    1 point
  10. Look into the LAYTRANS command too. If you want to stick with the lisp it could be refactored like so to check if the source layer exists. (foreach layer '(("SL-PL" "XX-LOTS-LN") ("SL-BNDRY" "XX-SUB-BDY")) (if (tblsearch "LAYER" (car layer)) (command "_.RENAME" "_LAYER" (car layer) (cadr layer)) ) )
    1 point
  11. The option from Lee Mac here is a good start Make a list of the layers and loop through this
    1 point
×
×
  • Create New...