Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/10/2024 in all areas

  1. Certainly - the following will construct a circle with the area of any closed shape: (defun c:carea ( / ent ins ocs ) (cond ( (not (setq ent (car (entsel))))) ( (vl-catch-all-error-p (setq are (vl-catch-all-apply 'vlax-curve-getarea (list ent)))) (princ "\nInvalid object selected.") ) ( (not (setq ins (getpoint "\nPoint for circle: ")))) ( (setq ocs (trans '(0 0 1) 1 0 t)) (entmake (list '(000 . "CIRCLE") (cons 010 (trans ins 1 ocs)) (cons 040 (sqrt (/ are pi))) (cons 210 ocs) ) ) ) ) (princ) )
    1 point
  2. So, I figured out the MDO mystery...it is a draw order that I had buried in my earlier files. I just remember my predecessor saying to always use it at the end of any command...so I have. Thank you again for the assistance.
    1 point
  3. It can be done, but as long as there is a Pi in that formula, the result will be affected by the precision used to approximate Pi. Even the answers to your previous question are affected by the same imprecision. It is small enough for our engineering needs, but it is not zero!
    1 point
  4. @Nikon You are not the first one. Others tried to solve this specific problem centuries ago. Also others proved that the problem has no solution (but they had no AutoCAD, nor AutoLisp at that time). Squaring a circle
    1 point
  5. If you dont have the source of the VLX we can not help you, its a case of look at this code. Yes its blank, that means some one has to start with a blank sheet and write all new code. You need to explain more what values need to have their color changed. Is it just all that you select to one color ? The send to Excel is the easy bit.
    1 point
  6. I use Bricscad and this is the rectang command you can see the "D" option. Ok a different way around it. (defun c:sqcirc ( / obj area side pt) (setq obj (vlax-ename->vla-object (car (entsel "\nPick object ")))) (setq area (vlax-get obj 'area)) (setq side (sqrt area)) (setq pt (getpoint "\nPick bottom left point ")) (command "rectang" pt (mapcar '+ pt (list side side 0.0))) (princ) ) (c:sqcirc)
    1 point
  7. @Steven P I've only this file as a Vlx, I will check If i can unlock it
    1 point
  8. Another real simple with no error checking, using rectang. Lee's is better having the error checking. Whilst entmake is faster than rectang as you are picking a circle speed is not a problem. Both methods draw in micro seconds. (defun c:sqcirc ( / obj area side pt) (setq obj (vlax-ename->vla-object (car (entsel "\nPick object ")))) (setq area (vlax-get obj 'area)) (setq side (sqrt area)) (setq pt (getpoint "\nPick bottom left point ")) (command "rectang" "D" side side pt pt) (princ) ) (c:sqcirc)
    1 point
  9. Usually, the escape prefix is ‘^C^C’ as mentioned here, I.e. acad.doc.SendCommand("^C^C-PURGE…. ") https://www.keanw.com/2006/08/cancelling_an_a.html If a command is actually running, then there’s not much you can do because the document is most likely locked. However, you can test if AutoCAD is ready to except a command by using the Application.GetAcadState method https://help.autodesk.com/view/ACD/2024/ENU/?guid=GUID-0225808C-8C91-407B-990C-15AB966FFFA8 if you don’t need to be running out of process, and your version of CAD is compatible, you should try to run PyRx. It’s literally 100s of times faster than pyautocad. You get all or ActiveX and a big subset of ObjectArx
    1 point
  10. Ok understand, a different approach get all the rectangs in an order, have a way to do that. Can send direct to Excel, no need to make a text file. Please confirm want an Excel as end result. It on my "to do list".
    1 point
  11. Welcome to CADTutor Panayotov Try this program that I have just finished from writing it and the program export the collected data to an excel file with csv format , so you can re-save the file in any other format if you'd like to . Anyway try it and let me know . (defun c:Blocks2Excel (/ _doc nm ds b ly f lst fl op) ;;--------------------------------------------;; ;; ;; ;; Author : Tharwat 10.June.2015 ;; ;;--------------------------------------------;; ;; Compute the quantity of all blocks in ;; ;; a drawing and write the outcome to an ;; ;; Excel file format in format .csv ;; ;;--------------------------------------------;; ;; Layer Name:,Block Name:,QTY,Description ;; ;; ;; ;;--------------------------------------------;; (vlax-for l (vla-get-layouts (setq _doc (vla-get-ActiveDocument (vlax-get-acad-object)))) (vlax-for o (vla-get-block l) (if (and (eq (vla-get-objectname o) "AcDbBlockReference") (setq nm (vla-get-effectivename o)) (setq ds (if (vlax-property-available-p (setq b (vla-item (vla-get-blocks _doc) nm)) 'comments) (vla-get-comments b) "") ) (setq ly (vla-get-layer o)) ) (if (vl-some '(lambda (x) (and (eq ly (car x)) (eq nm (cadr x)) (setq f x) ) ) lst) (setq lst (subst (list ly nm (1+ (caddr f)) ds) f lst)) (setq lst (cons (list ly nm 1 ds) lst)) ) ) ) ) (setq lst (vl-sort lst '(lambda (j k) (< (car j) (car k))))) (cond ((not lst) (alert "Couldn't find any block in this drawing !!")) ((and (setq fl (getfiled "Specify new Excel file name" (getvar 'DWGPREFIX) "csv" 1)) (setq op (open fl "w")) ) (write-line "Layer Name:;Block Name:;QTY;Description" op) (mapcar '(lambda (x) (write-line (strcat (car x) ";" (cadr x) ";" (itoa (caddr x)) ";" (nth 3 x)) op)) lst) (close op) ) ) (princ) )(vl-load-com)
    1 point
×
×
  • Create New...