Author Topic: Dimstyle Lisp Help  (Read 13512 times)

0 Members and 1 Guest are viewing this topic.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Dimstyle Lisp Help
« on: February 18, 2004, 08:43:38 AM »
I have a question about the posted lisp. Why doesn't this work?

Code: [Select]


(defun c:insertdim ()          
        (command "._style" "ROMANS" "ROMANS.SHX" "0" "1" "" "" "" "")
        (setvar "lunits" 4)
        (setvar "DIMASSOC" 1)
        (setq ds
      (list
        (cons 0 "DIMSTYLE")
        (cons 100 "AcDbSymbolTableRecord")
        (cons 100 "AcDbDimStyleTableRecord")
        (cons 2 "STANDARD") ;Dim style name
        (cons 70 0) ;
        (cons 5 "ARCHTICK") ;DIMBLK-Name of block instead of default arrowhead
        (cons 170 0) ;DIMALT-turns off alternate units
        (cons 40 48) ;DIMSCALE-sets the overall scale factor applied to all dimensions
        (cons 41 0.125) ;DIMASZ-sets the size of the arrow/tick
        (cons 44 0.0625) ;DIMEXE-specifies how far to extend the extention line beyound the dim line
        (cons 46 0) ;DIMDLE-sets the distance the dimension line extends beyond the extension line
        (cons 73 0) ;DIMTIH-controls the position of dimension text inside extention lines
        (cons 74 0) ;DIMTOH-controls the position of dimension text outside extention lines
        (cons 77 1) ;DIMTAD-controls the vertical position of text in relation to the dim line
        (cons 78 3) ;DIMZIN-controls the suppression of zeros
        (cons 140 0.125) ;DIMTXT-specifies the height of the text in the dim
        (cons 143 25.4) ;DIMALTF-controls the scale factor for alt. units
        (cons 147 0.0625) ;DIMGAP-sets the distance from around the dim text
        (cons 171 2) ;DIMALTD-controls the decimal places for units
        (cons 172 0) ;DIMTOFL-forces a line inside extension lines
        (cons 270 4) ;DIMUNIT-sets the units format for all dims
        (cons 271 4) ;DIMDEC-sets the number of decimal places of primary units
        (cons 273 2) ;DIMALTU-sets the units for alt. units
        (cons 275 0) ;DIMAUNIT-sets the angular format for angular dims
        (cons 280 0) ;DIMJUST-controls the horizontal positioning of dim text
        (cons 286 0) ;DIMALTTZ-Toggles the suppression in tolerance values
      )
)
(entmake ds)
(dimsave)
(princ)
)

(defun dimsave ()
(command "DIMSTYLE" "R" "STANDARD")
(setvar "DIMTXSTY" "ROMANS")
(command "DIMSTYLE" "S" "STANDARD" "Y")
)
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

JohnK

  • Administrator
  • Seagull
  • Posts: 10634
Dimstyle Lisp Help
« Reply #1 on: February 18, 2004, 08:59:11 AM »
:lol: Im sorry but that post is almost like calling a mechanic and asking him why your car dosent work. ...?! Please be more specific.  what is it suposed to do? What acad version are you using? Stuff like that. I would love to help  you out, but i am gonna need some more details from ya.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Dimstyle Lisp Help
« Reply #2 on: February 18, 2004, 09:09:23 AM »
I am using Autocad 2002. This is supposed to create a dimstyle with the settings outlined in the lisp. When I run the lisp it runs and when I check to see if the setting are taking affect, they are not. For instance, I'm setting DIMBLK to ARCHTICK. After running the routine, it still says closed arrow type. This is what happens to all my settings that I'm trying to set. Is there a better way to set these values without using the "setvar" or "command" option?
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

SMadsen

  • Guest
Dimstyle Lisp Help
« Reply #3 on: February 18, 2004, 09:44:01 AM »
You can't ENTMAKE a style that is already present. "STANDARD" is probably already defined? A good thing would be to search for the dimension style before trying the create it.

Second, the tick block is called "_ArchTick". For a list of arrowhead names, look up DIMBLK in the system variables reference.

JohnK

  • Administrator
  • Seagull
  • Posts: 10634
Dimstyle Lisp Help
« Reply #4 on: February 18, 2004, 10:09:10 AM »
Here is a brief example on using an ActiveX method for creating a dimstyle. look it over.

