+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Forum Newbie
    Using
    Civil 3D 2012
    Join Date
    Sep 2012
    Posts
    8

    Default Issues inserting block using a lisp routine - file location

    Registered forum members do not see this ad.

    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?

  2. #2
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,798

    Default

    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.
    A man who never made mistakes never made anything

  3. #3
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,041

    Default

    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:
    Code:
    (command "_insert" "C:\\MyBlocks\\FileName.dwg" ....)
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  4. #4
    Forum Newbie
    Using
    Civil 3D 2012
    Join Date
    Sep 2012
    Posts
    8

    Default

    Thanks BIGal and Msasu, the \\ worked.

  5. #5
    Super Member Bill Tillman's Avatar
    Using
    AutoCAD 2013
    Join Date
    Oct 2008
    Location
    Miami, FL
    Posts
    891

    Default

    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:

    Code:
    (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.
    It's deja vu, all over again.

  6. #6
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,798

    Default

    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"

    Code:
    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.
    A man who never made mistakes never made anything

  7. #7
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,041

    Default

    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:
    Code:
    (setq *pathsBlocksLibrary* '(("EL" . "C:\\MyBlocks\\Electrical\\")
                                 ("MC" . "C:\\MyBlocks\\Mechanical\\")
                                 ("PB" . "C:\\MyBlocks\\Plumbing")))
     
    (command "_.INSERT" (strcat (cdr (assoc "EL" *pathsBlocksLibrary*)) "Switch05") ...
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  8. #8
    Super Member Bill Tillman's Avatar
    Using
    AutoCAD 2013
    Join Date
    Oct 2008
    Location
    Miami, FL
    Posts
    891

    Default

    Quote Originally Posted by BIGAL View Post
    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.
    It's deja vu, all over again.

  9. #9
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,798

    Default

    Registered forum members do not see this ad.

    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.
    A man who never made mistakes never made anything

Similar Threads

  1. Part file location in title block?
    By andrewmmccallum in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 15th Aug 2012, 01:53 pm
  2. Inserting Blocks using Copy / Paste; Issues with Block Units
    By bilodeaucarl in forum AutoCAD Bugs, Error Messages & Quirks
    Replies: 3
    Last Post: 6th Apr 2011, 09:29 pm
  3. Lisp Command For Setting The Auto File Save Location
    By ReinierMeyer in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 10th Nov 2009, 04:15 am
  4. Inserting Block from a network location...
    By bigr1822 in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 24th Jun 2008, 08:06 am
  5. Looking for a LISP routine (Inserting Text)....
    By StykFacE in forum AutoLISP, Visual LISP & DCL
    Replies: 9
    Last Post: 7th May 2008, 07:42 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts