Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/21/2021 in all areas

  1. Why do you want a lisp? Have you tried using HATCHEDIT?
    1 point
  2. I think what your saying is make little functions that in turn use other predefined functions. That is what I call Library code or I guess CORE code. The running program may have like 1 line that calls 100 lines of code in another program. eg (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (setq ans (AH:getvalsm (list "This is heading" "Line 1" 5 4 "11" "Line2" 8 7 "22" "Line3" 8 7 "33" "Line4" 8 7 "4"))) This is a dcl input multi values from 1 to about 20 screen size limit. For those of us around for a while using core code is part of speeding up coding and reliability, 1 package Iwas involved in has 100 lisp files, the majority of the routines make calls to the core package, ensuring layer control etc. This is an example of get properties you decide what you want from an object. ; properties use as a library function ; By Alan H july 2020 (defun cords (obj / co-ords xy ) (setq coordsxy '()) (setq co-ords (vlax-get obj 'Coordinates)) (setq numb (/ (length co-ords) 2)) (setq I 0) (repeat numb (setq xy (list (nth (+ I 1) co-ords)(nth I co-ords) )) (setq coordsxy (cons xy coordsxy)) (setq I (+ I 2)) ) ) (defun AH:chkcwccw (obj / lst newarea) (setq lst (CORDS obj)) (setq newarea (/ (apply (function +) (mapcar (function (lambda (x y) (- (* (car x) (cadr y)) (* (car y) (cadr x))))) (cons (last lst) lst) l)) 2.) ) (if (< newarea 0) (setq cw "F") (setq cw "T") ) ) ; Can use reverse in Autocad - pedit reverse in Bricscad. (defun plprops (obj txt / lst) (foreach val lst (cond ((= (strcase val) "LAY") (setq lay (vla-get-layer obj))) ((= (strcase val) "AREA")(setq area (vla-get-area obj))) ((= (strcase val) "START")(setq start (vlax-curve-getstartpoint obj))) ((= (strcase val) "END" (strcase txt))(setq end (vlax-curve-getendpoint obj))) ((= (strcase val) "LEN" (strcase txt))(setq len (vlax-get obj 'Length))) ((= (strcase val) "CW" (strcase txt))(AH:chkcwccw obj)) ((= (strcase val) "CORDS" (strcase txt))(CORDS obj)) ) ) ) (defun lineprops (obj lst / ) (foreach val lst (cond ((= (strcase val) "LAY") (setq lay (vlax-get obj 'layer))) ((= (strcase val) "START")(setq start (vlax-get obj 'startpoint))) ((= (strcase val) "END" (strcase txt))(setq end (vlax-get obj 'endpoint))) ((= (strcase val) "LEN" (strcase txt))(setq len (vlax-get obj 'Length))) ) ) ) (defun circprops (obj lst / ) (foreach val lst (cond ((= (strcase val) "LAY") (setq lay (vlax-get obj 'layer))) ((= (strcase val) "LEN" (strcase txt))(setq len (vlax-get obj 'Circumference))) ((= (strcase val) "RAD" (strcase txt))(setq rad (vla-get-radius obj))) ((= (strcase val) "CEN" (strcase txt))(setq cen (vlax-get obj 'Center))) ((= (strcase val) "AREA" (strcase txt))(setq end (vlax-get obj 'AREA))) ) ) ) (defun arcprops (obj txtlst) (foreach val lst (cond ((= (strcase val) "LAY") (setq lay (vlax-get obj 'layer))) ((= (strcase val) "LEN" (strcase txt))(setq len (vlax-get obj 'length))) ((= (strcase val) "RAD" (strcase txt))(setq rad (vla-get-radius obj))) ((= (strcase val) "CEN" (strcase txt))(setq cen (vlax-get obj 'Center))) ((= (strcase val) "START" (strcase txt))(setq area (vlax-get obj 'startpoint))) ((= (strcase val) "END" (strcase txt))(setq area (vlax-get obj 'endpoint))) ((= (strcase val) "AREA" (strcase txt))(setq end (vlax-get obj 'AREA))) ) ) ) ; starts here (setq ent (vlax-ename->vla-object (car (entsel "Pick Object ")))) ; do a check for object type then use defun ; pick an example below ; many examples copy to command line for testing mix and match ; (plprops ent '("LAY"))(princ lay) ; (plprops ent '("END"))(princ end) ; (plprops ent '("START"))(princ start) ; (plprops ent '("END" "START"))(princ end)(princ start) ; (plprops ent '("AREA" "LAY" "END" "START"))(princ area)(princ lay)(princ end)(princ start) ; (plprops ent '("START" "AREA" "LAY" "CW"))(princ start)(princ area)(princ cw) ; (plprops ent '("start" "END" "CORDS" "cw"))(princ start)(princ end)(princ coordsxy)(princ cw) ; (plprops ent '("CW"))(princ cw) ; (plprops ent '("AREA"))(princ area) ; (plprops ent '("CORDS"))(princ coordsxy) ; (lineprops ent "len"))(princ len) ; (lineprops ent '("len" "lay"))(princ len)(princ lay) ; (lineprops ent '("lay" "end" "start" "len"))(princ len)(princ lay)(princ start)(princ end) ; (circprops ent '("lay" "rad" "area" "cen"))(princ lay)(princ rad)(princ area)(princ cen) ; (circprops ent '("lay" "rad")) ; (arcprops ent '("lay" "rad"))
    1 point
  3. Not sure what your doing wrong this is what you are talking about, but Autocad or Bricscad. Only way for any one to check would be to post a dwg and a pdf.
    1 point
  4. Sorry I was under a dead line at work. Someone please correct me if I am wrong but vla-put-Activedimstyle only changes the active dimension style set in the drawing. Tried to modify what i posted to work but kept doing weird stuff. but like my buddy confutatis says "Eh, I know, but sometimes laziness..." So i just went with the vl-cmdf route. (if (setq A1 (ssget "_X" '((0 . "DIMENSION")))) (progn ;added because multiple lines of code foreach and the two dimstyle commands (vl-cmdf "-DIMSTYLE" "RESTORE" "MyDimStyle") ;change to the style you want, only need to do this once outside foreach (vl-cmdf "-DIMSTYLE" "APPLY" A1 "") ; this can be applyed to everything at once so its outside the foreach for speed. (foreach ent (mapcar 'cadr (ssnamex A1)) ;This will change everything in A1 selection even if its on another tab. (vla-put-layer (vlax-ename->vla-object ent) "Dim") ;this will error if Dim layer isn't created (vla-put-color (vlax-ename->vla-object ent) "256") (vla-put-lineweight (vlax-ename->vla-object ent) "-1") (vla-put-linetype (vlax-ename->vla-object ent) "ByLayer") ) ) (prompt "\nNo dimension!") ) This is a learning experience for me as well. thought you could only do matchprop to update dimstyles.
    1 point
  5. Seems a lot of effort to do (alert "hello world\n \nhey its 4:30 Beer o clock") or ; bit of fun (defun SpeakSapi ( s / sapi ) (if (eq (type s) 'STR) (progn (setq sapi (vlax-create-object "Sapi.SpVoice")) (vlax-put sapi 'SynchronousSpeakTimeout 1) (vlax-invoke-method sapi 'WaitUntilDone 0) (vlax-invoke sapi "Speak" s 0) (vlax-release-object sapi) ))) (speaksapi "Hello world") (speaksapi "Welcome from BIG al the humour you can expect at times") (speaksapi "PLEASE PAY YOUR MONEY") (speaksapi "I know you have wound the clock back" ) (speaksapi "Call me on 1234 5678 if you like the software") (princ) Autodesk are going down the visual studio path as their future direction, not sure how that fits in with your preference.
    1 point
  6. Consider the vlax-Curve-GetStartPoint, and vlax-Curve-GetPointAtParam functions. Cheers
    1 point
×
×
  • Create New...