Code: [Select]
;;; Does the dimstyle exist?
(defun DimStyle-p (x)
  (and (tblsearch "Dimstyle" x))
 )

;;; Dimstyle Create
(defun CreateDimstyle (Name)
  (setq x (vla-get-activedocument (vlax-get-acad-object)))
  (vl-catch-all-apply
    'vla-put-ActiveDimstyle
    (list
      (vla-put-ActiveDimstyle x (vla-add (vla-get-Dimstyles x) Name)))
    )
  (princ)
 )

(defun Main (name)
  (if (not (Dimstyle-p name))
    (CreateDimstyle name)))
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Anonymous

  • Guest
Dimstyle Lisp Help
« Reply #5 on: February 18, 2004, 11:38:45 AM »
Even if I change the name of the dimstyle to something else and it does not exist. The routine still does not work.

JohnK

  • Administrator
  • Seagull
  • Posts: 10634
Dimstyle Lisp Help
« Reply #6 on: February 18, 2004, 11:50:49 AM »
what do you mean it dosent work. (whats to/and not to work about it?) do you mean it dosent create a dimstyle? ...Is Autocad saying something like: "; error: no function definition: VLAX-GET-ACAD-OBJECT" or something.

I dont know how your using the code snipit. ...are you running it from the command line as is? Did you modify the code and run it? --i dont know what you mean when you say that you 'changed the name and it didnt work'.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

daron

  • Guest
Dimstyle Lisp Help
« Reply #7 on: February 18, 2004, 11:53:10 AM »
Did you type (vl-load-com) before running it?

SMadsen

  • Guest
Dimstyle Lisp Help
« Reply #8 on: February 18, 2004, 12:04:46 PM »
Dvarino, if you mean that the ENTMAKE thingy did not work by only changing the dimstyle name then see the comment about the DIMBLK "_ArchTick".

Anonymous

  • Guest
Dimstyle Lisp Help
« Reply #9 on: February 18, 2004, 12:19:02 PM »
Correct, I changed the dimstyle name in the Entmake function that I posted and it still does not work even if I change the ARCHTICK to _ARCHTICK. I even tries this.

Code: [Select]

(defun c:test ()
(command "._style" "ROMANS" "ROMANS.SHX" "0" "1" "" "" "" "")
(setvar "lunits" 4)
(setvar "DIMASSOC" 2)
(setvar "DIMBLK" "_ARCHTICK")
(setvar "DIMALT" 0)
(setvar "DIMSCALE" 48)
(setvar "DIMASZ" 0.125)
(setvar "DIMEXE" 0.0625)
(setvar "DIMDLE" 0)
(setvar "DIMTIH" 0)
(setvar "DIMTOH" 0)
(setvar "DIMTAD" 1)
(setvar "DIMZIN" 3)
(setvar "DIMTXT" 0.125)
(setvar "DIMALTF" 25.4)
(setvar "DIMGAP" 0.0625)
(setvar "DIMALTD" 2)
(setvar "DIMTOFL" 0)
(setvar "DIMUNIT" 4)
(setvar "DIMDEC" 4)
(setvar "DIMALTU" 2)
(setvar "DIMAUNIT" 0)
(setvar "DIMJUST" 0)
(setvar "DIMALTTZ" 0)
(command "DIMSTYLE" "R" "STANDARD")
(setvar "DIMTXSTY" "ROMANS")
(command "DIMSTYLE" "S" "STANDARD" "Y")
)


This does not work either.

SMadsen

  • Guest
