Search the Community
Showing results for tags 'block'.
-
Insert a block based upon search/found criteria?
ILoveMadoka posted a topic in AutoLISP, Visual LISP & DCL
Up til now I have had 3 separate routines for inserting a block based upon the existence of an inserted block in a drawing. (if (tblsearch "BLOCK" "BlockA") (command "-insert" "Block1" "0,0" "" "" "")) (if (tblsearch "BLOCK" "BlockB") (command "-insert" "Block2" "0,0" "" "" "")) (if (tblsearch "BLOCK" "BlockC") (command "-insert" "Block3" "0,0" "" "" "")) I was wanting to combine them into a single routine similar to this; (defun c:foo () (cond (if (tblsearch "BLOCK" "BlockA") (command "-insert" "Block1" "0,0" "" "" "")) (if (tblsearch "BLOCK" "BlockB") (command "-insert" "Block2" "0,0" "" "" "")) (if (tblsearch "BLOCK" "BlockC") (command "-insert" "Block3" "0,0" "" "" "")) ) (princ)) [Which does not work correctly BTW - it does not go beyond the first step] I also wondered "what if more than one block exists?" Ideally only one of these blocks "should" exist in a drawing in my situation. How can I test for the existence of more than one block first and return an error if found or insert the appropriate block meeting the criteria otherwise? I read about using wcmatch if I set (setq myblks (list "BlockA" "BlockB" "BlockC")) Not sure how to incorporate that if it is the better way I have pieces and parts but cannot put it together Help please.. ps: When using multiple searches, how to you proceed to the next search if the criteria is not met? (if (tblsearch "BLOCK" "BlockA") (command "-insert" "Block1" "0,0" "" "" "")) -
Insert a block at multiple points or lines and scale
grouch19 posted a topic in AutoLISP, Visual LISP & DCL
G'day all I'm working on and editing a mapping project from photogrammetry. I have a block which indicates a square manhole cover. (File is attached to this post) My project area has hundreds of these manholes and my client needs each of them scaled and rotated to fit the exact size of the manhole. I had been manually doing this with the help of an ECW image in the background. But the process is rather tedious and not all that accurate. My operators can pick up a three point string showing the height and length of the manhole. Some manholes are square and some are rectangular. I have a few lisp routines that get the block in there. The block insertion point comes in at the first plotted point as required. Is there any similar LISP that will insert the attached block dwg file at the first point collected and scale it based on the 2nd and third point whilst keeping the elevation heights? I've attached two dwg files... One is the block itself and one is a diagram with a better explanation. I've also added a screen shot of what is required. Any help would be appreciated Cheers guys Manhole.dwg BlockSample.dwg -
List variables to block attributes with lisp
Kris Malen posted a topic in AutoLISP, Visual LISP & DCL
Can someone help me out with changing the attributes of a block using a list. The block is used in a leader. The block has 7 attributes, but my list doesn't always contain 7 variables. I have tried to implement Lee Mac's code dynamicblockfunctions, but I keep getting the error "too few arguments". I would like to import the leader when the calculation is done, and for the block to then automatically change the attributes to the variables in the list. Here's my current code: (defun c:testKRIS ( / *error* dch dcl des mv d1 d2 d3 d4 d5 d6) (defun *error* ( msg ) (if (and (= 'int (type dch)) (< 0 dch)) (unload_dialog dch) ) (if (= 'file (type des)) (close des) ) (if (and (= 'str (type dcl)) (findfile dcl)) (vl-file-delete dcl) ) (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))) (princ (strcat "\nError: " msg)) ) (princ) ) (cond ( (not (setq dcl (vl-filename-mktemp nil nil ".dcl") des (open dcl "w") ) ) (princ "\nUnable to open DCL for writing.") ) ( (progn (foreach str '( "ed : edit_box" "{" " alignment = left;" " width = 20;" " edit_width = 10;" " fixed_width = true;" "}" "" "test : dialog" "{" " spacer;" " key = \"dcl\";" " : ed" " {" " key = \"mv\";" " label = \"MV:\";" " }" " :boxed_column { " " label = \"Diepte vd buizen\";" " :row {" " : ed" " {" " key = \"d1\";" " label = \"A:\";" " }" " : ed" " {" " key = \"d4\";" " label = \"X:\";" " }}" " :row {" " : ed" " {" " key = \"d2\";" " label = \"B:\";" " }" " : ed" " {" " key = \"d5\";" " label = \"Y:\";" " }}" " :row {" " : ed" " {" " key = \"d3\";" " label = \"C:\";" " }" " : ed" " {" " key = \"d6\";" " label = \"Z:\";" " }}" " }" " : boxed_row" " { " " label = \"BOK berekeningen\";" " :column {" " : ed { key = \"res\"; label = \"BOK:\"; is_enabled = false; }" " : ed { key = \"res2\"; label = \"BOK2:\"; is_enabled = false; }" " : ed { key = \"res3\"; label = \"BOK3:\"; is_enabled = false; }" " }" " :column{" " : ed { key = \"res4\"; label = \"BOK4:\"; is_enabled = false; }" " : ed { key = \"res5\"; label = \"BOK5:\"; is_enabled = false; }" " : ed { key = \"res6\"; label = \"BOK6:\"; is_enabled = false; }" " }" " }" " : button" " {" " key = \"cal\";" " label = \"Calculate\";" " }" " spacer;" " ok_only;" "}" ) (write-line str des) ) (setq des (close des) dch (load_dialog dcl) ) (<= dch 0) ) (princ "\nUnable to load DCL file.") ) ( (not (new_dialog "test" dch)) (princ "\nUnable to display 'test' dialog.") ) ( t (set_tile "dcl" "Calculate Area") (action_tile "mv" "(setq mv $value)") (action_tile "d1" "(setq d1 $value)") (action_tile "d2" "(setq d2 $value)") (action_tile "d3" "(setq d3 $value)") (action_tile "d4" "(setq d4 $value)") (action_tile "d5" "(setq d5 $value)") (action_tile "d6" "(setq d6 $value)") (action_tile "cal" (vl-prin1-to-string '( (lambda ( / m x y z a b c lijst_results ) (setq lijst_results '()) (set_tile "res" "") (set_tile "res2" "") (set_tile "res3" "") (set_tile "res4" "") (set_tile "res5" "") (set_tile "res6" "") (setq m (distof mv)) (if m (progn (setq lijst_results (append lijst_results (list (strcat "mv: " (rtos m 2 2))))) (if (and d1 (setq a (distof d1))) (progn (setq lijst_results (append lijst_results (list (strcat "A: " (rtos (- m a) 2 2))))) (set_tile "res" (rtos (- m a) 2 2)))) (if (and d2 (setq b (distof d2))) (progn (setq lijst_results (append lijst_results (list (strcat "B: " (rtos (- m b) 2 2))))) (set_tile "res2" (rtos (- m b) 2 2)))) (if (and d3 (setq c (distof d3))) (progn (setq lijst_results (append lijst_results (list (strcat "C: " (rtos (- m c) 2 2))))) (set_tile "res3" (rtos (- m c) 2 2)))) (if (and d4 (setq x (distof d4))) (progn (setq lijst_results (append lijst_results (list (strcat "X: " (rtos (- m x) 2 2))))) (set_tile "res4" (rtos (- m x) 2 2)))) (if (and d5 (setq y (distof d5))) (progn (setq lijst_results (append lijst_results (list (strcat "Y: " (rtos (- m y) 2 2))))) (set_tile "res5" (rtos (- m y) 2 2)))) (if (and d6 (setq z (distof d6))) (progn (setq lijst_results (append lijst_results (list (strcat "Z: " (rtos (- m z) 2 2))))) (set_tile "res6" (rtos (- m z) 2 2)))) (print lijst_results) ) (alert "Vul maaiveld waarden in.") ) ) ) ) ) (start_dialog) ) ) (*error* nil) (princ) ) -
Changing / Converting Points into Blocks / Objects
highguyuk posted a topic in AutoLISP, Visual LISP & DCL
Long time lurker and user of the site. Apologies my first post is a question rather than an answer but now I’ve made the leap of faith who knows the possibilities! I have a drawing with approx. 50 points in it. These points have been created from exporting a file from our MapInfo software into CAD format. Each of these points represents a feature (although everything contained within the drawing is just 1 feature) and I need to be able to attached a symbol (and then associated key) to define the feature when I xref in other similar drawings. I hope I described that ok. After some searching, I’m led to believe I need to use an LSP command/file/code etc.? I have no knowledge of anything LSP based, how to use it or where to begin. The instructions I’ve seen in other threads asking similar questions unfortunately go straight over my head. Could I ask is the LSP the only way to achieve my solution, and if so, is there a (very) basic step by step guide to using the LSP or could someone guide me through please? I understand that there is a need for full AutoCAD to perform this task – which I have access to if needbe.- 17 replies
-
- block
- converting
-
(and 2 more)
Tagged with:
-
Hello everyone, can anyone help me, I have a case example that is almost similar to the actual case I am experiencing now. In the 1st picture I have a shapefile of the administrative boundaries of the United States that I have entered into autocad, the shp attribute has been entered into the data object of each feature with the data object name "GADM", in the data object there are State and County fields, for the layer of each feature I use the County field reference so that each feature is currently layered with its respective county name. what I want is that as in the 2nd picture I want each feature to be grouped or made per block per category of state, is there a quick way, because I think in each feature there is a State field? Noted: The Autocad that I use is AutocadMap 2021. Pic 1 Pic 2
-
Hi, I am currently using Autocad 2011 and my block editor suddenly won't open this morning... I have tried the blockeditlock to open it but nothing happens when I change the setting (0 or 1). Have anyone ever had a problem like this one before? Please help!
-
autolisp writes the intersecting line layer name to the center of the block
bery35 posted a topic in AutoLISP, Visual LISP & DCL
Hi, I tried to write an autolisp code and I got to a certain point, but it is not working as I wanted. I would like your suggestions and your support in revising the code. What I want to do is select a block. To find out which character (n) from the right is the "-" sign in the layer name of the line touching the block I selected. Then subtract 1 from this character(n) number and add n-1 from the right. Combining the part up to the character and the prefix text and writing to the block geometric point. The way this code works now is to combine the front text and the text to the right of the "-" sign of the last layer added to the layer list and write it to the center of the block. This wasn't something I wanted. (setq *textHeight* 8) (setq *layerName* "01 Equipment list 2") (setq *textColor* 1) ; (defun c:bs_ayar () (setq *textHeight* (getreal "\nEnter new text height: ")) (setq *layerName* (getstring "\nEnter new layer name: ")) (setq *textColor* (getint "\nEnter new color index (1 for Magenta): ")) (princ (strcat "\nText height is now " (rtos *textHeight*) ", layer name is " *layerName* ", color is " (itoa *textColor*) " was set to. ")) (princ) ) (defun c:bs4 () (setq prefix (getstring T "\nEnter prefix letter: ")) (setq blk (car (entsel "\nSelect Block: "))) (setq blkEnt (entget blk)) (setq insPt (cdr (assoc 10 blkEnt))) (setq ss (ssget "_X" (list (cons 0 "LINE,POLYLINE")))) (if (and ss (> (sslength ss) 0)) (progn (setq line (ssname ss 0)) (setq lineEnt (entget line)) (setq lineLayer (cdr (assoc 8 lineEnt))) (setq dashPos (vl-string-search "-" lineLayer)) (if dashPos (setq rightPart (substr lineLayer (+ dashPos 2))) (setq rightPart lineLayer) ) (command "._-LAYER" "_M" *layerName* "" "_C" *textColor* "" "") (command "._TEXT" insPt *textHeight* "" (strcat prefix rightPart)) (command "._-LAYER" "_S" *layerName* "") ) (princ "\nNo line or polyline was found touching the selected block.") ) (princ) )-
- intersecting
- line
-
(and 2 more)
Tagged with:
-
Generating a "Table Row" block
DJAW posted a topic in AutoCAD 2D Drafting, Object Properties & Interface
Working to standardize a bill of material drawing that must consist of nothing more than text, lines, and blocks for a client that refuses to use datalinks and I was hoping to find a way to create a standard block that could act as a row in the table with cells containing text fields. Essentially, I would like to have the functionality of attribute definitions but have them copy down using some kind of array action. Has anyone had any luck/experience with something like this? I understand it's might be kind of impossible. Attached is what I'm hoping to have as default text in the newly generated row as the user pulls down the array arrow. -
Can't Find Layer Hidden In Unknown Block
"Mitch" posted a topic in AutoCAD Drawing Management & Output
I received a drawing that contains a layer in the manager box. But when I attempted to Quick Select that layer, the result returns as "0" and this same layer cannot be deleted, since the message tells me that layers with objects cannot be deleted. I thawed all layers and still get "0" and the layer won't delete. This should mean that the layer is hidden inside a block. This drawing has several hundreds of blocks! Is there an application within AutoCAD that will reveal to me which block that layer is in? -
Hi i want to develop commercial dynamic blocks, is there a way to protect them against piracy? Thanks S
-
Copy Multiple Block Attributes from one block to another one click
lamonmar posted a topic in AutoLISP, Visual LISP & DCL
I have a drawing that has two different blocks (see attached), what I needed to do was transfer over the attributes of one block over to the other (both have different tags). For example copying over attributes in "rev0_date" from the first block tag over to "revslot1date" in the second block tag , I ran across some code in the forums that did just that created by Lee Mac.The problem with it is it only transfers one attribute over, I modified it a little but its still not exactly what I need. The way it currently works is - It asks me to choose the first block with the attributes to copy, once selected it then asks me to choose the second block that will have the attributes pasted to it, once I've selected them, it then pastes the first specified tag attribute in the first block to the second, after that I have to repeat the process again, clicking the block with the attribute to copy and then choosing the second block to paste, I have to keep repeating these steps, clicking the first block then the second over and over until all the tag attributes have been copied over. My question is how can I stop having click the first and then second block over and over again for each tag and instead only have to go through the process once (click first block, then second and then transfer all the attributes over at once). Here is my current code (sorry if its a mess I'm very new to this): (defun c:blockswap ( / _SelectBlockWithTag a b des src tag ) (vl-load-com) (setq DAT1A "Rev0_Date" ; Source Attribute Tag 1 DES1A "Rev0_Desc" ; Source Attribute Tag 2 REV1A "Rev0" ; Source Attribute Tag 3 RDB1A "Rev0_Drawn_By" ; Source Attribute Tag 4 REV1B "RevSlot1Number" ; Destination Attribute Tag 3 DES1B "RevSlot1Description" ; Destination Attribute Tag 2 DAT1B "RevSlot1Date" ; Destination Attribute Tag 1 RDB1B "RevSlot1DrawnBy" ; Destination Attribute Tag 4 ) (defun _SelectBlockWithTag ( tag / e a ) (setq tag (strcase tag)) (while (progn (setvar 'ERRNO 0) (setq f (car (entsel (strcat "\nSelect Block with attribute " tag ": ")))) (cond ( (= 7 (getvar 'ERRNO)) (princ "\nMissed, Try Again.") ) ( (not f) nil ) ( (and (eq "INSERT" (cdr (assoc 0 (entget f)))) (= 1 (cdr (assoc 66 (entget f)))) ) (if (not (setq z (vl-some (function (lambda ( x ) (if (eq tag (strcase (vla-get-tagstring x))) x) ) ) (vlax-invoke (vlax-ename->vla-object f) 'getattributes) ) ) ) (princ (strcat "\nBlock does not contain tag " tag ".")) ) ) ( (princ "\nInvalid Object Selected.") ) ) ) ) z ) (and (setq aa (_SelectBlockWithTag DAT1A)) (setq ab (_SelectBlockWithTag DAT1B)) ) (vla-put-textstring ab (vla-get-textstring aa)) (and (setq ba (_SelectBlockWithTag DES1A)) (setq bb (_SelectBlockWithTag DES1B)) ) (vla-put-textstring bb (vla-get-textstring ba)) (and (setq ca (_SelectBlockWithTag REV1A)) (setq cb (_SelectBlockWithTag REV1B)) ) (vla-put-textstring cb (vla-get-textstring ca)) (and (setq da (_SelectBlockWithTag RDB1A)) (setq db (_SelectBlockWithTag RDB1B)) ) (vla-put-textstring db (vla-get-textstring da)) (princ) ) drawing.dwg -
Send Wipeout to Back of Draworder within Block Definition
b_gum posted a topic in AutoLISP, Visual LISP & DCL
So I have been trying to figure this out with several approaches now and I need some help. I would like to send all Wipeouts, or really any specified entity type, within a block to the back of the draw order. Is there a way to do this using Lee Mac's Apply To Block Objects routine? I tried this in conjunction with his draw order routines but the MovetoBottom command kept failing. I'm pretty rough with VisualLisp which is part of the issue when trying to troubleshoot his great routines. Or what about this approach? (I dont really understand it, again Visual Lisp) Below is what I tried. I do understand Vanilla Lisp. Visual Lisp I barely know the basics, but eager to learn. Please help me improve my capabilities. I love autolisp. Thank you. The issue is clearly with the lambda function and my improper use of it Im sure. The ssget I am trying to do is incorrect approach for use with his function. ;=========================================================== ; 11/Sep/2020 10:09 AM[Friday] AUTHOR: Brandon Gum ;-- ;DESCRIPTION: ;Select block with wipeout. ;Will send wipeout objects the back of the draw orer ;=========================================================== (defun c:test ( / s ) (princ "\nSelect Block: ") (if (setq s (ssget "_+.:E:S" '((0 . "INSERT")))) (LM:ApplytoBlockObjects (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vla-get-effectivename (vlax-ename->vla-object (ssname s 0))) '(lambda ( obj ) (BG:WipeoutToBottom)) ) ) (princ) ) (vl-load-com) (princ) (defun BG:WipeoutToBottom( / ) (LM:movetobottom (ssget "X" '((0 . "WIPEOUT")))) ;(princ) );end of defun ;===============Below here are Lee's draw order functions============== My LeeMac Based Approach.LSP -
Hi, I am Michel Can you kindly to help me to. I need a lisp for a cable routing. I have just a block consist of 3 attributes (TAG, SRTP, MVZ). I need to extract each relating value in separate column in excel. For example, if I select 5 blocks in drawing, I need to have 5 columns, each column has only 3 rows (3 attributes) and the possibility to have different rows for different electric cables in same file. Thank you in advance Michel richiesta.xlsx
-
I found valuable lisp for auto creation block. I want to improve this lisp to following requirement * block selected object individually, not in one block thanks AUTO-BLOCK.LSP
-
Hi, I would like to know some help. 01 - Is there a possibility in this Lee Mac lisp, Automatically Label Attributes, that it can be changed so that every time I open a different file it asks me about the increment, prefix and suffix settings? Because in the current way it always loads the pre-configuration that is already in lisp. I don't want to have to edit the lisp to configure the numbers for each file. Note: I use attributed blocks and multileader blocks. 02 - I also use the Lisp Incremental Numbering Suite, I would like to know if the option for multileaders can be added. As the current options are only for text, mtext and blocks. For my use multileaders are more interesting. Because the use of block with attributes will have to be manually making the leader lines to indicate their positions and references after their insertion and when you have many blocks end up wasting valuable time. I would like to know if it is possible to make any of these changes, since lisps have many lines. Note: Sorry for the google translation. #NumIncV3-9.lsp AutoLabelAttributesV1-4.lsp
-
What command can I use to find a block by its name in my drawing and then delete it?
-
Hey, I draw ventilation ductwork all day at work, just recently stumbled across dynamic blocks and could do with a little help with one. Attached is what i have done so far, the straight section works perfectly, just having some trouble with the radius bend. What I need is for the arc to stretch with the angle of the bend. :/ I appreciate any help, and feel free to use my working block. TEST.dwg
- 12 replies
-
- dynamic block
- block
-
(and 1 more)
Tagged with:
-
I'm trying to modify some code to achieve the following: Ask the user to pick multiple blocks, step through each block, get the extents of the block, and save a view with the view name equal to the name of the block. Doing some research I've managed to get the extents of the block but can't figure out how to store the block name as a variable and use it as the view name. The code I found will draw a rectangle around the block using vla-getboundingbox but I can't figure out how to assign the name of the block to a variable for use in the -view command. I have a few hundred blocks in the same drawing. Existing code is: (defun c:BlockExtentsToRectangle (/ BlockObject mn mx) (vl-load-com) (if (setq BlockObject (car (entsel "\n >> Select Object >> "))) (progn (vla-getboundingbox (vlax-ename->vla-object BlockObject) 'mn 'mx) (vl-cmdf "._rectang" (vlax-safearray->list mn) (vlax-safearray->list mx)))) (princ) )
-
Exchange Same-Name Attribute Block With New Tag Definition
"Mitch" posted a topic in AutoCAD Drawing Management & Output
Drawing A: old tag definition Drawing B: new tag definition Hi Guys, I have an opened drawing file A with an old attribute tag definition and brought in another attribute block with the same name but having a new attribution tag definition from a drawing file B. I had purposefully purged drawing A’s attribute block containing the old tag definition, hoping to bring in the same-name attribute from drawing B, having new tag definition. It went well except the Enhanced Attribute Editor still contains the old tag definition of drawing A – even though Battman shows the new defined tags from drawing B. This means that I need to somehow, Purge the old defined tags from drawing A. Am I able to purge the attribute’s definition from a drawing? I am doing this so I may not have to change the attribute block’s name and keep the new tag definition. Thanks for your time, "Mitch" -
Does anyone know if it's possible to manipulate the vertical line spacing of multiline attributes within a block?
- 1 reply
-
- block
- attributes
-
(and 1 more)
Tagged with:
-
Block showing distance with arrow pointing in correct direction?
Akeane posted a topic in AutoLISP, Visual LISP & DCL
So the problem im having is i have code that runs to show the offset of measured points to design points, unfortunately the code works by inserting one of 4 predefined blocks for NSEW, or one of 4 when in 2 directions; only showing orthogonal distances. These work by passing through the distance to the block tag, and then comparing the EW, and/or NS values to determine the correct arrow direction to insert the correct block. What i want is instead of using orthogonal distances, is to have an arrow block within these blocks, that changes the direction of the arrow, based on a bearing that you pass through. eg if the horizontal distance between 2 points is 25mm at a bearing of 45 degrees, then a tag is created as per normal with 25 and an arrow point 45 degrees. Any good ideas? I've looked in the forums and couldn't find anything to solve this. Attached is an image of what i have currently made, note the aligned one showing 130mm is kinda what i want, but that arrow is not dynamic, it just goes left or right and the whole block is just rotated to show the bearing. It makes for a messy plan and a lot of neck craning to present to a client -
Hello, i try to insert block view in dcl format. I want when i chose block name to have block view to. Something like this.
-
I found a lisp (attached) to change object line type. But this lisp is not changing nested blocks line types and forcing one by one selection . I need to change linetype of all objects include nested blocks and as area selection. Please help ChangeObjLinetype.lsp
- 11 replies
-
- linetype
- nested block
-
(and 1 more)
Tagged with:
-
Scale only part of a block, keep the other part a constant size
mickeforsberg posted a topic in The CUI, Hatches, Linetypes, Scripts & Macros
Hello! I'm looking for a solution to my problem. I have a block (center in the attached image) that I'd like to be able to scale as usual, but I want the red circle to remain the same size always. This particular one is a symbol for a smoke detector and the red circle is supposed to be the coverage of this detector. That is why I want the coverage circle to remain a constant diameter of let's say 10 meters, but I'd still like to be able to scale the smoke detector symbol depending on viewport scale. I also want the circle to follow the detector so that I don't have to select both. Other requests are the ability to freeze or turn off visibility of the circle, but I'd still want it to follow the smoke detector if moved. Is any of this doable? What are your thoughts? Thanks! -
Can anyone help me for the create lisp for following condition . * I have 200 of text separately in my drawing ..i want block them individually each one. *i want select 200 of text at once block them individually .. Can any one create lisp for that.thank