+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
  1. #1
    Junior Member
    Discipline
    Mechanical
    Using
    AutoCAD 2016
    Join Date
    Jun 2018
    Location
    USA, Louisiana
    Posts
    24

    Default A little help needed.......

    Registered forum members do not see this ad.

    I have a code that I need a little help with. First things first, I am creating this to try to eliminate the use of incorrect title blocks as well as standard blocks on a project. This will be adapted to all projects so that there is more consistency throughout.


    The problem that I have run into is that I have to hit "enter" between the insertion of both blocks. And after the second block is inserted I get an unknown command error, but everything works.


    Not understanding what I have done wrong. Please see the code below and help shed some light on this for me please.


    Code:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;
    ;;Created by Karl E Sharp 7/3/2018
    ;;
    ;;Designed to create a default project specific DWG Template with all
    ;;   project variables set. (i.e. linewght, linetypes, dimstyle, textstyle, texthieght, etc.)
    ;;
    ;;Inserts project title block and all annotation blocks to be used
    ;;
    ;;Sets SDI mode to 0
    ;;
    ;;Turns off attribute Dialog on insertion of block
    ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;
    (defun c:NDS (/ d-path)
      (setvar "dimadec" 0)                 ; Angular decimal places
      (setvar "dimalt" 0)                  ; Alternate units selected
      (setvar "dimaltd" 0)                 ; Alternate unit decimal places
      (setvar "dimaltrnd" 0.0000)          ; Alternate units rounding value
      (setvar "dimalttd" 2)                ; Alternate tolerance decimal places
      (setvar "dimalttz" 0)                ; Alternate tolerance zero suppression
      (setvar "dimaltu" 2)                 ; Alternate units
      (setvar "dimaltz" 0)                 ; Alternate unit zero suppression
      (setvar "dimapost" "")               ; Prefix and suffix for alternate text
      (setvar "dimarcsym" 0)               ; Arc length symbol
      (setvar "dimasz" 0.1875)             ; Arrow size
      (setvar "dimatfit" 3)                ; Arrow and text fit
      (setvar "dimaunit" 0)                ; Angular unit format
      (setvar "dimazin" 0)                 ; Angular zero supression
      (setvar "dimblk" "")                 ; Arrow block name
      (setvar "dimblk1" "")                ; First arrow block name
      (setvar "dimblk2" "")                ; Second arrow block name
      (setvar "dimcen" 0.25)               ; Center mark size
      (setvar "dimclrd" 256)               ; Dimension line and leader color
      (setvar "dimclre" 256)               ; Extension line color
      (setvar "dimclrt" 2)                 ; Dimension text color
      (setvar "dimdec" 4)                  ; Decimal places
      (setvar "dimdle" 0)                  ; Dimension line extension
      (setvar "dimdli" 0.0625)             ; Dimension line spacing
      (setvar "dimdsep" ".")               ; Decimal separator
      (setvar "dimexe" 0.0625)             ; Extension above dimension line
      (setvar "dimexo" 0.0625)             ; Extension line origin offset
      (setvar "dimfrac" 2)                 ; Fraction format
      (setvar "dimfxl" 1)                  ; Fixed Extension Line
      (setvar "dimfxlon" 0)                ; Enable Fixed Extension Line
      (setvar "dimgap" 0.0625)             ; Gap from dimension line to text
      (setvar "dimjust" 0)                 ; Justification of text on dimension line
      (setvar "dimldrblk" "")              ; Leader block name
      (setvar "dimlfac" 1)                 ; Linear unit scale factor
      (setvar "dimlim" 0)                  ; Generate dimension limits
      (setvar "dimltex1" "bylayer")        ; Linetype extension line 1
      (setvar "dimltex2" "bylayer")        ; Linetype extension line 2
      (setvar "dimltype" "bylayer")        ; Dimension linetype
      (setvar "dimlunit" 4)                ; Linear unit format
      (setvar "dimlwd" -1)                 ; Dimension line and leader lineweight
      (setvar "dimlwe" -1)                 ; Extension line lineweight
      (setvar "dimrnd" 0)                  ; Rounding value
      (setvar "dimsah" 0)                  ; Separate arrow blocks
      (setvar "dimscale" 1)                ; Overall scale factor
      (setvar "ltscale" 0.5)               ; Linetype scale factor
      (setvar "dimsd1" 0)                  ; Suppress the first dimension line
      (setvar "dimsd2" 0)                  ; Suppress the second dimension line
      (setvar "dimse1" 0)                  ; Suppress the first extension line
      (setvar "dimse2" 0)                  ; Suppress the second extension line
      (setvar "dimsoxd" 0)                 ; Suppress outside dimension lines
      (setvar "dimtad" 1)                  ; Place text above the dimension line
      (setvar "dimtdec" 4)                 ; Tolerance decimal places
      (setvar "dimtfac" 1)                 ; Tolerance text height scaling factor
      (setvar "dimtfill" 1)                ; Text background enabled
      (setvar "dimtad" 1)                  ; Place text above the dimension line
      (setvar "dimtfillclr" 0)             ; Text background color
      (setvar "dimtih" 0)                  ; Text inside extensions is horizontal
      (setvar "dimtix" 0)                  ; Place text inside extensions
      (setvar "dimtm" 0)                   ; Minus tolerance
      (setvar "dimtmove" 0)                ; Text movement
      (setvar "dimtofl" 0)                 ; Force line inside extension lines
      (setvar "dimtoh" 0)                  ; Text outside horizontal
      (setvar "dimtol" 0)                  ; Tolerance dimensioning
      (setvar "dimtolj" 0)                 ; Tolerance vertical justification
      (setvar "dimtp" 0)                   ; Plus tolerance
      (setvar "dimtsz" 0)                  ; Tick size
      (setvar "dimtvp" 0)                  ; Text vertical position
      (setvar "dimtxsty" "standard")       ; Text style
      (setvar "dimtxt" 0.09375)            ; Text height
      (setvar "dimtzin" 0)                 ; Tolerance zero suppression
      (setvar "dimupt" 0)                  ; User positioned text
      (setvar "dimzin" 3)                  ; Zero suppression
      (command "dimstyle" "save" "standard" "y")
      (command "style" "standard" "romans" 0.09375 1 0 "no" "no" "no")
      (command "linetype" "load" "center2" "" "")
      (command "linetype" "load" "hidden2" "" "")
      (command "linetype" "load" "phantom2" "" "")
      (command "layer" "m" "DIM" "c" "1" "DIM" "")
      (command "layer" "m" "TEXT" "c" "2" "TEXT" "lt" "continuous" "TEXT" "")
      (command "layer" "m" "CENTER" "c" "1" "CENTER" "lt" "center2" "CENTER" "")
      (command "layer" "m" "HIDDEN" "c" "2" "HIDDEN" "lt" "hidden2" "HIDDEN" "")
      (command "layer" "m" "MATCHLINE" "c" "3" "MATCHLINE" "lt" "phantom2" "MATCHLINE" "")
      (command "layer" "m" "EQUIP" "c" "3" "EQUIP" "lt" "continuous" "EQUIP" "")
      (command "layer" "m" "LABEL_PLATE" "c" "3" "LABEL_PLATE" "lt" "continuous" "LABEL_PLATE" "")
      (command "layer" "m" "BACKGROUND" "c" "9" "BACKGROUND" "lt" "continuous" "BACKGROUND" "")
      (command "layer" "m" "SYMBOLS" "c" "3" "SYMBOLS" "lt" "continuous" "SYMBOLS" "")
      (command "layer" "m" "VIEWPORT" "c" "7" "VIEWPORT" "plot" "n" "VIEWPORT" "")
      (command "layer" "s" "0" "")
      (command "LUNITS" "4")
      (command "LUPREC" "5")
      (setvar "SDI" 0)                     ; Turns SDI mode off
      (setvar "attdia" 0)                  ; Turns the attribute edit dialog box off for block insertion
      (setvar "attreq" 1)
      (initdia 0)
      (setq filename "S:\\folder-1\\subfolder-1\\filename")
      (if
        (= 0 (getvar "SDI"))
          (command "-insert" "S:\\folder-1\\subfolder-1\\filename" '(0. 0. 0.) "" "" ""))   ; Inserts Client Border
      (while (= (logand (getvar "cmdactive")1)1)
        (command ""))
        (initdia)
      (princ)
       (setq filename "S:\\folder-2\\subfolder-2\\filename")
      (if
        (= 0 (getvar "SDI"))
          (command "-insert" "*S:\\folder-2\\subfolder-2\\filename" '(36. 0. 0.) "" "" )) ; Inserts Company Border with standard annotation blocks
      (while (= (logand (getvar "cmdactive")1)1)
        (command ""))
        (initdia)
      (princ)
    )
    Last edited by KESHAR; 5th Jul 2018 at 11:36 pm.

  2. #2
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    1,068

    Default

    just @ first glance, haven't tested your code, but you use while cmdactive command pause...

  3. #3
    Junior Member
    Discipline
    Mechanical
    Using
    AutoCAD 2016
    Join Date
    Jun 2018
    Location
    USA, Louisiana
    Posts
    24

    Default

    Completely new to this. What should I do instead? I tried removing the command pause and it freezes...... Oh this is making my brain pan hurt :/

  4. #4
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    1,068

    Default

    Quote Originally Posted by KESHAR View Post
    Completely new to this. What should I do instead? I tried removing the command pause and it freezes...... Oh this is making my brain pan hurt :/

    Well I'm actually feeding my brain with a little anti-freeze , hik ;-)


    but maybe (command "") in stead of (command pause)?


    Also (again without testing) , just from memory (which is slowly getting foggy) , when you insert a block with prefix * , do you still have the same number of prompts? I'm not entirely sure without trying , but I vaguely remember the standard prompts will ask for separate scale for x and y and the other just one scale factor for both.

  5. #5
    Junior Member
    Discipline
    Mechanical
    Using
    AutoCAD 2016
    Join Date
    Jun 2018
    Location
    USA, Louisiana
    Posts
    24

    Default

    Thanks.... that worked for the issue between the insertions..... not sure about the number of prompts for "*" on insertion......gonna check something.....

  6. #6
    Junior Member
    Discipline
    Mechanical
    Using
    AutoCAD 2016
    Join Date
    Jun 2018
    Location
    USA, Louisiana
    Posts
    24

    Default

    vundaba!!!! Thanks for the assistance RLX...... I had one to many quotes on the second insertion....I have edited the above code with the corrections. Trying to get a better handle on all of this so I can truly say that I have learned something new and in the process help out somewhere along the way, and hopefully make my life easier.

  7. #7
    Junior Member
    Discipline
    Mechanical
    Using
    AutoCAD 2016
    Join Date
    Jun 2018
    Location
    USA, Louisiana
    Posts
    24

    Default

    Just out of curiosity, is there a way to condense this down to less coding?

  8. #8
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    1,068

    Default

    Quote Originally Posted by KESHAR View Post
    Just out of curiosity, is there a way to condense this down to less coding?

    I'm sure you can compress the code a lot with using mapcar etc and most if not all command functions can be replaced with vla functions. But this would save you a few micro seconds , hell maybe a whole second... big deal. if it works it works. It's 1 in the morning for me so I wont be doing any coding no more for a wile

  9. #9
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,715

    Default

    About the only saving is in your make layers can be done as say read file but you have so few is it worth it. There are other ways also make a list of ((layname1 col LT)(layname2 col lt)) and so on reading the list and making, 3rd use a make layer defun (laych "Background" 9 "Continuous), in my case this is a library function that checks if layer exists ignore else make it.
    A man who never made mistakes never made anything

  10. #10
    Senior Member
    Discipline
    Surveying
    dlanorh's Discipline Details
    Occupation
    Geospatial Engineer
    Discipline
    Surveying
    Using
    AutoCAD 2012
    Join Date
    Aug 2017
    Location
    UK/Bundesrepublik Deutschland
    Posts
    130

    Default

    Registered forum members do not see this ad.

    Code:
      (initdia 0)
      (setq filename "S:\\folder-1\\subfolder-1\\filename")
      (if (= 0 (getvar "SDI"))
        (command "-insert" filename '(0. 0. 0.) "" "" ""))   ; Inserts Client Border   
      (while (= (logand (getvar "cmdactive")1)1) 
        (command ""))   
      (initdia) 
      (princ)  
      (setq filename (strcat"*" "S:\\folder-2\\subfolder-2\\filename")) 
      (if  (= 0 (getvar "SDI"))     
        (command "-insert" filename '(36. 0. 0.) "" "" )) ; Inserts Company Border with standard annotation blocks 
      (while (= (logand (getvar "cmdactive")1)1)   
        (command ""))     
      (initdia) 
       (princ) )
    The red items in your code are never used. I have subsituted the variable "filename" in the command insert calls. If you want to go with the hard coded file name string in the command insert calls, then the two red lines of code can be removed. If not then you can put it in a while loop
    Code:
      (initdia 0)
      (setq filenames (list (cons "S:\\folder-1\\subfolder-1\\filename" '(0. 0. 0.)) 
                            (cons "*S:\\folder-2\\subfolder-2\\filename" '(36. 0. 0.))
                      ))
      (foreach f_name filenames
        (if (= 0 (getvar "SDI"))
          (command "-insert" (car f_name) (cadr f_name) "" "" "")
        )
        (while (= (logand (getvar "cmdactive")1)1) 
          (command "")
        )   
        (initdia) 
        (princ)
     )

Similar Threads

  1. Help needed!
    By bavdeyka in forum Autodesk Inventor
    Replies: 4
    Last Post: 5th Feb 2017, 09:56 pm
  2. Help needed
    By the condition in forum SolidWorks
    Replies: 10
    Last Post: 15th Aug 2012, 04:13 pm
  3. 3D help needed
    By TheNewGuy in forum AutoCAD 3D Modelling & Rendering
    Replies: 2
    Last Post: 24th Mar 2009, 08:01 pm
  4. Help needed
    By ChrisN in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 20th Feb 2007, 05:35 pm
  5. Help Needed
    By Rebbeca in forum AutoCAD General
    Replies: 2
    Last Post: 30th Oct 2006, 02:31 pm

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