Jump to content

All Activity

This stream auto-updates

  1. Today
  2. You should post a sample drawing.
  3. @mhy3sx it calculate a2 as a trapezoid , because it is not a rectangle , short side are not parallel to be or no tobe a trapezoid.dwg
  4. This code does not work in Autocad 2021 (localized version), the selected MText is being deleted. How can this be fixed? ; UnFormat MText, MLeader, Table - strip formatting contol codes from texts ; ; based on Lee Mac's UnFormat string - www.lee-mac.com/unformatstring.html ; CAD Studio, 2018, www.cadstudio.cz www.cadforum.cz ; ; (vl-load-com) ;;-------------------=={ UnFormat String }==------------------;; ;; ;; ;; Returns a string with all MText formatting codes removed. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; str - String to Process ;; ;; mtx - MText Flag (T if string is for use in MText) ;; ;;------------------------------------------------------------;; ;; Returns: String with formatting codes removed ;; ;;------------------------------------------------------------;; (defun LM:UnFormat ( str mtx / _replace rx ) (defun _replace ( new old str ) (vlax-put-property rx 'pattern old) (vlax-invoke rx 'replace str new) ) (if (setq rx (vlax-get-or-create-object "VBScript.RegExp")) (progn (setq str (vl-catch-all-apply (function (lambda ( ) (vlax-put-property rx 'global actrue) (vlax-put-property rx 'multiline actrue) (vlax-put-property rx 'ignorecase acfalse) (foreach pair '( ("\032" . "\\\\\\\\") (" " . "\\\\P|\\n|\\t") ("$1" . "\\\\(\\\\[ACcFfHLlOopQTW])|\\\\[ACcFfHLlOopQTW][^\\\\;]*;|\\\\[ACcFfHLlOopQTW]") ("$1$2/$3" . "([^\\\\])\\\\S([^;]*)[/#\\^]([^;]*);") ("$1$2" . "\\\\(\\\\S)|[\\\\](})|}") ("$1" . "[\\\\]({)|{") ) (setq str (_replace (car pair) (cdr pair) str)) ) (if mtx (_replace "\\\\" "\032" (_replace "\\$1$2$3" "(\\\\[ACcFfHLlOoPpQSTW])|({)|(})" str)) (_replace "\\" "\032" str) ) ) ) ) ) (vlax-release-object rx) (if (null (vl-catch-all-error-p str)) str ) ) ) ) ;----------------- (defun doUnformatTable (table / rowCounter colCounter) (setq rowCounter (vla-Get-Rows table)) (repeat rowCounter (setq rowCounter (1- rowCounter)) (setq colCounter (vla-Get-Columns table)) (repeat colCounter (setq colCounter (1- colCounter)) (setq cellType (vla-GetCellType table rowCounter colCounter)) (if (= cellType acTextCell)(progn (setq cellText (vla-GetText table rowCounter colCounter)) (if (/= cellText "") (vla-SetText table rowCounter colCounter (LM:UnFormat cellText T))) )) ) ; rep ) ; rep ) (defun c:UNFORMAT (/ ss ssl cnt en xxobj otyp txr ntx) (princ "\nSelect MTEXTs/DIMENSIONs/MLEADERs/TABLEs: ") (setq ss (ssget '((0 . "MTEXT,DIMENSION,MULTILEADER,ACAD_TABLE")))) (if (and ss (> (setq ssl (sslength ss)) 0))(progn (setq cnt 0) (repeat ssl (setq en (ssname ss cnt)) (setq obj (vlax-ename->vla-object en)) (setq otyp (cdr (assoc 0 (entget en)))) ; (vla-get-objectname obj)) (cond ((= otyp "MTEXT")(vla-put-TextString obj (LM:UnFormat (vla-get-TextString obj) T))) ; AcDbMText ((= otyp "DIMENSION")(vla-put-TextOverride obj (LM:UnFormat (vla-get-TextOverride obj) T))) ; AcDbRotatedDimension, AcDbAlignedDimension ((= otyp "MULTILEADER")(vla-put-TextString obj(LM:UnFormat (vla-get-TextString obj) T))) ; AcDbMLeader ((= otyp "ACAD_TABLE")(doUnformatTable obj)) ; AcDbTable ) (setq cnt (1+ cnt)) ) ;rep ) (princ "\nNothing selected!") ) ;if (princ) ) (princ "\nUNFORMAT loaded.") (princ)
  5. Hi CivilTechSource , I test your code but if you test it in my dwg will see that calculate a2 area as trapezoid !!! Thanks
  6. Hello! I am working in AutoCAD 2007/2008 and opened my AutoCAD this morning to find myself stuck in the TableBuilder screen which is odd because I never use TableBuilder. Anyway, can someone please help me leave the TableBuilder screen and return to my home screen where all of my tool icons reside? Thank you, Dave
  7. We are in 2025, do we still need to show the work? Would it not be easier to write a lisp that prompts you to select each side of polygon by specifying starting and end point and then you can have the lisp do a check between if trapezoid or parallelogram and then put in text the formula substituting the lengths? The below is AI generated code that seems to work fine in terms of differentiating between triangle rectangle trapezoid and parallelogram. The mtext showing the work has some boxes not sure why. (defun C:POLYAREA (/ pt1 pt2 pt3 pt4 pts shape-type area calc-text insert-pt) ;; Function to calculate distance between two points (defun get-distance (p1 p2) (sqrt (+ (expt (- (car p2) (car p1)) 2) (expt (- (cadr p2) (cadr p1)) 2)))) ;; Function to calculate area using shoelace formula (defun shoelace-area (point-list) (setq n (length point-list)) (setq area 0.0) (setq i 0) (while (< i n) (setq j (if (= i (1- n)) 0 (1+ i))) (setq xi (car (nth i point-list))) (setq yi (cadr (nth i point-list))) (setq xj (car (nth j point-list))) (setq yj (cadr (nth j point-list))) (setq area (+ area (* xi yj))) (setq area (- area (* xj yi))) (setq i (1+ i))) (abs (/ area 2.0))) ;; Function to check if vectors are parallel (for parallelogram/rectangle check) (defun vectors-parallel (v1 v2 tolerance) (setq cross-product (abs (- (* (car v1) (cadr v2)) (* (cadr v1) (car v2))))) (< cross-product tolerance)) ;; Function to check if vectors are perpendicular (for rectangle check) (defun vectors-perpendicular (v1 v2 tolerance) (setq dot-product (+ (* (car v1) (car v2)) (* (cadr v1) (cadr v2)))) (< (abs dot-product) tolerance)) ;; Function to get vector from two points (defun get-vector (p1 p2) (list (- (car p2) (car p1)) (- (cadr p2) (cadr p1)))) ;; Function to identify quadrilateral type (defun identify-quad (p1 p2 p3 p4) (setq v1 (get-vector p1 p2)) ; Side 1 (setq v2 (get-vector p2 p3)) ; Side 2 (setq v3 (get-vector p3 p4)) ; Side 3 (setq v4 (get-vector p4 p1)) ; Side 4 (setq tolerance 0.001) ;; Check if opposite sides are parallel (setq opposite1-parallel (vectors-parallel v1 v3 tolerance)) (setq opposite2-parallel (vectors-parallel v2 v4 tolerance)) (cond ;; Rectangle: opposite sides parallel AND adjacent sides perpendicular ((and opposite1-parallel opposite2-parallel (vectors-perpendicular v1 v2 tolerance)) "Rectangle") ;; Parallelogram: opposite sides parallel ((and opposite1-parallel opposite2-parallel) "Parallelogram") ;; Trapezoid: one pair of opposite sides parallel ((or opposite1-parallel opposite2-parallel) "Trapezoid") ;; General quadrilateral (t "Quadrilateral"))) ;; Function to create calculation text for triangle (defun triangle-calc-text (p1 p2 p3 area) (setq a (get-distance p1 p2)) (setq b (get-distance p2 p3)) (setq c (get-distance p3 p1)) (setq s (/ (+ a b c) 2.0)) ; semi-perimeter (setq sa (- s a)) (setq sb (- s b)) (setq sc (- s c)) (strcat "TRIANGLE AREA CALCULATION\\P" "Using Heron's Formula:\\P" "Side a = " (rtos a 2 3) " units\\P" "Side b = " (rtos b 2 3) " units\\P" "Side c = " (rtos c 2 3) " units\\P" "Semi-perimeter s = " (rtos s 2 3) " units\\P" "Area = √(s(s-a)(s-b)(s-c))\\P" "Area = √(" (rtos s 2 3) "×" (rtos sa 2 3) "×" (rtos sb 2 3) "×" (rtos sc 2 3) ")\\P" "Area = √" (rtos (* s sa sb sc) 2 3) "\\P" "Area = " (rtos area 2 3) " square units")) ;; Function to create calculation text for rectangle (defun rectangle-calc-text (p1 p2 p3 p4 area) (setq width (get-distance p1 p2)) (setq height (get-distance p2 p3)) (strcat "RECTANGLE AREA CALCULATION\\P" "Width = " (rtos width 2 3) " units\\P" "Height = " (rtos height 2 3) " units\\P" "Area = Width × Height\\P" "Area = " (rtos width 2 3) " × " (rtos height 2 3) "\\P" "Area = " (rtos area 2 3) " square units")) ;; Function to create calculation text for parallelogram (defun parallelogram-calc-text (p1 p2 p3 p4 area) (setq base (get-distance p1 p2)) ;; Calculate height using area formula: Area = base × height (setq height (/ area base)) (strcat "PARALLELOGRAM AREA CALCULATION\\P" "Base = " (rtos base 2 3) " units\\P" "Height = " (rtos height 2 3) " units\\P" "Area = Base × Height\\P" "Area = " (rtos base 2 3) " × " (rtos height 2 3) "\\P" "Area = " (rtos area 2 3) " square units")) ;; Function to create calculation text for trapezoid (defun trapezoid-calc-text (p1 p2 p3 p4 area) (strcat "TRAPEZOID AREA CALCULATION\\P" "Using coordinate method (Shoelace formula)\\P" "Point 1: (" (rtos (car p1) 2 3) ", " (rtos (cadr p1) 2 3) ")\\P" "Point 2: (" (rtos (car p2) 2 3) ", " (rtos (cadr p2) 2 3) ")\\P" "Point 3: (" (rtos (car p3) 2 3) ", " (rtos (cadr p3) 2 3) ")\\P" "Point 4: (" (rtos (car p4) 2 3) ", " (rtos (cadr p4) 2 3) ")\\P" "Area = ½|∑(xᵢyᵢ₊₁ - xᵢ₊₁yᵢ)|\\P" "Calculation: ½|(" (rtos (car p1) 2 3) "×" (rtos (cadr p2) 2 3) "-" (rtos (car p2) 2 3) "×" (rtos (cadr p1) 2 3) ") + " "(" (rtos (car p2) 2 3) "×" (rtos (cadr p3) 2 3) "-" (rtos (car p3) 2 3) "×" (rtos (cadr p2) 2 3) ") + " "(" (rtos (car p3) 2 3) "×" (rtos (cadr p4) 2 3) "-" (rtos (car p4) 2 3) "×" (rtos (cadr p3) 2 3) ") + " "(" (rtos (car p4) 2 3) "×" (rtos (cadr p1) 2 3) "-" (rtos (car p1) 2 3) "×" (rtos (cadr p4) 2 3) ")|\\P" "Area = " (rtos area 2 3) " square units")) ;; Main program starts here (princ "\\nPolygon Area Calculator") (princ "\\nSelect points in order (clockwise or counterclockwise)") ;; Get first point (if (setq pt1 (getpoint "\\nSelect first point: ")) (progn ;; Get second point (if (setq pt2 (getpoint pt1 "\\nSelect second point: ")) (progn ;; Get third point (if (setq pt3 (getpoint pt2 "\\nSelect third point: ")) (progn ;; Check if user wants to add a fourth point (setq pt4 (getpoint pt3 "\\nSelect fourth point (or press Enter for triangle): ")) (if pt4 ;; Four points - quadrilateral (progn (setq pts (list pt1 pt2 pt3 pt4)) (setq shape-type (identify-quad pt1 pt2 pt3 pt4)) (setq area (shoelace-area pts)) ;; Create appropriate calculation text (cond ((= shape-type "Rectangle") (setq calc-text (rectangle-calc-text pt1 pt2 pt3 pt4 area))) ((= shape-type "Parallelogram") (setq calc-text (parallelogram-calc-text pt1 pt2 pt3 pt4 area))) (t (setq calc-text (trapezoid-calc-text pt1 pt2 pt3 pt4 area)))) (princ (strcat "\\nShape identified: " shape-type)) (princ (strcat "\\nArea: " (rtos area 2 3) " square units"))) ;; Three points - triangle (progn (setq pts (list pt1 pt2 pt3)) (setq shape-type "Triangle") (setq area (shoelace-area pts)) (setq calc-text (triangle-calc-text pt1 pt2 pt3 area)) (princ (strcat "\\nShape identified: " shape-type)) (princ (strcat "\\nArea: " (rtos area 2 3) " square units")))) ;; Get insertion point for MText (if (setq insert-pt (getpoint "\\nSelect point to insert calculation text: ")) (progn ;; Create MText entity (entmake (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbMText") (cons 10 insert-pt) ; insertion point (cons 40 2.5) ; text height (cons 41 50.0) ; reference rectangle width (cons 71 1) ; attachment point (top left) (cons 72 5) ; drawing direction (cons 1 calc-text) ; text string (cons 7 "STANDARD") ; text style (cons 210 '(0.0 0.0 1.0)))) ; normal vector (princ "\\nCalculation text inserted successfully!")) (princ "\\nText insertion cancelled."))) (princ "\\nThird point required.")) (princ "\\nSecond point required.")) (princ "\\nFirst point required.")) (princ)) ) ) ;; Command to run the function (princ "\\nPolygon Area Calculator loaded. Type POLYAREA to run.") (princ)
  8. BREAKUP is somewhat different from EXPLODE. BREAKUP is used to break a single object into its component parts without losing the original object’s properties. This command is particularly useful for complex objects like polylines, blocks, or other grouped entities. It allows you to manipulate individual components of an object while maintaining the overall integrity of the drawing. Not really sure what the real world difference would be if the "properties" are not needed after exploding. IIRC, it's useful for EXPLODING i.e. some of the Symbols, etc. from Mechanical and other verticals without losing the properties.
  9. CivilTechSource

    Help with Diesel Expression

    Thank you so much! After playing with lisp for over a two months now I am so happy that I can understand the above!
  10. Hi devitg, You delete parts of the original code . I use ; Set scale and text height (setq scl (getvar "useri1")) (setq ht (* 0.00003 scl)) To set the scale for a lot of the lisp I use , and I need this part too (initget "1 2") ;;; (setq t_spc (getkword "\n Insert calculations[1.Modelspace/2.Paperspace]? <1>: ")) I test the code you upload but The calculation on trapezoid is not fixed because can not understand that the paralilogram (a2) is not a trapezoid (a1) because the code check only if the lines is pararell and calculate the area of the trapezoid. Perhaps need son anngle check to understamd if it is paralilogram or trapezoid. Thanks
  11. MeGuinness

    text offset

    thanx for your reply, I'm new to inventor... learning , can you explain what to do with the file you shared please. thanx again
  12. The get area by co-ordinates method is a known mathematical formula why not just paste that into your dwg as a statement. Have a test shape like a square, with the example of calculations. Second comment this has been asked for before many years ago, it must be a particular country land title standard that must be shown. Sorry no idea where to start looking for the previous posts, maybe here or Forums/Autodesk.
  13. Yesterday
  14. BIGAL

    text offset

    Use Seants text to geom. or TXTEXP a built in explode text. TXTEXP Arial bold with a Oblique of 10. Then pedit multi, then extrude. Text 2 geom.zip
  15. One of the others ways to do this is to use a lisp and break the string into individual bits. As you have a "-" as a common item in the string you can blow it apart and rejoin. Thanks to Lee-mac parse lsp. Something like this. ; Parse string to a list ny Lee-mac (defun csv->lst (str ans / pos ) (if (setq pos (vl-string-position ans str)) (cons (substr str 1 pos) (csv->lst (substr str (+ pos 2)) ans)) (list str) ) ) (setq str "XXX-ZINC-XX-XX-DR-C-01000_S278 Sections") ; use (getvar 'dwgname) (setq newstr "" x 0) (setq ans (csv->lst str 45)) (repeat (- (length ans) 2) (setq newstr (strcat newstr (nth x ans) "-")) (setq x (1+ x)) ) (setq newstr (strcat newstr (nth x ans))) Ps ; tab 9 space 32 (chr 32) comma 44 semicolon 59 slash / 47 - 45
  16. Lisp give the correct Area The lsp have some error , I fix it as far as I know to do . See text file atached , dwg and lisp fixed You have to arrange ; Set scale and text height (setq scl (getvar "useri1")) (setq ht (* 0.00003 scl)) As you need fixed area-cal.LSP to check.txt get area by calculation.dwg
  17. I need to insert the calculation ananylic in specific drawings. If someone check the drawing ,need to know how I do the calculations.Thats why I want to update this code. Thanks
  18. @mhy3sx please upload the sample DWG with a mtext sample Mean while try the lisp file , it will put the area value at each polyline geografic center get area by calculation.dwg get-area.LSP
  19. MeGuinness

    text offset

    using inventor 2023
  20. MeGuinness

    text offset

    hi guys , is there a way to offset text ? i created the letters and then used the extruder command...cut..so to have the letters embossed to a surface, now i need to create the same letters but 4 mm thick that need to be snapped in on the surface embossed slots, i need to reduce the size slightly so the fit in the slots ...im able to offset anything that i created using LINES or Circle but not the letters . any help appreciated. thanx
  21. @mhy3sx Where you need to put area value .
  22. Someone just asked me about this command (BREAKUP) never heard of it, nothing on YT. I found this in the help file.. Is Explode not politically correct?
  23. @CivilTechSource sure thing. I actually figured out the 'misbehavior' based on an earlier response (it was me being stupid of course). I would love to add another grip to this thing to move the magenta part up and down from either the top or the bottom of the magenta, and have the grips 'slide' with the thing. So if I move the magenta part up with the top grip, the bottom grip goes along for the ride. Then if I slide back down with the bottom grip, the top grip goes along for the ride. I've done that EXCEPT after one round of back and forth it started acting wonky so I went back to the single Move. When I say "bottom", I mean the grip that stays at the bottom of the magenta, not the bottom of the overall block where the Basepoint is. Obviously that starts at the same spot if the block has been reset (notice this one has NOT been reset), but once the magenta moves up, I want the Basepoint to stay put and the "bottom" grip to stay at the bottom of magenta. Seems like it should be so easy but I keep not quite getting it right. I'll see if I can find my last attempt before I went back to this single Move version, but this does have the color differentiated. Thank you jack2.dwg
  24. I dont want to insert the calculations in table.I want to insert as mtext. And I want the calculations with the dimension of eatch polygon not by coordinates. Any ideas Thanks
  25. Makes me think of AreaG from GP_: Maybe you can take some inspiration on the calculations in his code?
  26. Can you highlight at a different color what needs to move up please that would help.
  27. I am trying to write a diesel expression that will extract the first part of the drawing file name. Full Drawing File Name: XXX-ZINC-XX-XX-DR-C-01000_S278 Sections First Part: XXX-ZINC-XX-XX-DR-C- My question: Is there a smarter way to extract the first part rather than relaying on the number of characters? If everyone is following the correct naming protocol it would be 20 characters but sometimes you have people instead of -C- they put -CE- so I am wondering is there a way to future proof it. Thank you. $(substr,$(getvar,"dwgname"),1,20)
  1. Load more activity
×
×
  • Create New...