Dimstyle Lisp Help
« Reply #10 on: February 18, 2004, 12:32:52 PM »
Hmmm, I have no problems creating a dimstyle with the changes below (only changed dimstyle name and DIMBLK name.

Code: [Select]
(defun c:insertdim ()
  (command "._style" "ROMANS" "ROMANS.SHX" "0" "1" "" "" "" "")
  (setvar "lunits" 4)
  (setvar "DIMASSOC" 1)
  (setq ds
         (list
           (cons 0 "DIMSTYLE")
           (cons 100 "AcDbSymbolTableRecord")
           (cons 100 "AcDbDimStyleTableRecord")
           (cons 2 "STANDARD_NEW")  ;Dim style name <-- changed this
           (cons 70 0)
           (cons 5 "_ARCHTICK") ;DIMBLK-Name of block instead of default arrowhead <-- and this
           (cons 170 0)         ;DIMALT-turns off alternate units
           (cons 40 48)         ;DIMSCALE-sets the overall scale factor applied to all dims
           (cons 41 0.125)      ;DIMASZ-sets the size of the arrow/tick
           (cons 44 0.0625)     ;DIMEXE-specifies how far to extend the ext line beyond the dim line
           (cons 46 0)          ;DIMDLE-sets the distance the dim line extends beyond the ext line
           (cons 73 0)          ;DIMTIH-controls the position of dim text inside extention lines
           (cons 74 0)          ;DIMTOH-controls the position of dim text outside extention lines
           (cons 77 1)          ;DIMTAD-controls the vert pos of text in relation to the dim line
           (cons 78 3)          ;DIMZIN-controls the suppression of zeros
           (cons 140 0.125)     ;DIMTXT-specifies the height of the text in the dim
           (cons 143 25.4)      ;DIMALTF-controls the scale factor for alt. units
           (cons 147 0.0625)    ;DIMGAP-sets the distance from around the dim text
           (cons 171 2)         ;DIMALTD-controls the decimal places for units
           (cons 172 0)         ;DIMTOFL-forces a line inside extension lines
           (cons 270 4)         ;DIMUNIT-sets the units format for all dims
           (cons 271 4)         ;DIMDEC-sets the number of decimal places of primary units
           (cons 273 2)         ;DIMALTU-sets the units for alt. units
           (cons 275 0)         ;DIMAUNIT-sets the angular format for angular dims
           (cons 280 0)         ;DIMJUST-controls the horizontal positioning of dim text
           (cons 286 0)         ;DIMALTTZ-Toggles the suppression in tolerance values
         )
  )
  (entmake ds)
  ;;(dimsave)
  (princ)
)

Anonymous

  • Guest
Dimstyle Lisp Help
« Reply #11 on: February 18, 2004, 12:43:55 PM »
I tried your posted routine and the dimsions that I made with the new style still has the closed filled (Arrow) instead of the _ARCHTICK that you have in the lisp.

Anonymous

  • Guest
Dimstyle Lisp Help
« Reply #12 on: February 18, 2004, 12:46:23 PM »
I typed at the command prompt DIMBLK and it returns

Command: dimblk

Enter new value for DIMBLK, or . for default <"">: *Cancel*

CADaver

  • Guest
Dimstyle Lisp Help
« Reply #13 on: February 18, 2004, 12:56:30 PM »
Quote from: Anonymous
Correct, I changed the dimstyle name in the Entmake function that I posted and it still does not work even if I change the ARCHTICK to _ARCHTICK. I even tries this.

Code: [Select]

(defun c:test ()
(command "._style" "ROMANS" "ROMANS.SHX" "0" "1" "" "" "" "")
(setvar "lunits" 4)
(setvar "DIMASSOC" 2)
(setvar "DIMBLK" "_ARCHTICK")
(setvar "DIMALT" 0)
(setvar "DIMSCALE" 48)
(setvar "DIMASZ" 0.125)
(setvar "DIMEXE" 0.0625)
(setvar "DIMDLE" 0)
(setvar "DIMTIH" 0)
(setvar "DIMTOH" 0)
(setvar "DIMTAD" 1)
(setvar "DIMZIN" 3)
(setvar "DIMTXT" 0.125)
(setvar "DIMALTF" 25.4)
(setvar "DIMGAP" 0.0625)
(setvar "DIMALTD" 2)
(setvar "DIMTOFL" 0)
(setvar "DIMUNIT" 4)
(setvar "DIMDEC" 4)
(setvar "DIMALTU" 2)
(setvar "DIMAUNIT" 0)
(setvar "DIMJUST" 0)
(setvar "DIMALTTZ" 0)


(command "DIMSTYLE" "R" "STANDARD")


(setvar "DIMTXSTY" "ROMANS")
(command "DIMSTYLE" "S" "STANDARD" "Y")
)


This does not work either.


Well could it be that you're restoring dimstyle STANDARD, which overwrites the previous settings?

SMadsen

  • Guest
Dimstyle Lisp Help
« Reply #14 on: February 18, 2004, 12:57:16 PM »
After running the above it has no problems with DIMBLK:

Command: dimblk
Enter new value for DIMBLK, or . for default <"ArchTick">: