Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/05/2024 in all areas

  1. A linetype can be read from a .lin file no need for code. *HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ---- A,12.7,-5.08,["HW",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08 We had custom.lin with lots of linetypes and would preload into our dwt so ready to go. Or Linetype Load 1 or more linetype into a dwg. ;load missing linetypes ;;; returns: T if loaded else nil (loadLinetype doc "Fence" "custom.lin") (loadLinetype doc "Tree" "custom.lin") (setq doc (vla-get-activedocument (vlax-get-acad-object))) ; open database (defun loadLinetype (doc LineTypeName FileName) (if (and (not (existLinetype doc LineTypeName)) (vl-catch-all-error-p (vl-catch-all-apply 'vla-load (list (vla-get-Linetypes doc) LineTypeName FileName ) ) ) ) nil T ) ) (defun existLinetype (doc LineTypeName / item loaded) (vlax-for item (vla-get-linetypes doc) (if (= (strcase (vla-get-name item)) (strcase LineTypeName)) (setq loaded T) ) ) )
    2 points
  2. Often I have to (ok , I want to) edit text (or blocks) directly on screen that are in a sort of table like order. Then it would be nice to be able sort it in rows & columns. In a perfect world all items would be spaced evenly. But we're not living in a perfect world now are we? Besides , that would be boring. Had something like this written a very long time ago but lately needed to be able to see if sorting order was correct before doing my stuff. So also for the fun of it I created mini app to sort things out (but not in my head) Anyways , added routine including a couple of tiny test functions. My own needs are a little bit more complex because need to be able to apply it on (sometimes specific) attributes in blocks too , but I leave the specialities for you little dragons Working is as follows: Select a group of simple text's (you can use attached drawing). The shape of your selection determines if you sort by row or by column (landscape means rows , portrait means columns. It uses the boundary size from 1st item in selection as a fuzz factor , some blocks are a little up , some a little down etc. This you can check by selecting the blocks on the left side of the sample drawing. After you made selection all insertionpoints (or text alignment points) the points are marked with blue number indication their rank on the social ladder. After this I use (grread) in a loop where you can use Tab to switch between ByRow & ByColumn , Spacebar to cycle in which Quadrant to start numbering and Enter means you're a happy human of planet earth. (C:t1) just shows you the list , (C:t2) you can replace the texts with another string. Rlx-Sort-SS.dwg RlxSortSS.lsp
    2 points
  3. sq mm to sq m is just a division. (/ 234234234 1e6) 234.234234 (/ 234234234 1000000) 234 (/ 224234234 1000000.) 224.234234 (setq str (strcat "Area is " (rtos area 2 2) "m" (chr 178))) "Area is 123.45m²" The chr 178 can be different in some text fonts.
    1 point
  4. Please have a look at the youtube it talks about how to convert same type objects to a block. The second dwg is fine as it has blocks for the clamps. But no sleeper out line. Sleeper-4 is different again, so a new code again. Please see PM as we can discuss off the forum while we go back and forth.
    1 point
  5. you can use (cvunit asum "sq_mm" "sq_m") to convert it. Additionally you could read insunits to check if that unit is actually used. (defun c:BB ( / ss index asum e obj tmparea msp spt txtobj dwgunit) (if (setq ss (ssget (list (cons 0 "CIRCLE,ARC,LWPOLYLINE,ELLIPSE,SPLINE")))) (progn (setq msp (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq index 0 asum 0) (repeat (sslength ss) (setq e (ssname ss index)) (setq obj (vlax-ename->vla-object e)) (setq tmparea (vla-get-area obj)) (setq asum (+ asum tmparea)) (setq index (1+ index)) ) (if (not (setq dwgunit (cdr (assoc (getvar "insunits") '((4 . "sq_mm")(5 . "sq_cm")(6 . "sq_m")))))) (progn (princ "\nError with dwg unit")(exit))) (setq asum (cvunit asum dwgunit "sq_m")) (prompt (strcat "\nTotal area = " (rtos asum 2 2) " m²")) (initget 1) (setq spt (getpoint "\nText start point: ")) (setq txtobj (vla-addtext msp (strcat (rtos asum 2 2) " m²") (vlax-3d-point spt) (getvar "textsize"))) ) ) (princ) )
    1 point
  6. Try this. Note your values in sample did not match the Excel values added more. ; https://www.cadtutor.net/forum/topic/87091-changing-dynamic-block-attribute-value-from-excel/ (defun c:ex2atts (/ row column lst x atts att obj st end) (if (not ColumnRow)(load "alan excel library3")) (getrangexl) (setq row 2 column (cadr end) lst '()) (repeat (- (car end) 1) (setq lst (cons (list (getcell2 row (- column 1))(getcell2 row column)) lst)) (setq row (1+ row)) ) (setq ss (ssget '((0 . "INSERT")(66 . 1)))) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (setq atts (vlax-invoke obj 'Getattributes)) (foreach att atts (if (= (vlax-get att "tagstring") "REF") (progn (setq val (vlax-get att 'textstring)) (foreach lstval lst (if (= (car lstval) val) (vlax-put att 'Textstring (cadr lstval)) ) ) ) ) ) ) (princ) ) (c:ex2atts)
    1 point
  7. Hi Cary, I might approach it like this: (defun CloseReactor nil (vl-load-com) ;; Lee Mac ~ 14.04.10 ( (lambda ( data / react ) (if (setq react (vl-some (function (lambda ( reactor ) (if (eq data (vlr-data reactor)) reactor) ) ) (cdar (vlr-reactors :vlr-editor-reactor) ) ) ) (if (vlr-added-p react) (vlr-remove react) (vlr-add react) ) (setq react (vlr-editor-reactor data (list (cons :vlr-beginclose 'CloseCallBack) ) ) ) ) (princ (if (vlr-added-p react) "\n** Reactor Activated **" "\n** Reactor Deactivated **" ) ) react ) "Close-Reactor" ) (princ) ) (defun CloseCallBack (reactor arguments) (vla-put-ActiveSpace (setq doc (vla-get-ActiveDocument (setq acad (vlax-get-acad-object)) ) ) acModelSpace ) (vla-ZoomExtents acad) (vla-put-ActiveLayer doc (vla-item (vla-get-layers doc) "0" ) ) (vla-put-ActiveUCS doc (vla-add (vla-get-usercoordinatesystems doc) (vlax-3D-point '(0. 0. 0.)) (vlax-3D-point '(1. 0. 0.)) (vlax-3D-point '(0. 1. 0.)) "TempWord_UCS" ) ) (if (not (eq "" (vla-get-FullName doc))) (vla-saveas doc (vla-get-FullName doc)) ) (princ) ) Here, the reactor function is a toggle, and can be toggled on and off whilst the drawing is open. The reactor will only save the drawing if the drawing has been saved previously. Its untested, but hopefully should work for you. Lee
    1 point
×
×
  • Create New...