Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/28/2022 in all areas

  1. Thanks Mhupp, for me given various styles of holes would have to start again, I have used the library dcl routines as they are dynamic in terms of number of holes. I would do something like this. So if 4 holes required and 1 row you can turn on of off do a hole, the dcl will show how many holes you ask for. The double row again a double toggle turn on or off holes. A tick means yes a off means no circle. It would be a custom program I have not added the other dcl which is all the dimension values. It would require a custom dcl have done this sort of thing for another client where the entry's match say number of holes. The above depends on the prior number in this case its 4.
    1 point
  2. This came up in another question earlier... copied and pasted the important parts of my answer from there CSV... Comma Seperated Values.. and can be created using notepad... and if we can create one using notepad than AutoCAD can do that too.... From Lee Macs website, http://lee-mac.com/writecsv.html , follow the example at the bottom of the page to run the lisp you can download from the top of the page, in this case using the example above it might give you this (I haven't checked this though) I think replace the first part of below with the second part and add Lee Macs Lisp above to the start of yout LISP file (foreach line master-lst ;write master-lst to cvs ) to be: (if (setq fn (getfiled "Create Output File" "" "csv" 1)) (LM:WriteCSV master-lst fn) ) )
    1 point
  3. The color(s) you see in a block depend on the block definition and the layer the block is on. You can't change either of those things without editing the referenced drawing. If the components of a block are set to color ByLayer and if they're on layer 0, then you can change the color of the layer on which the block is inserted, and the block will change color. So it's a good idea to define all your blocks that way if possible. Otherwise, you're stuck with the colors of the block elements or of the block instance itself. Another possibility is if those block elements are color ByBlock (because nothing is simple in AutoCAD). Then the block, not the layer, determines the color. Unless the block is color ByLayer, then it inherits the layer color. tl;dr: You can redefine the color of an xref-ed layer, but if that doesn't help, you're stuck without access to the drawing itself.
    1 point
  4. This line is setting up for the next line of code. Think of it as a map location saying in AutoCAD > Active Drawing > list of blocks in this drawing > of those blocks select the one named blk. def is a location, were blk is just the name of the block. The next line of code is then saying create this attribute at the "def" location. Here is a little example. when ever your using any vla-add function you first have to define the location where to add that item. (defun C:Foo (/ spm dia cen cir) (vl-load-com) (setq spm (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) ;set the location/area for model space (setq dia (getstring "\nCircle Radius: ")) (setq cen (getpoint "\nCircle Center: ")) (setq cir (vla-addcircle spm cen dia)) ;create a circle defined as cir in spm location/area ;you could then manipulate the circle by calling "cir" if you wanted. )
    1 point
  5. You can take the text and search around it for a block, say using bounding box then offset a pline use the co-ords and (ssget "CP" co-ords.... this way could all be done starting with a single window selection. The only draw back is may get wrong block. Pretty sure been done before. This is an example based on sample dwg, using a bounding box would be better. Just butchered one i already had. Look at LST for result. ; https://www.cadtutor.net/forum/topic/74392-require-lisp-to-export-coordinate-of-objects-along-with-text/ ; By AlanH Jan 2022 (defun c:toff (/ ent CEN CO-ORD LAY LST OBJ OBJ2 OLDSNAP RAD SS SS2 STR X) (setq offd (getreal "\nEnter offset try 2.5")) if text is further away (setq oldsnap (getvar 'osmode)) ; save current osnaps (setvar 'osmode 0) ; turn off osnaps (setq ent (entget (car (entsel "\nPick text for layer and value")))) ; select a text obect (setq lay (cdr (assoc 8 ent))) ; get object layer dxf code 8 (setq ss (ssget (list (cons 0 "*TEXT") (cons 8 lay) ))) ; get objects that are text on layer plus text string (setq lst '()) ; set list to blank in case exists already (repeat (setq x (sslength ss)) ; do for every text in selection (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) ; get each item in selection set (setq ins (vlax-get Obj 'insertionPoint)) ; get text insertion point (setq str (vlax-get Obj 'textstring)) ; get object text dxf code 1 (if (> (vl-string-search "BricsCAD" (getvar 'acadver)) 0) (command "polygon" 20 ins offd) ; for Bricscad (command "polygon" 20 ins "I" offd) ;Autocad Note bricscad is different ) (setq obj2 (entlast)) ; save the name of the last object created (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget obj2)))) ; loops through the pline vertice points (command "erase" obj2 "") ; no longer required as needed points (setq ss2 (ssget "CP" co-ord (list (cons 0 "INSERT,POINT")))) ; looks for insert that touch the polygon (if (= ss2 nil) (princ) (progn (setq obj2 (vlax-ename->vla-object (ssname ss2 0))) (cond ((= (vla-get-objectname obj2) "AcDbBlockReference") (setq cen (vlax-get obj2 'insertionpoint))) ; gets the center point of the block ((= (vla-get-objectname obj2) "AcDbPoint") (setq cen (vlax-get obj2 'coordinates))) ) (setq lst (cons (list str cen) lst)) ; makes a list ) ) ) (setvar 'osmode oldsnap) ; reset the osnaps (princ lst) (princ) ; quite exit of defun ) (c:toff)
    1 point
  6. I would just evaluate entsel. eliminates if statement. (while (setq MyEnt (entsel "\nSelect Point, or Enter or Space to exit")) (setq MyPCoords (cdr (assoc 10 (entget (car MyEnt))))) (setq MyEnt (entsel "\nSelect Text")) (setq MyText (cdr (assoc 1 (entget (car MyEnt))))) (setq MyList (append MyList (list MyText (car MyPCoords) (cadr MyPCoords)))) )
    1 point
  7. Seeing that you have been on the forum for a while, I guess you know the basics of a LISP. In your example drawing the text and point are not linked so I guess you will need to select the point then it's text and repeat until you have got all you need to get? Using entsel for both selections is a good option: (setq MyEnt (entsel "\nSelect Point")) (setq MyPCoords (cdr (assoc 10 (entget (car MyEnt))))) Will get you a coordinate and change assoc 10 to assoc 1 will get you the text in most instances....should give you a start anyway.. have a go and see where you go with that. If it was me I would use this (setq MyList (list)) (setq DoLoop "Yes") (while (= DoLoop "Yes") (if (setq MyEnt (entsel "\nSelect Point, or Enter or Space to exit")) (progn (setq MyPCoords (cdr (assoc 10 (entget (car MyEnt))))) (setq MyEnt (entsel "\nSelect Text")) (setq MyText (cdr (assoc 1 (entget (car MyEnt))))) (setq MyList (append MyList (list MyText (car MyPCoords) (cadr MyPCoords)) )) ) (setq DoLoop "No") ) ) (princ MyList) This creates short list (x y text) and stores them in a longer list MyList, You could use (nth n list) to extract the information when writing to an excel file.... and there have been questions about writing to excel recently that should help... (setq MyList (list)) (setq DoLoop "Yes") (while (= DoLoop "Yes") (if (setq MyEnt (entsel "\nSelect Point, or Enter or Space to exit")) (progn (setq MyPCoords (cdr (assoc 10 (entget (car MyEnt))))) (setq MyEnt (entsel "\nSelect Text")) (princ "Select Text") (setq MyText (cdr (assoc 1 (entget (car MyEnt))))) (setq MyList (append MyList (list MyText (car MyPCoords) (cadr MyPCoords)) )) ) (setq DoLoop "No") ) ) ;; get data to write to excel 1 set of data at a time (setq acount 0) (while (< acount (length MyList)) (setq Mytext (nth 0 (nth acount MyList))) (setq MyX (nth 1 (nth acount MyList))) (setq MyY (nth 2 (nth acount MyList))) ;;Write Mytext to excel ;;Write MyX to excel ;;Write MyY to excel (setq acount (+ acount 1)) )
    1 point
×
×
  • Create New...