Jump to content

hanhphuc

Members
  • Content count

    762
  • Joined

  • Last visited

Community Reputation

10 Good

About hanhphuc

  • Rank
    Associate

Personal Information

  • Location
    Happy Garden

My Software

  • Main CAD Product
    AutoCAD
  • Current Product Version
    2007
  • First AutoCAD Version
    AutoCAD 2007
  1. hanhphuc

    Story-Booking idea for a LISP

    hi, Notepad++ has nice formatting environment but for LISP efficiency & debugging i still prefer powerful VLIDE FWIW, in VLIDE - matching parenthesis Ctrl+M
  2. hanhphuc

    New Forum Feedback

    hi admin thanks for the afford & updates! i'm occasionally volunteering & active in AutoLISP forum, just notice hot thread icon ,kudos & icon missing. hopefully i'll get used to it soon i like the new code Tags (stake overflow website) but the hiccup no color / highlighting syntax? or missing something? i'll keep supporting CADTUTOR
  3. hanhphuc

    auto on/off an object

    FWIW alternative suggestion (not hiding method) (vla-put-fade image 50)
  4. (defun foo (x) (* (fix (/ (+ x 1.0) 2.0)) 2.0 ) ) ? (foreach x '(901 902. 902.9 903 904.1 904.9 905 905.5 906.9 907 908.9 909.1) (princ (strcat "\n" (rtos x 2 [color="red"]1[/color]) " = " (rtos (foo x)2 [color="red"]0[/color]) )) ) (princ)
  5. hanhphuc

    [LISP] Parse/split list by element

    my $0.02 if content of string has "#" ? keep or parse ? '("#" "ASD" "AS[color="red"]#[/color]DD" "DSA" "1 ""2" "#" "FDS" "gfsfg" "#") ;also string has many possibilities [color="purple"]"#" " #" "# " " # " "# #"[/color] nice idea though (parselst4 "#" '("#" "ASD" "ASDD" "DSA" " #" "#" " #" "FDS" "gfsfg" "#" " # ") ) (nil ("ASD" "ASDD" "DSA") nil ([color="red"]" #"[/color] "FDS" "gfsfg") ([color="red"]" # "[/color])) (parselst4 "#" '("#" "ASD" "ASDD" "DSA" " #" "#" " #" "FDS" "gfsfg" "#" " # ") ) (nil ("ASD" "ASDD" "DSA" [color="red"]" #"[/color]) ([color="red"]" #"[/color] "FDS" "gfsfg") ([color="red"]" # "[/color])) same bug here - brackets must be paired otherwise ; error: malformed list or extra right paren on input
  6. command call to avoid osnap bug (command "line" [color="red"]"_non"[/color] startpoint [color="red"]"_non"[/color] nextpoint "") another entmake based on OP dwgs. (defun c:LENLINE (/ l i s p e d ) (vl-cmdf "_UNDO" "_BE") (and (setq s (ssget '((0 . "LWPOLYLINE")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) d (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) p (mapcar '(lambda (x) ((eval (read (strcat "vlax-curve-get" x "Point"))) e)) '("Start" "End")) ) (entmakex (list '(0 . "LINE") (cons 10 (car p)) (cons 11 (setq p (polar (car p) (apply 'angle p) d))) ) ) (setq l (cons p l)) ) (entmakex (vl-list* '(0 . "LWPOLYLINE") '(62 . 6) '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(70 . 0) (cons 90 (length l)) (mapcar '(lambda (x) (cons 10 x)) (vl-sort l '(lambda (a b) (apply '< (mapcar 'car (list a b))))) ) ) ) ) (vl-cmdf "_UNDO" "_END") (princ) ) @Tharwat the example drawing the polylines extrusion i.e, normal = '(1 0 0)
  7. hanhphuc

    Get Unicode of characters in LISP

    hi, you only can write to asciii file, e.g .dxf, txt, csv etc.., but not a drawing file do you mean open a new drawing? just curious ac2007 ([color="blue"]ascii[/color] "\U+6C49") [color="green"];returns only 92 the first char[/color]
  8. hanhphuc

    The Xref name in a one pick

    no worries. you are welcome p/s: without lisp - just activate properties window
  9. hanhphuc

    Auto dimesioning polyline

    hi, a polyline is singular (vlax-curve-getdistatparam en (vlax-curve-getendparam en)) few examples : 1. by selections 2. by LineTypes 3. by groups
  10. hanhphuc

    The Xref name in a one pick

    (defun c:test (/ en s) (prompt "\nSelect an xref or block to get it name : ") (or (while (setq s (ssget "_:S:E+." '((0 . "INSERT")))) (if en (redraw en 4) ) (and (setq en (ssname s 0)) (progn (redraw en 3) (alert (strcat "XREF/block name :\n" (cdr (assoc 2 (entget en)))))) ) ) (alert "\nOops! no XREF or block selected?") ) (princ) )
  11. hanhphuc

    max and min coordinate in polyline

    BingoBox finally explained doubt thanks
  12. hanhphuc

    As-Built Deviation

    Nice idea. since the LINE being created, if only working in WCS i have an idea using FIELD - Line's delta property v2007 using qleader instead of mleader. [EDIT] since line's delta property is referenced to UCS, i.e: The deviations value can be updated while working in different UCS or WCS upon command REGEN - trans UCS & output 'str' to be evaluated in 'and' expression - Mtext justification entmod didn't work after addleader due to entlast was not MTEXT (vl-load-com) (defun c:[b]devtest2[/b] ( / *error* p1 p2 p3 ex del obj [color="red"]str mtx[/color] ) (setq *msps* ((lambda (doc) (foreach x '(ActiveDocument ActiveLayout Block) (setq doc (vlax-get doc x))) ) (vlax-get-acad-object) ) *error* '((msg) (princ "\n*cancel*")) ) (while (and (setq p1 (getpoint "\nPick 1st point.. ")) (setq p2 (getpoint "\nPick 2nd point.. ")) (setq en (entmakex (vl-list* '(0 . "LINE") '(8 . "DEVIATION") '(62 . (mapcar ''((a b)(cons a (set b ([color="blue"]trans[/color] (eval b) 1 0)))) '(10 11) '(p1 p2)))) obj (vlax-ename->vla-object en) p2 (mapcar ''((a b) (* (+ a b) 0.5)) p1 p2) ) (setq p3 (getpoint (trans p2 0 1) "\nSpecify leader landing location: ")) (setq p3 ([color="blue"]trans[/color] p3 1 0) del (vlax-get obj 'delta) [color="red"]str[/color] ([color="blue"]XY->field[/color] obj 2 0 1000 0)) ) (progn (vla-addleader *msps* (vlax-safearray-fill (vlax-make-safearray 5 '(0 . 5)) (append p2 p3 )) (progn (setq [color="red"]mtx[/color] (vla-addmtext *msps* (vlax-3d-point p3) (* (+ 3 (apply 'max (mapcar ''((x) (strlen (rtos x 2 3))) del))) (getvar 'textsize)) str ) ) [color="green"];;; Text justification revised using vla method [/color] (mapcar '(lambda (a b)(vlax-put [color="red"]mtx[/color] a b)) '(attachmentpoint Rotation) (list (if (car (mapcar '< p2 p3)) 4 6 ) (- (* 2. pi) (angle '(0. 0. 0.) (getvar 'ucsxdir))) ) ) mtx ) acLineWithArrow ) ) ;progn ) ; while (*error* nil) (princ) ) [color="green"];;; XY->FIELD : generates quick XY point field code - hanhphuc ;;;obj - VLA object ;;;u - units 1=Scientific 2=Decimal 3=Engineering 4=Architectural 5=Fractional 6=Current ;;;prec - precision ;;;sc - [color="red"]multiplier factor[/color] (credits: Inspired by Lee Mac's [url="http://lee-mac.com/fieldmath.html"]fieldmath[/url]) ;;;mode - (Points,*Text,Arc,Circle,Ellipse & Delta ) 0=default ;;; (Line,Arc,Ellipse) 1=Startpoint,2=Endpoint [/color] [color="green"];V1.1: fix to support start&endpoints, maintains 5 arguments[/color] (defun [b]XY->field[/b] (obj u prec sc mode / prop pfx xy ) (setq xy [color="red"] 0[/color] [color="green"];;;;user favorite prefix format default 0=E&N ,1=X&Y[/color] pfx (if (zerop xy) '("E " "N ") '("X " "Y ") ) ) (if (and (setq prop (nth mode (vl-remove nil (mapcar '(lambda (x) (if (vlax-property-available-p obj x) x ) ) '("Coordinates" "Center" "InsertionPoint" "TextPosition" "Origin" "Delta" "StartPoint" "EndPoint") ) ) ) ) (not (vlax-erased-p obj)) (<= (length (vlax-get obj prop)) 3) ) (apply 'strcat (mapcar '(lambda (a b c) (strcat a "%<\\AcExpr ("(rtos (float sc) u prec)" * %<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-objectid obj)) ">%)." prop " \\f \"%lu"(itoa u)"%pt" c "%pr8\">%" ") \\f \"%lu"(itoa u)"%pt" c "%qf1%pr"(itoa prec)"\">%" " \n" ) ) (if (= prop "Delta") (mapcar '(lambda(x)(strcat "d" x)) pfx ) pfx ) (vlax-get obj prop) '("1" "2") ) ) ) )
  13. hanhphuc

    As-Built Deviation

    no worries. putting arrow thanks ronjonp has shared his idea though ver 2007 does not have command mleader, IMO qleader could do the same.
  14. hanhphuc

    Embed linked images in Blocks

    hi i recall recently watched YouTube somewhere 1.open image *JPG *PNG *BMP (not sure REVIT image format) etc with paint.exe or other image editor apps 2.select all [Ctrl+A] 3.Copy selection [Ctrl+C] 4.open ACAD dwg in model space 5.menu - EDIT- paste special As (checked radio button) 'Picture(Metafile)' etc..
  15. hanhphuc

    max and min coordinate in polyline

    oops, i misunderstood. In case polyline has bulge, i thought OP looking merely min max like bbox thanks Lee
×