Recent Posts

Pages: [1] 2 3 ... 10
1
CAD General / Re: What's the right commercial software to run as a SaaS platform?
« Last post by MickD on May 23, 2022, 10:52:49 PM »
We have been interacting with Autodesk's Design Automation API and Model Derivative API, but there are a lot of bells and whistles we don't need for our business requirements (we only require 3 pieces of information from 2D dwg and dxf files).

So we thought we'd just develop our own API that can process DWG and DXF files (hopefully more file types) and get the desired outputs we want using a script that can be triggered by the API.

As a web developer I don't know exactly how the workflow would look, but I know that we want to build something similar to Autodesk's API that can run custom scripts on an AutoCAD file.

The API would need to be able to handle 100 files a day being processed, and also needs to have a Node.js interface. We obviously need a commercial license for autoCAD software (I'm assuming AutoCAD is a term that refers to general processing of dwg-like files).

Question: What is the best commercial license where we can use it however much we want, and pay a fixed fee instead of monthly? Is there only repeat-charge licenses available?

The easiest way would be to write a C# plugin with the AutoCAD API to load, read to get data into a JSON format, save/close the drawing.
I'd embed a simple server into the plugin that takes CRUD requests to do this work. You can have say an Nginx main server running on port 80 (standard port) that routes requests to your node web app and also to your AutoCAD server via different ports depending on the routes. Apache can do this too but I find Nginx easier personally. the node and CAD servers can then talk to each other as well either directly by port number or via the main server (probably best).

Regardless of what CAD platform you use this would be the best setup pretty much, you 'could' just use the server embedded in the CAD app but for security and reliability I'd route it through Apache/Nginx.

hth

P.S.
You could write a plugin to distribute to the CAD users that supply the drawing that mines out the data then sends it to your web app for processing but then you have many app's to maintain and distribute rather than only one plugin for the server app.
2
I use sheet set manager with multiple drawings instead of one drawing with multiple layouts
3
AutoLISP (Vanilla / Visual) / Re: Shading?
« Last post by JohnSnow on May 23, 2022, 10:11:16 PM »
Thank you. I will have a look
4
AutoLISP (Vanilla / Visual) / Re: Set default page setup
« Last post by MrSmith on May 23, 2022, 07:42:46 PM »
That's the impression I'm getting from my searches.  I may have to go through the motion of plotting but not ACTUALLY plot using the page setup to set it as the default. Not exactly what I wanted to do.

Hi Matt! I am a few years late, but what Lee Mac suggested does work. You can copy the current layout object and paste it to other layouts without having to open the files. Unfortunately, AutoCAD has many DB Document bugs and one includes exporting named page setups by copying them. This does not cause problems when printing from the file directly; however, if you try to use an exported page setup via the Publish command, it will fail saying the pagesetup is not named.

Thankfully, Lee Mac has a solution to this problem in his Steal version 1.7 and greater, which basically modifies the dictionary by pulling the plot name from the entity. Unfortunately, this modification requires opening the drawing. I have written a method that will fix this problem via the AC Core Console which drastically speeds up the solution. Here is a very strip down example how I implemented it, devoid of most DLC and error checking, but should give you a good idea how it can work. (Note: Most of the support functions come from Lee Mac or was scraped from the interwebs).

To get the command to run, simply change "(setq files nil)" to the directory path containing the files you with to export the page setups to.
Example: (setq files "C:\\Users\\You\\Desktop\\Testland\\Page Setups")
Afterwards type "PageSetupBasicExport" in the drawing that has the named page setups you wish to export to the other drawings.


Code - Auto/Visual Lisp: [Select]
  1. (defun c:PageSetupBasicExport ( / files includeSubFolders SetDefaultSetup)
  2.         (setq files nil) ;Directory or list of files
  3.         (setq includeSubFolders nil) ;Change to 1 to include DWGs in subfolders
  4.         (setq SetDefaultSetup 1) ;Will set the drawings all to the same pagesetup layout
  5.         (pageSetupExport SetDefaultSetup files includeSubFolders)
  6.        
  7. )
  8.  
  9. (defun pageSetupExport (SetDefaultSetup files subfiles / vlaPageSetups notifyExit plotConfigNames directoryFiles DBXCopyPlotConfigs currentPageSetup fixPageSetupNames runActiveXFunctionOnDwgs pageSetups amt ct dwgName doc f pageSetups)
  10.         (defun notifyExit (msg) (alert msg) (princ (strcat "\n" msg)) (exit) ) ;Prints, alerts, and also exits the function
  11.         (defun plotConfigNames ( / out)
  12.                 (vlax-for x     (vla-get-plotconfigurations *acdoc*)
  13.                         (setq out (cons (strcase (vla-get-name x)) out))
  14.                 )
  15.                 (reverse out)
  16.         )
  17.         (defun directoryFiles ( path fileFolderNamePattern searchSubFolders / temp) ;Path is entire path where files/folders reside. FileFolderNamePattern is a wcmatchable string pattern for what to include. I.e. *.dwg for all dwg files.
  18.                 (setq path (vl-string-right-trim "\\" (vl-string-translate "/" "\\" path))) ;Nil on searchsubFolders to NOT search all folders.
  19.                 (if (> 259 (strlen (strcat fileFolderNamePattern path))) ;The fileFolderNamePattern search + length of filename/path can not be 259 or longer character length
  20.                         (progn
  21.                                 (append (mapcar '(lambda ( x ) (strcat path "\\" x)) (vl-directory-files path fileFolderNamePattern 1))
  22.                                         (if (and searchSubFolders (not (= 0 searchSubFolders)))
  23.                                                 (apply 'append
  24.                                                         (mapcar
  25.                                                            '(lambda ( x )
  26.                                                                         (if (not (or (= x ".") (= x "..")))
  27.                                                                                 (if (> 259 (strlen (strcat fileFolderNamePattern (setq temp (strcat path "\\" x)))))
  28.                                                                                         (directoryFiles temp fileFolderNamePattern 1)
  29.                                                                                         (list (debug "Too long: " (strlen (strcat fileFolderNamePattern temp))) (debug "Path: " temp) (debug "Pattern: " fileFolderNamePattern))
  30.                                                                                 )
  31.                                                                         )
  32.                                                                 )
  33.                                                                 (vl-directory-files path nil -1)
  34.                                                         )
  35.                                                 )
  36.                                         )
  37.                                 )
  38.                         )
  39.                         (debug "Path too long: " path)
  40.                 )
  41.         )
  42.         (defun DBXCopyPlotConfigs (plotConfigs setDefault / plt) ;DBX Function for copying plot configs to additional drawings
  43.                 (or
  44.                         vlaPageSetups
  45.                         (vlax-for x     (vla-get-plotconfigurations *acdoc*)
  46.                                 (if (member (strcase (vla-get-name x)) plotConfigs)
  47.                                         (setq vlaPageSetups (cons x vlaPageSetups))
  48.                                 )
  49.                         )
  50.                 )
  51.                
  52.                
  53.                 (setq plt (vla-get-plotconfigurations doc))
  54.                
  55.                 (vlax-map-collection plt 'vla-delete) ;Wipe all the current page setups incase of repeats
  56.                 (vlax-invoke *acdoc* 'copyobjects vlaPageSetups plt nil) ;Copy over the page setup from the source file
  57.  
  58.                 (if setDefault
  59.                         (vlax-for it (vla-get-layouts doc)
  60.                                 (if (not (= "Model" (vla-get-name it)))
  61.                                         (progn
  62.                                                 (vla-copyfrom it (vla-get-activelayout *acdoc*))
  63.                                                 ; (vlax-invoke it 'refreshplotdeviceinfo) ;I don't think this does anything....
  64.                                         )
  65.                                 )
  66.                         )
  67.                 )
  68.                 (princ)
  69.         )
  70.  
  71.         ;Returns the current layouts current pagesetup
  72.         (defun currentPageSetup ()
  73.                 (cdr (assoc 1 (entget
  74.                         (vlax-vla-object->ename (vla-item (vla-get-layouts *acdoc*) (getvar 'ctab)))
  75.                 )))
  76.         )
  77.  
  78.         (defun fixPageSetupNames (files / batFile scriptFile txt fl) ;AutoCAD has a bug when exporting pagesetups via ObjectDB where they are given an anoynomous name. This an be easily fixed Lee Mac's solution by pulling the entities page setup name and replace the anoynomous name with the real one
  79.                 (setq batFile (strcat (getvar "TEMPPREFIX") "ACADFixPageSetupNames.bat"))
  80.                 (setq scriptFile (strcat (getvar "TEMPPREFIX") "fixPageSetupNames.scr"))
  81.                 (setq txt "")
  82.                 (foreach it files (setq txt (strcat "\"" it "\"," txt)))
  83.                 (setq txt (vl-string-right-trim "," txt))
  84.                 (setq txt (strcat "FOR %%G IN (" txt ") DO \"" (findfile "accoreconsole.exe") "\" /i %%G /s \"" scriptFile "\""))
  85.                
  86.                 ;Write Bat File
  87.                 (if (setq fl (open batFile "w"))
  88.                         (progn
  89.                                 (write-line txt fl)
  90.                                 (close fl)
  91.                         )
  92.                 )
  93.                 ;Write Script File
  94.                 (if (setq fl (open scriptFile "w"))
  95.                         (progn
  96.                                 (write-line "((lambda (dic) (entmod (mapcar (function (lambda (a b) (if (and (= 003 (car a)) (= 350 (car b))) (cons 3 (cdr (assoc 1 (entget (cdr b))))) a))) dic (append (cdr dic) '( nil )))))(dictsearch (namedobjdict) \"ACAD_PLOTSETTINGS\")) qsave" fl)
  97.                                 (close fl)
  98.                         )
  99.                 )
  100.                 (startapp batFile)
  101.         )
  102.        
  103.         (defun runActiveXFunctionOnDwgs ( / vlaRelease checkAlreadyOpenedDWG massOpenFilesCheck setDBXObject dwl)
  104.                 (defun vlaRelease (obj) (if (= 'vla-object (type obj)) (not (vl-catch-all-error-p (vl-catch-all-apply 'vlax-release-object (list obj))))))
  105.                 (defun checkAlreadyOpenedDWG (filename / dwl f lst s)
  106.                         (if (and  ;See if a DWL exists and it can't be deleted
  107.                                         (setq dwl (findfile (strcat (vl-filename-directory filename) "\\" (vl-filename-base filename) ".DWL")))
  108.                                         (not (vl-file-delete dwl))
  109.                                 )
  110.                                 (if (setq f (open dwl "r")) ;Open it to get its info
  111.                                         (progn
  112.                                                 (while (setq s (read-line f)) (setq lst (cons s lst)))
  113.                                                 (close f)
  114.                                                 (strcat "Drawing [" fileName "] is currently opened by User: " (strcase (caddr lst)) " on computer " (strcase (cadr lst)))
  115.                                         )
  116.                                         nil ;Otherwise not open
  117.                                 )
  118.                         )
  119.                 )
  120.                 (defun massOpenFilesCheck (filesToCheck / openList) ;checks to see if any of the files are already opened
  121.                         (setq filesToCheck (mapcar 'strcase filesToCheck))
  122.                         (vlax-for doc (vla-get-documents *acad*) ;We can have files we have open in our autocad
  123.                                 (setq filesToCheck (vl-remove (strcase (vla-get-fullname doc)) filesToCheck)) ;Used to make sure we are not opening already open drawings
  124.                         )
  125.                         (setq openList (vl-remove nil (mapcar 'checkAlreadyOpenedDWG filesToCheck))) ;This list is not just the fileName, includes additional information i.e. who has it open
  126.                         (if openList ;If files are open, give the user the option to close out
  127.                                 (progn ;Print the results
  128.                                         (princ "\nThe following files are opened and need to be closed:")
  129.                                         (mapcar '(lambda(x) (princ (strcat "\n" x))) openList)
  130.                                         (princ "\n")
  131.                                         (exit)
  132.                                 )
  133.                         )
  134.                 )
  135.                 (defun setDBXObject ( dbx / vrs) ;Sets the DBX Object, from Lee
  136.                         (if (or (not (eval dbx)) (= 'vla-object (type (eval dbx))))
  137.                                 (set dbx (vl-catch-all-apply 'vla-getinterfaceobject
  138.                                         (list (setq *acad* (vlax-get-acad-object))
  139.                                                 (if (< (setq vrs (atoi (getvar 'acadver))) 16) "objectdbx.axdbdocument" (strcat "objectdbx.axdbdocument." (itoa vrs)))))
  140.                                 )
  141.                         )
  142.                         (if (or (null (eval dbx)) (vl-catch-all-error-p (eval dbx))) (notifyExit "\nUnable to interface with ObjectDBX."))
  143.                 )
  144.                 (setDBXObject '*dbx*)
  145.                 (massOpenFilesCheck files)
  146.                 (vlax-for doc (vla-get-documents *acad*)
  147.                         (setq dwl (cons (cons (strcase (vla-get-fullname doc)) doc) dwl)) ;Used to make sure we are not opening already open drawings
  148.                 )
  149.                 (setq amt (length files))
  150.                 (setq ct 1)
  151.                 (if ctrl (princ (strcat "\nBeginning to Process [" (itoa amt)"] Drawings.")))
  152.                 (foreach dwg files
  153.                         (if (not (setq dwgName (fnsplitl dwg)))
  154.                                 (princ (strcat "\nDrawing Name is unprocessable! See DWG: " dwg))
  155.                                 (progn
  156.                                         (setq dwgName (strcat (cadr dwgName) (caddr dwgName)))
  157.                                         (if
  158.                                                 (if (setq doc (cdr (assoc (strcase dwg) dwl))) ;Already Opened File, set doc to it
  159.                                                         (setq f 1) ;Set the doc is already open variable, we can use it to regen the viewport. Unopened documents will get generated when opened.
  160.                                                         (and
  161.                                                                 (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list *dbx* dwg)))) ;Else, open the drawing via *dbx*
  162.                                                                 (setq doc *dbx*)
  163.                                                         )
  164.                                                 )
  165.                                                 (progn
  166.                                                         (princ (strcat "\nCurrently in Drawing: [" (itoa ct) "] (" dwgName ") out of [" (itoa amt)"]"))
  167.                                                         (DBXCopyPlotConfigs pageSetups SetDefaultSetup) ;function uses the doc variable set above
  168.                                                         (vlax-invoke-method doc 'Saveas dwg)
  169.                                                         (if f (progn (vla-regen doc acActiveViewport) (setq f nil))) ;Drawing is already open, regen viewport just incase.
  170.                                                         (setq ct (+ ct 1))
  171.                                                 )
  172.                                                 (progn ;warn of failure
  173.                                                         (princ (strcat "\nUnable to interface with Drawing: [" (itoa ct) "] (" dwgName "). Drawing may be open!"))
  174.                                                         (setq ct (+ ct 1))
  175.                                                 )
  176.                                         )
  177.                                 )
  178.                         )
  179.                 )
  180.                 (vlaRelease *dbx*)
  181.         )
  182.         (setq pageSetups (plotConfigNames))
  183.         (cond
  184.                 ((or (not files) (= "" files)) ;No drawings selected
  185.                         (notifyExit "ERROR: No DWG(s) Selected to Export Page Setups Into!") ;No DWG(s) Set to export page setups into
  186.                 )
  187.                 ((and (= (type files) 'STR)(not (vl-file-directory-p (vl-string-translate "/" "\\" files))))
  188.                         (notifyExit "ERROR: DWGs Process Directory Does Not Exist!") ;Incorrect directory for processing DWGs
  189.                 )
  190.                 ((not pageSetups)
  191.                         (notifyExit "ERROR: No Page Setups Selected to Export!") ;No page setups selected
  192.                 )
  193.                 (T ;Everything good, Run the script
  194.                         (if (= 'STR (type files)) ;get the files if files is a directory
  195.                                 (setq files (directoryFiles files "*.dwg" subfiles))
  196.                                 (setq files files)
  197.                         )
  198.                         (setq files (vl-remove (vla-get-fullname *acdoc*) files)) ;Don't need to be deleting the current drawings stuff :'(
  199.                         (if SetDefaultSetup
  200.                                 (progn
  201.                                         (alert "SET CURRENT the Page Setup to apply as default for all drawings.")
  202.                                         (COMMAND "_.PAGESETUP")
  203.                                         (if (= "" (currentPageSetup))
  204.                                                 (notifyExit "ERROR: Current Page Setup set to None!")
  205.                                         )
  206.                                         (setq  
  207.                                                 Layts (vla-get-layouts *acdoc*)
  208.                                                 clyt  (vla-get-activelayout *acdoc*)
  209.                                         )
  210.                                         (foreach itm (vl-remove (vla-get-name clyt) (layoutlist))
  211.                                                 (vla-copyfrom (vla-item Layts itm) clyt)
  212.                                         )
  213.                                 )
  214.                         )
  215.                         (runActiveXFunctionOnDwgs)
  216.                         (fixPageSetupNames files)
  217.                         (print "Page Setups exported successfully!")
  218.                         (princ)
  219.                 )
  220.         )
  221. )

code=cadlisp-7  mod' kdub
5
AutoLISP (Vanilla / Visual) / Re: LISP to draw circle and make block
« Last post by like_citrus on May 23, 2022, 07:40:46 PM »
Yes, with appload.
6
AutoLISP (Vanilla / Visual) / Re: VLisp alternative to dos_clipboard
« Last post by rkmcswain on May 23, 2022, 01:02:27 PM »
Good topic all.

I know I did this years ago, now I need to go back and find that code and see how "I" did it.

lol.
7
Reason the other two work and that one doesn't is block names are case sensitive and it needs upper case C.



Code - Auto/Visual Lisp: [Select]
  1. (setq vis1 (ESTR_VALPARAM_DYNBLKDEF "Presa" "VIS.")) ;matches
  2. (setq vis2 (ESTR_VALPARAM_DYNBLKDEF "punto luce" "VIS.")) ;matches
  3. (setq vis3 (ESTR_VALPARAM_DYNBLKDEF "comando" "VIS.")) ;doesn't match
  4. (setq vis3 (ESTR_VALPARAM_DYNBLKDEF "Comando" "VIS.")) ;matches

8
AutoLISP (Vanilla / Visual) / Re: LISP to draw circle and make block
« Last post by mhupp on May 23, 2022, 08:43:20 AM »
How are you loading the lisp?

appload
9
Hi guys, happy to meet you.
I have a problem with a dynamic block definition for which I can't extract the list of its visibility values, for which I have often used the successfully attached Lisp file.
I am also attaching a drawing with 3 block definitions, all containing only the "Visibility" parameter.
With the block definitions "Presa" and "Puntoluce" the program works perfectly, while with the definition "Comando" it returns nil.
Can anyone help me understand the problem?
Thank you all
10
AutoLISP (Vanilla / Visual) / Pls Help - Quick Assign ObjectData to Point
« Last post by Namae Wa on May 23, 2022, 01:12:23 AM »
Hi everyone,
I'm trying to create a GIS shapefile (in AutoCAD Map3D/C3D) from a CAD drawing.
I want to make (or find) a lisp that does quick assign two TEXT Values (manhole elevation) to Object Data ( Data table created from ADEFDATA command)
Here is my idea workflow:
  1. Select two Texts (Ground level and Invert level)
  2. Select destination Point
  3. (automatic): Assign the Higher text value (Ground elevation) to Object Data1
                         Assign the Lower text value (Invert elevation) to Object Data2


Thanks in advance. :embarrassed2:
Pages: [1] 2 3 ... 10