Author Topic: Dimstyle Lisp Help  (Read 13475 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: 10623
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: 10623
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: 10623
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">:

Anonymous

  • Guest
Dimstyle Lisp Help
« Reply #15 on: February 18, 2004, 01:18:43 PM »
This one works fine. When I initiate the command to run this code the textscreen pops up. How can I avoid this?

Code: [Select]

(defun c:insertdim ()
(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)
(setvar "DIMTXSTY" "ROMANS")
(command "DIMSTYLE" "S" "STANDARD" "Y")
(princ)
)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Dimstyle Lisp Help
« Reply #16 on: February 18, 2004, 02:40:47 PM »
The only thing that got my attention is DIMASSOC.
I'm using acad2k and it is 1 or 0.
What does 2 stand for?

CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

SMadsen

  • Guest
Dimstyle Lisp Help
« Reply #17 on: February 18, 2004, 02:49:25 PM »
DIMASSOC doesn't affect dimstyles, does it? .. but you might just have a point there?

Anonymous

  • Guest
Dimstyle Lisp Help
« Reply #18 on: February 18, 2004, 03:19:31 PM »
This is from the HELP!!!

Associative dimensions. Automatically adjust their locations, orientations, and measurement values when the geometric objects associated with them are modified. TheDIMASSOC system variable is set to 2.
Nonassociative dimensions. Selected and modified with the geometry they measure. Nonassociative dimensions do not change when the geometric objects they measure are modified. The dimension variable DIMASSOC is set to 1.
Exploded dimensions. Contain a collection of separate objects rather than a single dimension object. The DIMASSOC system variable is set to 0.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Dimstyle Lisp Help
« Reply #19 on: February 18, 2004, 03:38:15 PM »
You see I am using an older version of ACAD than you.
Even the var name has changed.

Quote
Type: Switch
Saved in: Drawing
Initial value: On
Controls the associativity of dimension objects.

Off   Creates no association between the various elements of the dimension. The lines, arcs, arrowheads, and text of a dimension are drawn as separate objects.
On   Creates an association between the elements of the dimension. The elements are formed into a single object. If the definition point on the object moves, the dimension value is updated.

DIMASO is not stored in a dimension style.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CADaver

  • Guest
Dimstyle Lisp Help
« Reply #20 on: February 18, 2004, 05:04:52 PM »
Quote from: CAB
You see I am using an older version of ACAD than you.
Even the var name has changed.


That happened somewhere between R14 and 2k2

DIMASO became obsolete
DIMASSOC=0  -  Dumb entity dims, text, lines, solids
DIMASSOC=1  -  Associative Dims like we're used to
DIMASSOC=2  -  TRANS-SPATIAL Dims; dims in PS read the actual MS length (not real stable in R2K2, sometimes a 12'-0" model dim shows up as 3")

daron

  • Guest
Dimstyle Lisp Help
« Reply #21 on: February 18, 2004, 06:12:36 PM »
>When I initiate the command to run this code the textscreen pops up. How can I avoid this?

At the end of your code type (graphscr)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Dimstyle Lisp Help
« Reply #22 on: February 18, 2004, 10:28:11 PM »
Quote from: Anonymous
This one works fine. When I initiate the command to run this code the textscreen pops up. How can I avoid this?

Code: [Select]

(setvar "cmdecho" 0)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Dimstyle Lisp Help
« Reply #23 on: February 19, 2004, 07:55:28 AM »
Thanks guys for all your help.

Don
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023