Jump to content

update block from a website (Autocad 2006)


svorgodne

Recommended Posts

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

Link to comment
Share on other sites

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? :unsure:

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. :geek:

 

Hope this helps!

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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 by BlackBox
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...