Results 1 to 5 of 5

Thread: Problem with Dimstyle Import

  1. #1
    AUGI Addict
    Join Date
    2006-04
    Location
    (getpoint "Anywhere on the Enter Key =>")
    Posts
    1,160
    Login to Give a bone
    0

    Default Problem with Dimstyle Import

    Long time ago I got help here for importing dimstyle.
    I now find AutoCAD will be crashed when I apply the imported dimstyle to a new dimension.
    Here is a simplified version.
    Your helps is much appreciated.

    Code:
    (defun c:DimStyleImport (/ currentDimStyle DimStyle_ID DimStyleList
             DimStyle_Name fqnName fqnTemp myAcad dbxName myDb
             sourceDimStyle targetDimStyle)
    (setvar "cmdecho" 0)
    (setq currentDimStyle (getvar "dimstyle"))
    (setq DimStyle_ID (getstring "\nEnter a DimStyle ID: "))
    (setq DimStyleList
          (list (cons "1-1" "STD 1-1"); this is the dimstyle to be imported.
             (cons "1-2" "STD 1-2"); this is the dimstyle to be imported.
       (cons "1-5" "STD 1-5"); this is the dimstyle to be imported.
       (cons "1-10" "STD 1-10"); this is the dimstyle to be imported.
       (cons "1-20" "STD 1-20"); this is the dimstyle to be imported.
       (cons "1-50" "STD 1-50"); this is the dimstyle to be imported.
       (cons "1-100" "STD 1-100"); this is the dimstyle to be imported.
       (cons "1-200" "STD 1-200"); this is the dimstyle to be imported.
       (cons "1-500" "STD 1-500"); this is the dimstyle to be imported.
       (cons "1-1000" "STD 1-1000"); this is the dimstyle to be imported.
       ); end of list
    ); end of setq
      
    (setq DimStyle_Name
       (cdr (assoc DimStyle_ID DimStyleList))
    ); end of setq 
    (if (tblsearch "dimstyle" DimStyle_Name)
        (progn (prompt (strcat "\nDimStyle " DimStyle_Name " has already existed."))
            (command "._-dimstyle" "restore" DimStyle_Name)
         (exit)
     ); end of progn
    ); end of if
    (setq fqnName "C:\\Standard.dwt"); your standard drawing template
    (findfile fqnName)
    (setq fqnTemp
       (vl-filename-mktemp "Dims" (getenv "Temp") ".dwt")
    ); end of setq
    (vl-file-copy fqnName fqnTemp)
    (setq myAcad
       (vlax-Get-Acad-Object)
    ); end of setq
    (setq dbxName
       (strcat "ObjectDBX.AxDbDocument." (itoa (atoi (getvar 'AcadVer))))
    ); end of setq
    (setq myDb
       (vla-GetInterfaceObject myAcad dbxName)
    ); end of setq
    (progn (vla-Open myDb fqnTemp) 'T)
    (not (vl-catch-all-error-p
      (vl-catch-all-apply
       (function (lambda ()
           (setq sourceDimStyle
              (vla-Item (vla-Get-DimStyles myDb) DimStyle_Name))
           ); end of lambda
       ); end of function
      ); end of vl
      ); end of vl
    ); end of not
    (setq targetDimStyle
       (vla-Add (vla-Get-DimStyles (vla-Get-ActiveDocument myAcad))
          DimStyle_Name)
    ); end of setq
    (progn (vla-CopyFrom targetDimStyle sourceDimStyle) T)
    (vlax-Release-Object myDb)
    (vl-file-delete fqnTemp)
    (command "._-dimstyle" "restore" currentDimStyle)
    (setvar "cmdecho" 1)
    (princ)
    ); end of Routine

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Problem with Dimstyle Import

    ... If you're having trouble importing the desired style, simply STEAL it instead.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    AUGI Addict
    Join Date
    2006-04
    Location
    (getpoint "Anywhere on the Enter Key =>")
    Posts
    1,160
    Login to Give a bone
    0

    Default Re: Problem with Dimstyle Import

    Thanks for the link.
    At this time, I don't want to "steal" but want to figure it out what was wrong in the code.
    Could anyone give me help? Thanks again.

  4. #4
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Problem with Dimstyle Import

    Quote Originally Posted by RenderMan View Post
    ... If you're having trouble importing the desired style, simply STEAL it instead.
    One of my favorite routines, makes Design Center jealous.
    Thanks again Lee,

  5. #5
    AUGI Addict
    Join Date
    2006-04
    Location
    (getpoint "Anywhere on the Enter Key =>")
    Posts
    1,160
    Login to Give a bone
    0

    Default Re: Problem with Dimstyle Import

    Can anyone give a help, please?

Similar Threads

  1. 2012: Can't import Dimstyle through Design Center
    By tplancon in forum AutoCAD General
    Replies: 2
    Last Post: 2012-04-24, 03:53 PM
  2. Import An Existing Dimstyle
    By BeKirra in forum AutoLISP
    Replies: 20
    Last Post: 2010-03-10, 12:55 AM
  3. dwf import problem
    By bartonions in forum Software
    Replies: 2
    Last Post: 2009-01-12, 03:19 AM

Posting Permissions

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