Jump to content

Issues inserting block using a lisp routine - file location


Recommended Posts

Posted

I joined a company that had very little in the way of cad standards and lisp routines. I took their computers and pointed cad to a common folder location on our servers. When a drafter or engineer complains about a repetitive task, I create a lisp to reduce the work. This is works great.

 

I'm writing a lisp and I am hung up on one portion of the lisp. I created a wblock and saved the file to the server. I want to use the -insert command to insert the block (or whatever command I should be using). When I list the blocks through the insert command, my block is not shown. when I use the command -insert with FileLocation/FileName.dwg I can insert the block. When I write this into a lisp, the lisp is failing when I try using ( command "-insert" "FileLocation/FileName.dwg" ....). ... representing code I have written out but don't know off the top of my head. How do I get autocad on everyone's computer to pick up this block?

Posted

There may be a problem with spaces in the directory name I had a problem with this try // for a single slash in path, there may be Vla-insertblock which may read file path and name, correctly, I use a small VBA called from lisp to get around problem.

Posted

You should either add the said folder to Support File Search Path list in Options and input only the name of the block or use a double backslashes when store hard-coded the path in code:

(command "[color=red]_[/color]insert" "[color=red]C:\\MyBlocks\\[/color]FileName.dwg" ....)

Posted

This one might have been better posted in the LISP section, but nonetheless...

 

I do this a lot and have little troubles with it. If I understand your problem correctly the LISP program is not recognizing your path and filename. MSasu's recommendation is one way of doing it but there is, IMHO, a better way. I don't particularly like going around to everyone's computer and adding a new support path. And there comes a point when you can have too many support paths. I have blocks located in different folders on the servers based on which product line the user is generating a drawing for. And again, I don't see where your error is unless you have a typo or something in your code. Here is a typical insert command I use in it's complete form:

 

(command "_INSERT" "//a_very_long_novell_server_path/product/my_blk.dwg" "" "" "")

 

This works for me just fine whether I use mapped drive or UNC format for the path. I use UNC because the users have drives mapped differently. Again, standard would help but we have many higher projects and the users, as far as they are concerned are enforcing standards....their own.

Posted

Bill it would be interesting to see if the problem is a space in directory name, the first example uses maybe a variable as the path&filename where your method uses a more literal string "asdf"

 

something like
(setq fname "f://drive//my special 2012 projects//carblock")
(command "_insert" fname "" "" "")
may not work I will test further on the inserts that did not work here.

Posted

If you need to deal with many paths, then an effective approach will be to define a library of paths - keep this loaded as a global variable:

(setq *pathsBlocksLibrary* '(("EL" . "C:\\MyBlocks\\Electrical\\")
                            ("MC" . "C:\\MyBlocks\\Mechanical\\")
                            ("PB" . "C:\\MyBlocks\\Plumbing")))

(command "_.INSERT" (strcat (cdr (assoc "EL" *pathsBlocksLibrary*)) "Switch05") ...

Posted
Bill it would be interesting to see if the problem is a space in directory name,......

 

Mine often use spaces and I just double checked to make sure it works...and yes, as long as you get the path right, enclose it in quotes and use /, not \ or \\ and not \...it will work. And like MSasu suggests, I often place these long Novell server paths into small variable names like blkpath, or bklpath1. I also identify my blocks with variables because depending on the features selected by the user I will bring in a different block. I then (strcat blkpath blk1) to get the requested block into the drawing.

Posted

Just a bit of waffle Autocad on pc = / on unix =\ which is of course is backwards to the actual operating system gets very confusing some times. Yeah I am old enough Autocad on Sun workstations and I think reversed lisp for the 1st original mac version.

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