Jump to content

Leaderboard

Popular Content

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

  1. Owner id is reset every time you load a drawing. I posted some code but cant find it. it was either entsel or entget that used the point to select another entity. you could use that to with dxf cod 10 or 15 to select the circle to get what you need.
    1 point
  2. 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
  3. 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
  4. Here you go ... (defun c:Test (/ xb4 yb4 pt p1 p2 p3 in 1p 2p 3p) ;; Tharwat Al Choufi - 27.Jan.2.22 ;; (or *Plate:len* (setq *Plate:len* 300.0)) (or *Plate:hgt* (setq *Plate:hgt* 200.0)) (if (and (setq *Plate:len* (cond ((getdist (strcat "\nSpecify X length " (rtos *Plate:len* 2 2) " > : " ) ) ) (*Plate:len*) ) ) (setq *Plate:hgt* (cond ((getdist (strcat "\nSpecify Y length " (rtos *Plate:hgt* 2 2) " > : " ) ) ) (*Plate:hgt*) ) ) (setq xb4 (/ *Plate:len* 4.0) yb4 (/ *Plate:hgt* 4.0) ) ) (while (setq pt (getpoint "\nSpecify base point : ")) (setq p1 (polar pt pi *Plate:len*) p2 (polar p1 (* pi 0.5) *Plate:hgt*) p3 (polar p2 0.0 *Plate:len*) in (polar (polar pt pi xb4) (* pi 0.5) yb4) 1p (polar in pi (* xb4 2.0)) 2p (polar 1p (* pi 0.5) (* yb4 2.0)) 3p (polar 2p 0.0 (* xb4 2.0)) ) (LWPoly pt p1 p2 p3) (LWPoly in 1p 2p 3p) (foreach q (list in 1p 2p 3p) (entmake (list '(0 . "CIRCLE") (cons 10 q) '(40 . 9.0))) ) ) ) (princ) ) ;; ;; (defun LWPoly (1pt 2pt 3pt 4pt) (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1) (cons 10 1pt) (cons 10 2pt) (cons 10 3pt) (cons 10 4pt) ) ) )
    1 point
  5. You can change some values as default you can also do keep a value for next use in same session. I wont go into that now but its easy. Change to suit colored values, the 5 4 is 5 digits max so if need more say 8 7 instead for text may need like 21 20. Each can be a different size. (setq ans (AH:getvalsm (list "Enter Values" "X" 5 4 "100" "X1" 5 4 "50" "X2" 5 4 "50" "Y " 5 4 "100" "Y1 " 5 4 "50" "Y2 " 5 4 "50" "Rad" 5 4 "10" ))) The ans returned is a list of strings so use Atof or Atoi for numbers. I matched your way of doing x x1 x2 etc Re learning no quick way other than keep looking at tasks like this. Start simple learn about stuff like polar for working out pts, I often draw on a piece of paper the point numbers as I code so dont lose track. A beginner big hint work angles in radians, aunits 3, 90 = (/ pi 2.0) and the nasty Autocad is counter clockwise for angles, but you get used to it. Just post another request then people here will help you to learn. I would look at a custom menu next adding what you download or write much easier than using appload.
    1 point
  6. Try this (defun c:hatpat ( / lay hatchtype hatchname hatchangle ss x ) (setq ent (entget (car (entsel "\nPick a hatch")))) (setq lay (cdr (assoc 8 ent)) hatchtype (cdr (assoc 2 ent)) hatchangle (cdr (assoc 52 ent)) ) (setq hatchname (getreal "\nEnter hatch name")) (setq ss (ssget "x" '((0 . "hatch")(cons 2 hatchtype)(cons 52 hatchangle))) ) (repeat (setq x (sslength ss)) (setq ent (entget (ssname ss (setq x (1- x))))) (entmod (subst (cons 2 Hatchname) (assoc 2 ent) ent)) ) (princ) )
    1 point
  7. I want that is to change the Pattern while keeping the slant angle. so I need to filter each hatch with a different tilt angle
    1 point
  8. You're welcome anytime. A few mods if you are interested. (if (= (cdr (assoc 0 (entget ent))) "CIRCLE") (progn (vl-cmdf "_circle" "_non" pt "0.0078") (setq obj (entlast)) (vl-cmdf "_view" "save" "s") (vl-cmdf "_Zoom" "OB" obj "") (vl-cmdf "_trim" obj "" "_non" pt "") (vl-cmdf "_erase" obj "") (vl-cmdf "_view" "restore" "s") ) (command "_.break" (list ent pt) "_F" "_non" (polar pt ang (/ off 2.)) "_non" (polar pt (+ pi ang) (/ off 2.)) ) )
    1 point
×
×
  • Create New...