Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/09/2024 in all areas

  1. Simple example - (defun c:sqcircle ( / ent enx ins len ocs ) (cond ( (not (setq ent (car (entsel "\nSelect circle: "))))) ( (/= "CIRCLE" (cdr (assoc 0 (setq enx (entget ent))))) (princ "\nObject is not a circle.") ) ( (not (setq ins (getpoint "\nPoint for square: ")))) ( (setq ocs (trans '(0 0 1) 1 0 t) len (* (sqrt pi) (cdr (assoc 40 enx))) ) (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(090 . 4) '(070 . 1) (cons 010 (trans ins 1 ocs)) (cons 010 (trans (mapcar '+ ins (list len 0.0)) 1 ocs)) (cons 010 (trans (mapcar '+ ins (list len len)) 1 ocs)) (cons 010 (trans (mapcar '+ ins (list 0.0 len)) 1 ocs)) (cons 210 ocs) ) ) ) ) (princ) )
    1 point
  2. I have some experience with python / AutoCAD integration with the wrappers I’m working on https://github.com/CEXT-Dan/PyRx Its all in process though, I don’t have much experience out of process though. Post a sample, I’ll try to help
    1 point
  3. I have modified this batch convertor, it works on an entire folder and should SaveAs 2013. (not tested) You can also convert to older versions with DWGConvert in newer AutoCAD (not sure first version), eTransmit and DWG TrueView. ;;;|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ;;; | ;;;<<<<<<<<<<<<<<<<<<<<<<<<>Modified to Batch Convert AutoCAD® DWG *.dwg into AutoCAD® DWG *.dwg>>>>>>>>>>>>>>>>>>>>>>>>>>| ;;; | ;;;|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ;;; | ;;; Original versions I got from here | ;;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-convert-dgn-to-dwg/td-p/3237978 | ;;; | ;;;|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ;;; ;;;* DGNIMPORT.LSP - Converts a list of Microstation *.dgn drawings into AutoCAD *.dwg drawings ;;; Start command by typing DGNI ;;; ;;; Make the necessary adjustments to the following variables: ;;; --------------------------------------------------------- ;;; tx1 = path and name of a file that holds a list with names for all the *.dgn's to be imported, ;;; names of *.dgn drawings may be written without extension, as well as with extension, ;;; in plain text format, no return after the last line. ;;; tx2 = the path for the input folder, containing the actual *.dgn files to import. ;;; tx3 = the path for the output folder, where the drawings converted into *.dwg will be saved, ;;; (routine assumes that the *.dwg files do not exist yet) ;;; tx4 = name of the drawing model to import ;;; ;;; ;;; The routine reads drawing names from the file given in tx1 line-for-line. ;;; In each loop it performs a DGNIMPORT from the folder given as tx2 into the existing AutoCAD drawing, ;;; does a Zoom Extends, saves the converted drawing result as *.dwg in the folder given as tx3, ;;; and finally restores the drawing to its original state, ready to receive the next DGNIMPORT loop. ;;; ;;; The DELAY command for 1000 milliseconds (1 second) is needed to provide sufficient separation ;;; between the DGNIMPORT and SAVEAS processes (otherwise it starts to mix up drawings). ;;; ;;; The DGNIMPORT command trips when the name of the *.dgn to be imported contains a comma, ;;; I advise to rename drawings having this issue. ;;; ;;; Written by M. Moolhuysen. Modified by C. Matthews ;;; ;;; Modified by Cage Here https://www.cadtutor.net/forum/topic/78123-batch-convert-acis-sat-to-dwg/#comment-624627 ;;; ;;; This software may not be sold as commercial product or included as part of a commercial product. ;;; ;;; ;;;************************************************************************************************************************ ;;;************************************************************************************************************************ ;;; * ;;; Converts a folder of AutoCAD® DWG *.dwg drawings into AutoCAD® DWG *.dwg drawings (Version 2013) * ;;; * ;;; Start command by typing DWG2DWG * ;;; * ;;; Modified by SLW210 A.K.A. Steve Wilson from DGNIMPORT to DWG2DWG 01/31/2024 * ;;; * ;;;************************************************************************************************************************ ;;;************************************************************************************************************************ (defun C:DWG2DWG (/ fil tx1 tx2 tx3 tx4 tx5) (princ "Please select input folder. \n") (setq tx1 (vl-directory-files (setq tx2 (acet-ui-pickdir)) "*.dwg")) ; Select the folder containing *.dwg files to be imported. (princ "Please select output folder. \n") (setq tx3 (acet-ui-pickdir) ; Select folder for the converted *.dwg files to be exported into. tx4 "Default" ) (setvar "FILEDIA" 0) (foreach tx5 tx1 (if (wcmatch tx5 "*`.???") (setq tx5 (substr tx5 1 (- (strlen tx5) 4))) ) (command "_UNDO" "_MARK" "OPEN" "" (strcat tx2 "\\" tx5) tx4 "" "" "_ZOOM" "_E" "._DELAY" 500 "_SAVEAS" "D" "V" "2013" "16" (strcat tx3 "\\" tx5 ".dwg") "_N" ; change SaveAs version etc. here. ) (command "_ERASE" "ALL" "") ;erases everything on the page after the save (command "_.purge" "_all" "" "_no") ;purges everything so you don't carry it over to the next drawing (command "_.purge" "_regapp" "" "_no") (command "_QNEW") ;opens a new drawing (setvar "FILEDIA" 0) ) (princ) )
    1 point
  4. I moved your thread to the .NET, ObjectARX & VBA Forum.
    1 point
  5. Not sure but it seems to me at this point (command "layer" "s" "WB5611----_RADIATOR" "" ) (command "insert" "radiator" pt4 lengte 100 (/ (* ang 180.0) pi)) You could use Bedit calling radiator then do a Bsaveas with the new name, then insert the new block with correct scale based on length. This will also keep radiator for further use. Will have a play. Try this. ;; DCL List-Tile Dependency - V1.1 (2019-04-27) - Lee Mac ;; Configures action_tile statements for the list of keys to enabled dependency between the DCL tiles. ;; key - [lst] List of DCL tile keys in order of dependency ;; lst-sym - [sym] Quoted variable containing list data ;; rtn-sym - [sym] Quoted variable containing initial selection indexes (defun LM:dcld:action ( key lst-sym rtn-sym ) (defun LM:dcld:addlist ( key lst ) (start_list key) (foreach itm lst (add_list itm)) (end_list) ) (defun LM:dcld:getlists ( idx lst ) (if (cdr idx) (cons (mapcar 'car lst) (LM:dcld:getlists (cdr idx) (cdr (nth (car idx) lst)))) lst ) ) (defun LM:substnth ( itm idx lst ) (if lst (if (zerop idx) (cons itm (mapcar '(lambda ( x ) 0) (cdr lst))) (cons (car lst) (LM:substnth itm (1- idx) (cdr lst))) ) ) ) (defun LM:dcld:actions ( key lst-sym rtn-sym lvl / fun ) (setq fun (if (cdr key) (list 'lambda '( val lst ) (list 'setq rtn-sym (list 'LM:substnth '(atoi val) lvl rtn-sym)) (list 'LM:dcld:addlist (cadr key) (list 'nth (1+ lvl) (list 'LM:dcld:getlists rtn-sym 'lst))) (list (LM:dcld:actions (cdr key) lst-sym rtn-sym (1+ lvl)) (list 'set_tile (cadr key) "0") 'lst ) ) (list 'lambda '( val lst ) (list 'setq rtn-sym (list 'LM:substnth '(atoi val) lvl rtn-sym)) ) ) ) (action_tile (car key) (vl-prin1-to-string (list fun '$value lst-sym))) fun ) (mapcar 'LM:dcld:addlist key (LM:dcld:getlists (eval rtn-sym) (eval lst-sym))) ( (eval (LM:dcld:actions key lst-sym rtn-sym 0)) (set_tile (car key) (itoa (car (eval rtn-sym)))) (eval lst-sym) ) (princ) ) ;; DCL List-Tile Dependency - Get Items - Lee Mac ;; Returns a list of the items selected from each dependent list tile. ;; idx - [lst] List of selection indexes ;; lst - [lst] List data (defun LM:dcld:getitems ( idx lst / tmp ) (if (cdr idx) (cons (car (setq tmp (nth (car idx) lst))) (LM:dcld:getitems (cdr idx) (cdr tmp))) (list (nth (car idx) (car lst))) ) ) ;; Two List Tile Dependency Example - Lee Mac ;; Requires ListTileDependency.lsp to be loaded. ;------------------------------------------------------START MAIN FUNCTION------------------------------------ (defun c:CBLL ( / *error* dch dcl des lst rtn) (defun *error* ( msg ) (if (= 'file (type des)) (close des) ) (if (< 0 dch) (unload_dialog dch) ) (if (and (= 'str (type dcl)) (findfile dcl)) (vl-file-delete dcl) ) (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))) (princ (strcat "\nError: " msg)) ) (princ) ) (setq lst '( ("300" ("500" ("300x500_T21S_378W" "300x500_T22_471W")) ("600" ("300x600_T21S_453W" "300x600_T22_565W")) ("800" ("300x800_T21S_604W" "300x800_T22_754W" "300x800_T33_1067W")) ("1000" ("300x1000_T22_945W" "300x1000_T33_1334W")) ("1200" ("300x1200_T22_1130W" "300x1200_T33_1601W")) ("1300" ("300x1300_T22_1225W" "300x1300_T33_1734W")) ("1400" ("300x1400_T22_1319W" "300x1400_T33_1868W")) ("1600" ("300x1600_T22_1507W" "300x1600_T33_2134W")) ("1800" ("300x1800_T22_1696W" "300x1800_T33_2401W")) ("2000" ("300x2000_T22_1884W" "300x2000_T33_2668W")) ) ("400" ("400" ("400x400_T11_266W")) ("500" ("400x500_T11_333W" "400x500_T21S_477W" "400x500_T22_601W")) ("600" ("400x600_T11_400W" "400x600_T21S_572W" "400x600_T22_721W" "400x600_T33_1020W")) ("700" ("400x700_T11_466W")) ("800" ("400x800_T11_533W" "400x800_T21S_762W" "400x800_T22_962W" "400x800_T33_1360W")) ("900" ("400x900_T11_599W")) ("1000" ("400x1000_T11_667W" "400x1000_T21S_953W" "400x1000_T22_1202W" "400x1000_T33_1700W")) ("1100" ("400x1100_T11_733W")) ("1200" ("400x1200_T11_799W" "400x1200_T21S_1144W" "400x1200_T22_1442W" "400x1200_T33_2040W")) ("1300" ("400x1300_T11_866W" "400x1300_T21S_1239W" "400x1300_T22_1563W" "400x1300_T33_2210W")) ("1400" ("400x1400_T11_932W" "400x1400_T21S_1334W" "400x1400_T22_1683W" "400x1400_T33_2380W")) ("1600" ("400x1600_T11_1066W" "400x1600_T21S_1525W" "400x1600_T22_1923W" "400x1600_T33_2720W")) ("1800" ("400x1800_T11_1199W" "400x1800_T21S_1715W" "400x1800_T22_2164W" "400x1800_T33_3060W")) ("2000" ("400x2000_T11_1332W" "400x2000_T21S_1906W" "400x2000_T22_2404W" "400x2000_T33_3400W")) ) ("500" ("400" ("500x400_T11_321W" "500x400_T21S_456W" "500x400_T22_580W")) ("500" ("500x500_T11_401W" "500x500_T21S_571W" "500x500_T22_725W" "500x500_T33_1024W")) ("600" ("500x600_T11_481W" "500x600_T21S_685W" "500x600_T22_869W" "500x600_T33_1229W")) ("700" ("500x700_T11_561W" "500x700_T21S_799W" "500x700_T22_1014W" "500x700_T33_1434W")) ("800" ("500x800_T11_642W" "500x800_T21S_913W" "500x800_T22_1159W" "500x800_T33_1638W")) ("900" ("500x900_T11_722W" "500x900_T21S_1027W" "500x900_T22_1304W" "500x900_T33_1843W")) ("1000" ("500x1000_T11_802W" "500x1000_T21S_1141W" "500x1000_T22_1449W" "500x1000_T33_2048W")) ("1100" ("500x1100_T11_882W" "500x1100_T21S_1255W" "500x1100_T22_1594W" "500x1100_T33_2253W")) ("1200" ("500x1200_T11_962W" "500x1200_T21S_1369W" "500x1200_T22_1739W" "500x1200_T33_2458W")) ("1300" ("500x1300_T11_1043W" "500x1300_T22_1884W" "500x1300_T33_2662W")) ("1400" ("500x1400_T11_1123W" "500x1400_T21S_1597W" "500x1400_T22_2029W" "500x1400_T33_2867W")) ("1600" ("500x1600_T11_1283W" "500x1600_T21S_1826W" "500x1600_T22_2318W" "500x1600_T33_3277W")) ("1800" ("500x1800_T11_1444W" "500x1800_T21S_2054W" "500x1800_T22_2608W" "500x1800_T33_3686W")) ("2000" ("500x2000_T11_1604W" "500x2000_T21S_2282W" "500x2000_T22_2898W" "500x2000_T33_4096W")) ) ("600" ("400" ("600x400_T11_374W" "600x400_T21S_529W" "600x400_T22_673W")) ("500" ("600x500_T11_467W" "600x500_T21S_661W" "600x500_T22_842W" "600x500_T33_1190W")) ("600" ("600x600_T11_560W" "600x600_T21S_793W" "600x600_T22_1010W" "600x600_T33_1427W")) ("700" ("600x700_T11_654W" "600x700_T21S_925W" "600x700_T22_1178W" "600x700_T33_1665W")) ("800" ("600x800_T11_747W" "600x800_T21S_1058W" "600x800_T22_1346W" "600x800_T33_1903W")) ("900" ("600x900_T11_841W" "600x900_T21S_1190W" "600x900_T22_1515W" "600x900_T33_2141W")) ("1000" ("600x1000_T11_934W" "600x1000_T21S_1322W" "600x1000_T22_1683W" "600x1000_T33_2379W")) ("1100" ("600x1100_T11_1027W" "600x1100_T21S_1454W" "600x1100_T22_1851W" "600x1100_T33_2617W")) ("1200" ("600x1200_T11_1121W" "600x1200_T21S_1586W" "600x1200_T22_2020W" "600x1200_T33_2855W")) ("1300" ("600x1300_T11_1214W" "600x1300_T21S_1719W" "600x1300_T22_2188W" "600x1300_T33_3093W")) ("1400" ("600x1400_T11_1308W" "600x1400_T21S_1851W" "600x1400_T22_2356W" "600x1400_T33_3331W")) ("1600" ("600x1600_T11_1494W" "600x1600_T21S_2115W" "600x1600_T22_2693W" "600x1600_T33_3806W")) ("1800" ("600x1800_T11_1681W" "600x1800_T21S_2380W" "600x1800_T22_3029W" "600x1800_T33_4282W")) ("2000" ("600x2000_T11_1868W" "600x2000_T21S_2644W" "600x2000_T22_3366W" "600x2000_T33_4758W")) ) ("700" ("400" ( "700x400_T21S_600W" "700x400_T22_763W")) ("500" ( "700x500_T21S_750W" "700x500_T22_954W" "700x500_T33_1348w")) ("600" ( "700x600_T21S_899W" "700x600_T22_1144W" "700x600_T33_1618W")) ("700" ( "700x700_T21S_1049W" "700x700_T22_1335W" "700x700_T33_1887W")) ("800" ( "700x800_T21S_1199W" "700x800_T22_1526W" "700x800_T33_2157W")) ("900" ( "700x900_T21S_1349W" "700x900_T22_1716W" "700x900_T33_2426W")) ("1000" ( "700x1000_T21S_1499W" "700x1000_T22_1907W" "700x1000_T33_2696W")) ("1100" ( "700x1100_T21S_1649W" "700x1100_T22_2098W")) ("1200" ( "700x1200_T21S_1799W" "700x1200_T22_2288W")) ("1300" ( "700x1300_T21S_1949W" "700x1300_T22_2479W" "700x1300_T33_3503W")) ("1400" ( "700x1400_T21S_2099W" "700x1400_T22_2670W")) ("1600" ( "700x1600_T21S_2398W" "700x1600_T22_3051W")) ) ("900" ("400" ("900x400_T11_525W" "900x400_T21S_736W" "900x400_T22_930W")) ("500" ("900x500_T11_656W" "900x500_T21S_921W" "900x500_T22_1163W" "900x500_T33_1649W")) ("600" ("900x600_T11_787W" "900x600_T21S_1105W" "900x600_T22_1396W" "900x600_T33_1978W")) ("700" ("900x700_T11_918W" "900x700_T21S_1289W" "900x700_T22_1628W" "900x700_T33_2308W")) ("800" ("900x800_T11_1050W" "900x800_T21S_1473W" "900x800_T22_1861W" "900x800_T33_2638W")) ("900" ("900x900_T11_1181W" "900x900_T21S_1657W" "900x900_T22_2093W" "900x900_T33_2967W")) ("1000" ("900x1000_T11_1312W" "900x1000_T21S_1841W" "900x1000_T22_2326W" "900x1000_T33_3297W")) ("1100" ("900x1100_T11_1443W" "900x1100_T22_2559W" "900x1100_T33_3627W")) ("1200" ("900x1200_T11_1574W" "900x1200_T21S_2209W" "900x1200_T22_2791W" "900x1200_T33_3956W")) ("1300" ("900x1300_T11_1706W" "900x1300_T21S_2393W" "900x1300_T22_3024W" "900x1300_T33_4286W")) ("1400" ("900x1400_T11_1837W" "900x1400_T21S_2577W" "900x1400_T22_3256W" "900x1400_T33_4616W")) ("1600" ("900x1600_T11_2099W" "900x1600_T21S_2946W" "900x1600_T22_3722W" "900x1600_T33_5275W")) ("1800" ("900x1800_T11_2362W" "900x1800_T21S_3314W" "900x1800_T22_4187W" "900x1800_T33_5935W")) ("2000" ("900x2000_T11_2624W" "900x2000_T21S_3682W" "900x2000_T22_4652W" "900x2000_T33_6594W")) ) ) ) (setq dcl (vl-filename-mktemp "tmp.dcl")) (setq des (open dcl "w")) (foreach str '( "lbx : list_box" "{" " alignment = centered;" " fixed_width = true;" " fixed_height = true;" " width = 35;" " height = 15;" "}" "test : dialog" "{" " label = \"Brugman Compact 4 Bibliotheek\";" " spacer;" " : row" " {" " : lbx { key = \"lb0\"; label = \"Hoogte\"; }" " : lbx { key = \"lb1\"; label = \"Breedte\"; }" " : lbx { key = \"lb2\"; label = \"Type\"; }" " }" " spacer;" " ok_cancel;" "}" ) (write-line str des) ) (not (setq des (close des))) (< 0 (setq dch (load_dialog dcl))) (new_dialog "test" dch) (setq rtn '(0 0 0)) (LM:dcld:action '("lb0" "lb1" "lb2") 'lst 'rtn) (if (= 1 (start_dialog)) (progn (setq lb1list (LM:dcld:getitems rtn lst) newname (nth 2 lb1list) old-lay (getvar "clayer") LAY (if (not (tblsearch "layer" "WB5611----_RADIATOR")) (command "layer" "M" "WB5611----_RADIATOR" "C" "2" "" "L" "CONTINUOUS" "" "") ) ) (setq dist (getreal "\nEnter length ")) (setq pt (getpoint "\nPick point for new block ")) (command "layer" "s" "WB5611----_RADIATOR" "" ) (command "-bedit" "Radiator" "bsaveas" newname "No" "Bclose" "") (command "-insert" newname pt dist 100 0.0) (command "zoom" "E") ) ) (princ) ) (c:cbll)
    1 point
  6. As noted by rlx, this is unfortunately a bug in the ObjectDBX interface, and therefore not something which can be overcome using the LISP API - I note this as one of the known restrictions of the application. Hopefully a simple open/save/close script can rectify any inconvenience caused.
    1 point
  7. As you mentioned the issue is using OBDX to change objects, so you may have to run a script open the 400 one at a time and saveas. Then go to lunch. The other may be using Acoreconsole it may support the saveas command. Not tested, accoreconsole can run over an entire directory of dwg's. Like OBDX there is no opening of dwgs. Here is a couple of good sources of how to use Accoreconsole. https://through-the-interface.typepad.com/through_the_interface/2012/02/the-autocad-2013-core-console.html https://forums.autodesk.com/t5/forums/replypage/board-id/130/message-id/444989
    1 point
  8. I don't think it's Lee's bug but Autodesk... odbx can only save files in native AutoCad format so when you run it on 2013 , files are saved as 2013 even if you set an other version in the saveas command. So when you run code on 2018 or 2020 odbx saves it in this format. I also use a batch app that can use script / core & dbx but when I close a project I have a button called 'just save' and when I use this all files are saved in the version specified in my company's profile because it uses a plain and simple script.
    1 point
  9. Try this (defun lotsofholes ( / ) (setq pi45 (* pi 0.25)) (setvar 'textstyle "Standard") (setq oldsnap (getvar 'osmode)) (setvar 'osmode 512) (setq pt (getpoint "\nPick bottom left corner ")) (command "UCS" "OB" pt) (command "PLan" "") (command "zoom""C" (trans pt 0 1) 6.0) (prompt "select all circles use window enter to stop ") (while (setq ss (ssget '((0 . "Circle")))) (if (= ss nil)(progn (Alert "no circles found \nwill now exit ")(exit))) (setq cnum (vlax-ldata-get "Circles" "NUM")) (if (= cnum nil) (setq cnum 0)) (setq lst '()) (setq x -1) (repeat (sslength ss) (setq ent (entget (ssname ss (setq x (1+ x))))) (setq rad (cdr (assoc 40 ent))) (setq cen (cdr (assoc 10 ent))) (setq cenucs (trans (cdr (assoc 10 ent)) 0 1)) (setq cx (atof (rtos (car cenucs) 2 4) ) cy (atof (rtos (cadr cenucs) 2 4))) (setq lst (cons (list cx cy (car cen)(cadr cen) rad) lst)) ) (setq lst (vl-sort lst '(lambda (a b) (cond ((< (car a) (car b))) ((= (car a) (car b)) (< (cadr a) (cadr b))) ) ) ) ) (setvar 'osmode 0) (foreach val lst (setq cen (list (car val)(cadr val))) (setq rad (nth 4 val)) (command "text" (polar cen pi45 (+ rad (* rad 0.2))) rad 0.0 (rtos (setq cnum (1+ cnum)) 2 0)) ) (vlax-ldata-put "Circles" "NUM" cnum)) (setvar 'osmode 512) (command "ucs" "w") (command "plan" "") (princ) ) (lotsofholes) Pick lower left when asked. Used to get orientation, last number is saved in dwg. In the "LST" is the co-ordinates of the circles. A question the example dwg does not look like a real size was this done just for get code ? How is the co-ords relevant to what ? Does not look like 0,0 etc.
    1 point
  10. At the end of my code: Insert this line of code. This puts the object you first selected in the newly created layer. (princ "\nLayer created: ") (princ lName) ;; put the selected object in the newly created layer (vla-put-layer (vlax-ename->vla-object src) lName ) (princ) ) ... Or do you want to select a bunch of other objects to be put in that new layer? in that case, at the end of the code: (princ "\nLayer created: ") (princ lName) (princ "\nOptionally, select a bunch of objects to be put in the new layer: ") (setq i 0) (setq ss (ssget)) (if ss (repeat (sslength ss) (vla-put-layer (vlax-ename->vla-object (ssname ss i)) lName ) (setq i (+ i 1)) ) ) (princ) )
    1 point
×
×
  • Create New...