AutoCAD Visual LISP / AutoLISP :: Write Event Handler For Command Like Insert New Block?
Jul 19, 2012
Is it possible to write an event handler for an autocad event/ command like insert new block? I want the event to trigger the execution of an update routine . something like this post
[URL]
how do I access the autocad object in autolisp?
View 4 Replies
ADVERTISEMENT
Mar 27, 2012
I am working on a lisp file that lets you select a block and automaticaly change the layer and color in block editor. Afther this it exits block editor, deletes the original block and places the new one.
It works fine accept for the last part.
When i incert my new name whit the insert command it automaticaly changes the name whit autofil so it wil still pot my originial block (the new block name is only two characters shorter than the old one).
View 5 Replies
View Related
Oct 11, 2012
I'm trying to write a lisp routine that, when I invoke the mleader command, osmode is set to "nearest" & orthomode is set off. I then would like the original settings to be returned.
attached is what I have written so far:-
View 4 Replies
View Related
Apr 18, 2013
I am learning autolips and i found a problem that i can´t solved.
(vl-load-com)(defun c:pmb ( / ss ent pt )(prompt "
selec block : ")(setq ss (ssget '((0 . "INSERT")))) (setq ent (ssname ss 0)), (setq pt (cdr (assoc 10 (entget ent)))) (command "point" pt))
wich this code you select one block and insert one point at insert point´s block.
which this other code yo select all block and insert all point.... but in one block
(vl-load-com) (defun c:pmb11 ( / sele cod bloque nbloque lista pt ) (prompt "
block: ") (setq sele (ssget ( List'(0 . "INSERT"))) Cod 0 )cod (1+ cod) (repeat (sslength sele) (setq bloque (ssname sele cod)) (setq pt (cdr (assoc 10 ( entget bloque)))) (command "punto" pt) );repeat )
View 4 Replies
View Related
Nov 30, 2012
I have a block that i want to insert several times and revised each one to be different to do this i would have to insert it and rename the blocks that come in and then reinsert i would like to insert and have a lisp explode the main block and rename the other 2 blocks with a suffix at the end depending on how many times its in the drawing... can this even be done? My original block name that will be first inserted is "BENT PULLEY NOTES" it needs to explode after i drop it in and then there are 2 blocks within that called "Bent Pulley" and "Bent Pulley DYN" that i was hoping to keep the names but add a number at the end depending on how many are in the drawing already...
here is a lisp that i have found... it would work if i didn't have nested blocks and only wanted the one block to be insert and not explode...
(defun c:Test (/ e i name Bname )
(setq e nil)
(command "_.-insert" "Drawing1.dwg" pause "" "" "")
(if (setq e (entlast))
[Code] .......
View 9 Replies
View Related
Sep 26, 2013
I have a routine that counts dynamic blocks by visibility state and stores that information then prompts for scale and color and stores that information. Then a legend begins to build from the data and a collection of blocks to reflect the dynamic blocks and their visibility state. Everything works great on all of the machines around the office except on one. When the legend begins building, the one user is getting the DDATTE dialog instead of allowing the values to populate as expected. So, I had him change ATTREQ to 0 an run again. No deal, the same thing happens again and again. And; it only occurs on the one machine.
View 5 Replies
View Related
Apr 22, 2013
I am trying to insert one or another block into a drawing, and i need to do this 8 times per drawing.
(defun C:detector (/ filename gas pressure)
(repeat 8 (initget 1 "Gas Pressure")
(setq filename (getkword "
Enter Detector Type [Gas/Pressure]: "))
(if (= filename "gas") (command "-insert" "*T:\acad\schematic_circuits\suny\sunygasdetectornew.dwg" pause "" "")
(or (if (= filename "pressure")
(command "-insert" "*T:\acad\schematic_circuits\suny\sunypressuretransmitternew.dwg" pause "" ""))
) ;;end or
) ;;end if
) ;;end repeat
)
View 4 Replies
View Related
Aug 2, 2013
Any way to insert a block onto many different drawings quickly? I have a title block I need to insert into about 100 drawings. It seems very tedious to open each drawing and insert 100 times.
View 3 Replies
View Related
Oct 15, 2013
I tried to adapt the code provided by scottbolton in the "Insert block at intersection" thread to suit my needs. I would like to be able to enter a block name, and let that block be inserted at intersection points.
But i keep getting a DXF error.
(defun c:sbx (/)
(vl-load-com)
;;;define block used in program
(setq bloktype (getvar "USERS5"))
(prompt "asiswaarde: ")
[code]......
View 9 Replies
View Related
Apr 19, 2013
I need a routine that inserts a point at the insert point or block named "Insert_Point" at every block in the file. The routine could use the current layer, which would be set prior to starting the routine. If it could request the user for the PDMode value and PDSize that would be great too. This will assist me in creating block libraries.
View 9 Replies
View Related
Jan 3, 2012
1. I want to all selected profiles or blocks set to one object, than continue to select second object,(see attached drawing file). How to write the "ssget" lisp.
2. Command "line" ask me specify next point.
3. Found object boundary prompt me to "select oblect", when i selected profile, with the error: bad argument type: consp.
View 5 Replies
View Related
May 21, 2013
I am testing de new version of autocad 2014 and i have a problem with lisp.
when i use (command "_insert" "block1" pt1 "" "" "" obj1 ).
The block is inserted but without value. In the old version work.Some variable that has to change?
View 3 Replies
View Related
Feb 19, 2013
We are using autocad 2010 and I have written a routine that will insert several blocks on to several layers. I thought it worked flawlessly, until I used it. Our drawings use layer states. When one state is in use, all the other layers are frozen. We want to insert a block, at a specific point chosen by the user, and the lisp routine will insert a couple of other blocks at that same point, but on a layer that is frozen. Three blocks installed in all, at the same point, on two layers. The routine works if all layers are thawed, but not if the layers are frozen.
(defun c:lP1 () ; this starts the routine
(setq temperr *error*) ; saves *error*
(setq *error* rerr) ; sets the new error variable
(command "_.Undo" "_mark") ; start of "undo" command
[code]....
View 8 Replies
View Related
Feb 23, 2008
I figured out how to entmake a Block with attributes based on user input for insert point, rotation, etc.
My block is a detail bubble that is a circle with a tail, that cuts the object and shows direction of cut. I will include that with this post.
My problem lies in this. I've used dynamic block features such as linear for the tail length, and the cut length, and angle for the direction of the tail.
My old routine was simple, it would ask for detail point and angle. From that it would insert a block that was just the bubble and draw the tail and cut with a polyline.
Since then I've been able to use entmake, which is a lot more powerful for creating entities in AutoCAD. But for the life of me I can't figure out how to add the dynamic properties of my "new" detail block that has the tail, cut and bubble in one.
what I need in the entmake statement to make this create programmatically instead of inserting the block, then modifying it, if possible.
View 9 Replies
View Related
Sep 26, 2013
take a look at this piece of my LISP-routine.
(command "_.block" pause pause ss "")
where:
ss - is a Selection set of some entities
In the rest of code, I don't change the values of initdia, or cmdecho, or whatever else
I haven't sill understood them that well.The problem is the following:
When My routine executes this line, I am promted for:
1. block name - that's OK
2. insertion point - that's OK
3. then the block-command receives correctly the entities from ss-selection set - that's OK
4. then all the object dissapear! **Problem here**
The block is created... I can insert it in the drawing from the block-data base...
But is there a way to let this block stay in the drawing ? without disappearing?
View 2 Replies
View Related
Jun 28, 2013
I got this code in a web trawl to insert a block to points taken from a txt file......
its coming back with an error as follows:
; === Top statistic:
; Function definition (with number of arguments): ((C:INSERTBLOCKS . 0))
; Check done.
What does this mean and how can I fix it.
(defun c:insertBlocks (/ txtFile xyData expertVar attreqVar)(setq expertVar (getvar "expert"))
(setq attreqVar (getvar "attreq"))
(setvar "expert" 2)(setvar "attreq" 0)
(setq txtFile (open "c:\cad\textfile.txt" "r")) ;
[Code] ......
View 3 Replies
View Related
Jan 28, 2012
I would like to insert a block in a specific layout (eg. "LAYOUT13") using the function vla-insertblock
I have already searched the web and this newsgroup but have not found the solution.
View 3 Replies
View Related
Nov 4, 2011
I am using 2008 and I have a dynamic block with attributes that I want to insert with the below program and have the attritute values filled in automatically. I have done this with other programs in the past and they worked great with literally no problems. They were not dynamic blocks may be the reason this does not work. Why the block will not fill in the attributes like it should. Occasionally in my testing I see a message about "units" when I am inserting the block but I have my insunits set to 0. I have attached one of the blocks I want to use. I am thinking either you cannot do this because it is a dynamic block or there is a new variable that won't let it work.
(setq upisosym "L:/AcadUtilsJack/Programs/InsertIsoSymbols/ELL90BW_Flip_01" isosym "rat")
(setq upod "3" upsch "sched" upmatl "matl" uprat "400")
I found these two new variables and turn them off or 0 thinking they might be the problem???
(setvar "INSUNITSDEFTARGET" 1)
(setvar "INSUNITSDEFSOURCE" 1)
(defun c:JD ()
(setvar "attdia" 0)
(setvar "attreq" 1)
[Code] .....
View 9 Replies
View Related
Feb 15, 2013
When scanning the BTR (Block Table Records) and encounter a "*U" block definition
how can i know if it relate to dynamic block and have it's name?
acutally my current goal is:
when insert a dynamic block at default state (no change in it's dynamic properties/actions)
it's 'Name and 'EffectiveName is equal, when set some of it's properties it turns to dynamic anonymous
with Name = "*Unn"
Can i programaticlly set the block reference to be dynamic anonymous (with out setting any of it's properties)
cause i would like to modify it's BTR (with out effecting the original BTR dynamic block) but do not want to convert it to static anonymous block.
View 2 Replies
View Related
Sep 22, 2011
I am starting with a polyline then i use the pasteblock command to insert that polyline as a block.Now i can pull up the property box and change the xyz scale.
I would like to know how to change these setting in my lisp.The scale will be x=1 y=0.1 z=1
View 7 Replies
View Related
Dec 27, 2011
I have been working on an AutoLISP routine which is intended to:
1) collect input from the user via a DCl dialog box
a) Create a List of the non-null "GROUP_CODE..." variable values collected from the dialog's settings
b) Create a List of the "ESN***#_Part" variable values collected from the dialog's settings (does the List elements' order need to be reversed after collecting them?)
2) Prompt the user to select an insertion point
3) Insert a Block named "ESN-CONTROL-WIRED" which has multiple attributes
a) Apply the first List element collected at step 1.a above to the attribute tag "INPUT_ADD" in the block
b) Apply the first List element collected at step 1.b above to the Attribute Tag "PART_NUMBER" in the block
4) Insert a second instance of the Block named "ESN-CONTROL-WIRED" below the first instance
a) Apply the second List element collected at step 1.a above to the attribute tag "INPUT_ADD" in the block
b) Apply the second List element collected at step 1.b above to the Attribute Tag "PART_NUMBER" in the block etc. .... keep inserting the block "ESN-CONTROL-WIRED" below the previous on until all the input from the dialog has been displayed in the attributes.
Notes:
The Dialog's pop-up lists are populated from external .TXT files which reside on our network (or alternate local C: drive folder if no network drive is found)
Inside the file "ESN_SENSORS_NUMBER.LSP", it is the function "ESN_APPLY_TAG" which I am struggling with how to write...
find inside the .ZIP file:
- (2) example screenshot .BMPs showing dialog box settings and what the resulting output in AutoCAD should look like
- (1) ESN_SENSORS_NUMBER.LSP
- (1) ESN_SENSORS_NUMBER.DCL
- (1) ESN_SENSORS_NUMBER.DWG with a sample output - and the definition of the block ESN-CONTROL-WIRED
- (1) ESN-OCC.txt which populates the PopUp List Boxes
- (1) ESN-DAYLT.txt which populates the PopUp List Boxes
- (1) ESN-IR.txt which populates the PopUp List Boxes
View 6 Replies
View Related
Sep 19, 2012
I am trying to insert a norht block oriented on two selected points with the following
(defun c:North ( / ss )
;Orientate North Symbol
(setq oldos (getvar "osmode"))
(setq blk (vlax-ename->vla-object (car (entsel "
[Code] .......
I am not sure how to (a) erase the selected north block, then (b) make the insert north block in its place bit work.
View 6 Replies
View Related
Mar 29, 2013
It's been too long since I created one of these for Toolbars. I need a macro that will insert and explode a block. I just need the block's content, not the block itself. I can create a maco to explode a block with no path, but can't remember how to include the "*" in a file with a folder path to explode the block while its being inserted. Because of spaces in the file name, quotes (") must be around the path.
View 1 Replies
View Related
May 8, 2013
I have a lisp routine that I would like to add to. Right now when running the macro the user is not prompted to "Pick Point On Line" in this example
(command "insert" blk "s" var1 pause pause))
I have added the line
(setq pt1 (entsel "Pick Point On Line "))
(command "insert" blk pt1 "s" var1 pause pause))
but the command doesn't seem to like my PT1 value
BLK and VAR1 are set in another lisp routine.
View 9 Replies
View Related
Dec 24, 2013
I currently insert certain dynamic block into drawings with a short function that first inserts the specified dynamic block and then immediately changes the visibility state to one specified as an argument to the function.
I'm wondering if it is possible / better / faster to somehow insert the dynamic block with the decided visibility state simultaneously. I've been amazed by many capabilities of VL so I wouldn't at be surprised if this can be done. (the dynamic blocks I'm inserting could have many multiples in the drawing but I need this method to only affect the one being inserted at the time the function is called. I currently use entlast to decide which one is being inserted.)
View 6 Replies
View Related
Nov 30, 2010
I have a dynamic block that I would like to insert via a lisp routine. When the routine is run from my menu I would like to select two points on the drawing area. Then I would like my dynamic block to be inserted at one of the points I selected and then I would like a specific "point" of my block to be stretched to the other point that I selected. I was wondering if this is possible with LISP? I have my old LISP program I wrote that draws a leader and then inserts my block but that was before I started working with dynamic blocks.
Here is my current
(defun c:wldsym()
(setq osnapold (getvar "osmode"))
(setq orthold (getvar "orthomode"))
(setq dimsc (getvar "dimscale"))
[code]...........
wld1r.dwg is my current block. It has some dynamic properties already. But I'm trying to add new properties that can be seen in my working test drawing wld1r-new.dwg
When using my code with "wld1r.dwg" you can see how everything behaves right now. Then open "wld1r-new.dwg" and note that the insertion point and a stretch point my default are in the same spot. Work with the two stretch points and look at how the block reacts.
View 9 Replies
View Related
Sep 26, 2012
trying to insert point instead of block.
(setq blok (entget (car (entsel))))
(setq point (cdr (assoc 10 blok)))
(setq XX (rtos (car point) 2 20)) ;; x koordinata bloka
(setq YY (rtos (cadr point) 2 20)) ;; y koordinata bloka
(setq ZZ (rtos (caddr point) 2 20)) ;; z koordinata bloka
(command "point" xx,yy,zz) is not working
!xx="5582453.414999999" but when i (atoi xx) i get 5582453 no dedimals...
how to create valid insertation point from xx, yy and zz?
View 6 Replies
View Related
Nov 28, 2011
I am trying to create a lisp that prompts you to select multiple lines, and then prompts to enter a name of a block you wish to use. With that information use the measure command to place the entered block along the selected lines with the spacing set to the value in the blocks attribute.
I have a lisp that does most of this with the exception of the extracting the value of the block size to use as the distance between blocks, the current lisp just prompts for the distance.
I have a lot of blocks with different spacing so it is hard to remember the distance.
Here is the current Lisp i use:
(defun c:MEB (/ blk ss l name)
; TharwaT 04. 04. 2011
(if
[Code].....
View 9 Replies
View Related
Apr 13, 2012
I know how to write a single line of text to a txt file with LISP, but how do i write two or more lines of text to a txt file ussing lisp?
View 4 Replies
View Related
Feb 17, 2013
I want to write content of variables to a text file but I should have conversion function for variables.
for example
(setq a 123); a is an integer type, contetnt of a is 123
so I should use (itoa a) to get "123" as a string and then I can write it to text file.
but what about another type of variables?
(defun ToString ( a / result)(setq result "")(cond((= (type a) 'ENAME) (progn (setq result "Entity names")))((= (type a) 'EXRXSUBR) (progn (setq result "External ObjectARX applications")))((= (type a) 'FILE) (progn (setq result "File descriptors")))((= (type a) 'INT) (progn (setq result (itoa
[Code].....
View 5 Replies
View Related
Jun 27, 2013
I can't write unicode characters to a text file.
as you know, you can write chars on text screen easily: (write-line (strcat "\U+" "2122"))
but if you want to write chars to a text file, this command does not work: (write-line (strcat "\U+" "2122") TxtFileVar)
Here is a part of my code to test:
(defun C:HexGen ( / d f S w x y z h c)(setq d '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F") f (open "c:\0000-FFFF.txt" "w"))(foreach w d (foreach x d (foreach y d (progn (setq S "") (foreach z d (progn (setq h (strcat w x y z)) (setq c (strcat "\U+" h));;;<===character (setq S (strcat S " " (strcat h " = " c ))) ) ) (write-line S f) ) ) )) (close f)(startapp "notepad" "c:\0000-FFFF.txt"))
View 9 Replies
View Related