svorgodne Posted January 7, 2011 Share Posted January 7, 2011 I need other users to update a block from a website where I am making changes to originals. If the block is inside the local network I can use a normal path like: p:/... with a lisp routine like: "INSERT" "block=P:/.../block.dwg" but I cannot update a block with this system when the block is on a website. Any suggestion? Have a nice 2011 beginning Sergio Quote Link to comment Share on other sites More sharing options...
BlackBox Posted January 7, 2011 Share Posted January 7, 2011 Forgive my asking... but as it would only need to be done once, could you not download the block (from the website to your local network), then run your LISP? Quote Link to comment Share on other sites More sharing options...
svorgodne Posted January 7, 2011 Author Share Posted January 7, 2011 the problem is that I constantly have to change this information due to consultants specifications so I have the specific need to update several times several blocks in many drawings, that's the reason I need an "update block" command that can do that within the AutoCAD editor. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted January 7, 2011 Share Posted January 7, 2011 Like I said.... So DOWNLOAD the file from the website to your network first. :wink: (defun download (url path / utilObj tempPath newPath) ;; © RenderMan 2011, CADTutor.net ;; Example: (download "[url]http://www.indiesmiles.com/wp-content/uploads/2010/12/2010/12/SMILE.jpg[/url]" (getvar 'dwgprefix)) (vl-load-com) (setq utilObj (vla-get-utility (vla-get-activedocument (vlax-get-acad-object)))) (if (= :vlax-true (vla-isurl utilObj url)) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-GetRemoteFile (list utilObj url 'tempPath :vlax-true))) (prompt "\n <!> Error Downloading File From URL <!> ") (progn (if (findfile (setq newPath (strcat path (vl-filename-base url) (vl-filename-extension url)))) (vl-file-rename newPath (setq voidPath (strcat (vl-filename-directory newPath) "[url="file://\\void"]\\void[/url]_" (vl-filename-base newPath) "_" (menucmd "M=$(edtime,$(getvar,date),YYYY-MO-DD-HH-MM-SS)") (vl-filename-extension newPath))))) (vl-file-copy tempPath newPath) (vl-file-delete tempPath))) (prompt "\n <!> Invalid URL <!> ")) (vl-catch-all-apply 'vlax-release-object (list utilObj)) (princ)) ... Then run your LISP. This routine is a first draft, and has room for improvement. However, for now, this routine will download a file from a valid URL, and automatically 'void' out your current file saved on the network, and then copy the new file to the same location. Let me know if you have any trouble implementing this routine within your own program. Hope this helps! Quote Link to comment Share on other sites More sharing options...
svorgodne Posted January 10, 2011 Author Share Posted January 10, 2011 Thanks again Render, the project we have is so big and we have to open so many drawings containing different layouts. Therefore I think it is more useful to type only one command which updates from a website instead of making two steps, your routine is working smooth fine Quote Link to comment Share on other sites More sharing options...
BlackBox Posted January 10, 2011 Share Posted January 10, 2011 (edited) Thanks again Render, the project we have is so big and we have to open so many drawings containing different layouts. Therefore I think it is more useful to type only one command which updates from a website instead of making two steps, your routine is working smooth fine That is why I provided you a sub-function which can be called prior to running your own functions. Within YOUR function, prior to the line of code which replaces the existing block with the new, add this line: (download "url" "filepath") Then you have one, single command to run which does the whole process. Example: (defun c:MyFunction (/ blockName newPath ) (vl-load-com) (if (tblsearch "block" (setq blockName "[color=red]blockname[/color]")) (progn [b][color=blue]([/color][/b]download "[color=red]url[/color]" "[color=red]filepath[/color]"[color=blue][b])[/b][/color] (if (findfile (setq newPath (strcat "[color=red]filepath[/color]" blockName ".dwg"))) (command "._-insert" (strcat blockName "=" newPath))))) (princ)) Edit: This can also be utilized in a foreach statement to handle multiple URL's, and blocks. Edited January 10, 2011 by BlackBox Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.