Leaderboard
Popular Content
Showing content with the highest reputation on 04/09/2024 in all areas
-
There are a few people going down this path, making ARX function library, I know of another to do with Excel functions. Yes have tested them, but still use lisp. Another is a poster pushing python code again need a runtime. I stay away from 3rd party add ons like DOSLIB have enough problems with clients just running lisps, without adding an extra load that they struggle to do. Look at LT2024 no DOSLIB.1 point
-
Another way is to use foreach. (setq blks (list "SW1FRM" "SW1PNL" "EW1FRM" "EW1PNL")) (foreach blk blks (if (tblsearch "BLOCK" blk) (if (tblsearch "BLOCK" "MBS_TABLES.dwg") (princ "exists") (command "-INSERT" "MBS_TABLES.dwg" "0,-50" txthtscld "0") ) ) )1 point
-
This one will now export it to a CSV file. Type CRVTOTALCSV to run the command. CurveTotal_csv.LSP1 point
-
@Steven P His "xdrx" command are actually a whole library written in ObjectARX. He should be including the link to his Github for it: https://github.com/xdcad/XDrx-API. It's not open source however, but it's free. Think of it like McNeel's DOSLIB, but much bigger. He is basically trying to open up a big chunk of the ObjectARX API to Visual LISP. Even though I applaud his efforts, I personally won't use it yet: 1) I don't trust any new thing like this, if not open source, and not well known, tested and established in the community like DOSLIB. Perhaps as things move on and more give it approval, I will try it out. 2) I don't like being dependant on a 3rd party add-on (even DOSLIB), and prefer to find out how I can accomplish it myself.1 point
-
@C. Roberts Actually, now that I think about it - here is a much shorter way! (setq blks (list "SW1FRM" "SW1PNL" "EW1FRM" "EW1PNL") ex (if (vl-remove-if 'null (mapcar '(lambda (x)(if (tblsearch "BLOCK" x) T nil)) blks)) T nil) ) OR as a function: (defun Blockp (l) (if (vl-remove-if 'null (mapcar '(lambda (x)(if (tblsearch "BLOCK" x) T nil)) l)) T nil) ) ;;Example: (Blockp (list "SW1FRM" "SW1PNL" "EW1FRM" "EW1PNL"))1 point
-
For those who don't know the basics of Visual LISP: don't forget to add (vl-load-com) to the top of the routine.1 point
-
(defun c:XDTB_DWGCUT (/ dynpt e lastpnt myerr olderr pts ss ss1 tf) (defun _callback (dynpt) (xdrx_entity_move ss lastpnt dynpt) (setq lastpnt dynpt) ) (defun _move (ss) (setq lastpnt (trans (xd::geom:get9pt ss 5)1 0)) (xdrx_pointmonitor "_callback" ss) (initget 1) (getpoint (xdrx-string-multilanguage "\n插入点:""\nInsert Point:")) (xdrx_pointmonitor) ) (defun myerr (msg) (princ "\n*cancel") (xdrx_end) (vl-cmdf ".undo" 1) (setq *error* olderr) (princ) ) (xdrx_begin) (setq olderr *error*) (setq *error* myerr) (setq pts nil) (if (setq e (car (xdrx_entsel (xdrx-string-multilanguage "\n请拾取裁剪边界<退出>:""\nPlease pick the cropping boundary <Exit>:") '((0 . "lwpolyline,circle,ellipse,spline")) ) ) ) (progn (setq tf (xdrx-document-safezoom e)) (setq pts (xdrx_getsamplept e) ss (ssget "cp" (xd::pnts:wcs2ucs pts)) ) (if (setq ss1 (xdrx_geom_clipboundary ss e t t)) (progn (if tf (xdrx_document_zoomprevious) ) (ssadd e ss1) (_move ss1) ) ) ) ) (setq *error* olderr) (xdrx_end) (princ) ) [XDrX-PlugIn(83)] DWG cutting (theswamp.org) https://www.theswamp.org/index.php?topic=59019.01 point
-
I left work before IT could get back to me. Maybe they can get it sorted with Autodesk.1 point
-
1 point
-
1 point
-
Autolisp way (defun C:PL0 (/ ss) ;; Set PolyLine Width to 0.0 (setq ss (ssget ":L")) (foreach poly (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS)))) (vla-put-lineweight poly 0) ) (princ) )1 point
-
fyi if your using entmake 62 will only works with colors 1 - 256 for true colors you need to use 420 you can have the user select what color they want with (setq col (acad_truecolordlg (62 . 1)) ;true color menu defaults to red (setq col (acad_truecolordlg (420 . 8227074)) ;true color menu defaults to 125 20 50 ;; RGB -> True - Lee Mac ;; Args: r,g,b - [int] Red, Green, Blue values (defun LM:RGB->True ( r g b ) (logior (lsh (fix r) 16) (lsh (fix g) 8) (fix b)) ) ;; True -> RGB - Lee Mac ;; Args: c - [int] True Colour (defun LM:True->RGB ( c ) (mapcar '(lambda ( x ) (lsh (lsh (fix c) x) -24)) '(8 16 24)) )1 point
-
An example entmake layer. (defun Layer (Name Col Ltyp LWgt Plt) (entmake (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (cons 2 Name) (cons 70 0) (cons 62 Col) (cons 6 Ltyp) (cons 290 Plt) (cons 370 LWgt))))1 point
-
This one works well for me (DEFUN C:PLW0 (/ ss1) ;; Set PolyLine Width to 0.0 (setq ss1 (ssget ":L")) (command "_.PEDIT" "_M" ss1 "" "_W" 0.0 "") (princ) ) Steve1 point
-
I would go the entmake route its a lot cleaner and less spam in the command prompt. @ronjonp made a good one. it also "attempt to load the linetype if found in the acad*.lin file and if the layer exists, it will update the properties." https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-layer-with-true-color-in-lisp/m-p/7904814/highlight/true#M367339 (_addlayer "NewLayerName" '(69 69 69) "3Dash2" 1) changes to (_addlayer "NewLayerName" (list colorR colorG colorB) "3Dash2" 1)1 point
-
(defun c:linesthickness-0 ( / s i e ex ) (prompt "\nSelect LINE entities...") (setq s (ssget "_:L" (list (cons 0 "LINE")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i)))) (if (assoc 39 (setq ex (entget e))) (entupd (cdr (assoc -1 (entmod (subst (cons 39 0.0) (assoc 39 ex) ex))))) ) ) (princ) )1 point
-
1 point
-
1 point
-
I think I commented earlier, it would be far more convenient for us if you post the code in the same thread as the question was asked, rather than starting a new single post thread without any context in another forum.1 point
-
It would be easier to post the code here in case anyone doesn't have an account over in theswamp1 point
-
It can be done fairly simply but it needs your help, as the objects are on same layer this complicates things so 1st step is change dims to a new layer, 2nd step change plines to a new layer. Once this is done can just isolate 2 layers the text and the pline. Its a simple look for text say ST1 then search above it for a pline, can then simply block that object with correct name. So try editing the dwg making common objects on layers and code will be easy to do. Re post new dwg. If you want as blocks why not draw correct 1st up I would use a lisp to draw looks like 2 patterns, a triangle and a chamfered corner rectang, can do which way up and which corner pretty easy. As part of lisp makes block. The dwg should really be using lots of layers not everything on layer 0. But I would have lisps for a lot of what your drafting like slots. They could be dynamic blocks, width and length, bolt holes patterns and so much more.1 point
-
(defun c:dimdiv ( / *error* acdoc oldosmode oldcmdecho ent entlist num pt1 pt2 pt3 pt4 entl objl measurevalue digits rounddownvalue lsf ssl index ) (vl-load-com) (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))) (defun *error* ( msg ) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (setvar 'osmode oldosmode) (setvar 'cmdecho oldcmdecho) (vla-EndUndoMark acdoc) (princ) ) ;; Round Down - Lee Mac ;; Rounds 'n' down to the nearest 'm' (defun LM:rounddown (n m) ((lambda (r) (cond ((equal 0.0 r 1e-8) n) ((< n 0) (- n r m)) ((- n r)))) (rem n m) ) ) (vla-StartUndoMark acdoc) (setq oldosmode (getvar 'osmode)) (setq oldcmdecho (getvar 'cmdecho)) (setvar 'cmdecho 0) (setvar 'osmode 0) (princ "\n Pick Dimension : ") (if (setq ss (ssget '((0 . "DIMENSION")))) (progn (setq num (getint "\nEnter how many divisons ")) (setq ssl (sslength ss)) (setq index 0) (repeat ssl (setq ent (ssname ss index)) (setq entlist (entget ent)) (setq pt1 (cdr (assoc 13 entlist))) (setq pt2 (cdr (assoc 14 entlist))) (setq pt3 (cdr (assoc 10 entlist))) (setq dist (/ (distance pt1 pt2) num)) (setq ang (angle pt1 pt2)) (setq lsf (vlax-get-property (vlax-ename->vla-object ent) 'linearscalefactor)) (entdel ent) (repeat num (setq pt4 (polar pt1 ang dist)) (command "DIM" "align" pt1 pt4 pt3 "" "exit") (setq entl (entlast)) (setq objl (vlax-ename->vla-object entl)) (vlax-put-property objl 'linearscalefactor lsf) (setq measurevalue (vlax-get-property objl 'measurement)) (setq digits (strlen (rtos measurevalue 2 0))) (setq rounddownvalue (LM:rounddown measurevalue (expt 10 (- digits 2)))) (vlax-put-property objl 'textoverride rounddownvalue) (setq pt1 pt4) ) (setq index (+ index 1)) ) ) (progn) ) (setvar 'osmode oldosmode) (setvar 'cmdecho oldcmdecho) (vla-EndUndoMark acdoc) (princ) ) maybe osmode do that?1 point