Jump to content
autolisp

dimension style create (plz chk my new lisp & how to improve)

Recommended Posts

dear sir

plz chk my new lisp create dim style & how to improve

(defun c:dim100()
;check for layer and create if missing
 (if (= (tblsearch "layer" "Legend") nil)
 (command "layer" "make" "dimtest" "color" "7" "" "lt" "continuous" "" ""))
;check for style and create if missing
 (command "style" "style1" "arial.TTF" "0" "1" "0" "n" "n")
 (if (not (tblsearch "DImstyle" "Dim100"))
   (progn(command "dimstyle" "S" "Dim100")
     (command "dim" "style" "style1"
       "DIMADEC"   0
       "DIMALT"      0
       "DIMALTD"     3
       "DIMALTF"     0.0394
       "DIMALTRND"   0.0000
       "DIMALTTD"    3
       "DIMALTTZ"    0
       "DIMALTU"     2
       "DIMALTZ"     0
       "DIMASZ"      1.2000
       "DIMATFIT"    3
       "DIMAUNIT"    0
       "DIMAZIN"     0
       "DIMBLK"      "_Dot"
       "DIMBLK1"     ""
       "DIMBLK2"     ""
       "DIMCLRD"     8
       "DIMCLRE"     8
       "DIMCLRT"     4
       "DIMDEC"      0
       "DIMDLE"      0.0000
       "DIMDLI"      7.0000
       "DIMEXE"      2.0000
       "DIMEXO"      2.0000
       "DIMFRAC"     0
       "DIMGAP"      0.5000
       "DIMJUST"     0
       "DIMLFAC"     1.0000
       "DIMLIM"      0
       "DIMLUNIT"    2
       "DIMLWD"     9
       "DIMLWE"      9
       "DIMRND"      0.0000
       "DIMSAH"      0
       "DIMSCALE"    100.0000
       "DIMSD1"      0
       "DIMSD2"      0
       "DIMSE1"      0
       "DIMSE2"      0
       "DIMSOXD"     0
       "DIMTAD"      1
       "DIMTIH"      0
       "DIMTIX"      1
       "DIMTM"       0.0000
       "DIMTMOVE"    0
       "DIMTOFL"     1
       "DIMTOH"      0
       "DIMTSZ"      0.0000
       "DIMTVP"      0.0000
       "DIMTXSTY"    "style1"
       "DIMTXT"      2.5000
       "DIMFIT"         5 \e)
     (command "dimstyle" "S" "Dim100" "Y")))(graphscr)(princ))

Edited by Tiger
changed to code-tags

Share this post


Link to post
Share on other sites

I'm suggesting using a list of features and SETVAR function instead of that long command call:

 

(foreach SetupList '(("DIMADEC" . 0) ("DIMALT" . 0) ("DIMALTD" . 7))
(setvar (car SetupList) (cdr SetupList))
)

 

 

Regards,

Share this post


Link to post
Share on other sites
dear sir

plz chk my new lisp create dim style & how to improve

(defun c:dim100()
;check for layer and create if missing
(if (= (tblsearch "layer" "Legend") nil)
(command "layer" "make" "dimtest" "color" "7" "" "lt" "continuous" "" ""))
;check for style and create if missing
(command "style" "style1" "arial.TTF" "0" "1" "0" "n" "n")
(if (not (tblsearch "DImstyle" "Dim100"))
(progn(command "dimstyle" "S" "Dim100")
(command "dim" "style" "style1"
"DIMADEC" 0
"DIMALT" 0
"DIMALTD" 3
"DIMALTF" 0.0394
"DIMALTRND" 0.0000
"DIMALTTD" 3
"DIMALTTZ" 0
"DIMALTU" 2
"DIMALTZ" 0
"DIMASZ" 1.2000
"DIMATFIT" 3
"DIMAUNIT" 0
"DIMAZIN" 0
"DIMBLK" "_Dot"
"DIMBLK1" ""
"DIMBLK2" ""
"DIMCLRD" 8
"DIMCLRE" 8
"DIMCLRT" 4
"DIMDEC" 0
"DIMDLE" 0.0000
"DIMDLI" 7.0000
"DIMEXE" 2.0000
"DIMEXO" 2.0000
"DIMFRAC" 0
"DIMGAP" 0.5000
"DIMJUST" 0
"DIMLFAC" 1.0000
"DIMLIM" 0
"DIMLUNIT" 2
"DIMLWD" 9
"DIMLWE" 9
"DIMRND" 0.0000
"DIMSAH" 0
"DIMSCALE" 100.0000
"DIMSD1" 0
"DIMSD2" 0
"DIMSE1" 0
"DIMSE2" 0
"DIMSOXD" 0
"DIMTAD" 1
"DIMTIH" 0
"DIMTIX" 1
"DIMTM" 0.0000
"DIMTMOVE" 0
"DIMTOFL" 1
"DIMTOH" 0
"DIMTSZ" 0.0000
"DIMTVP" 0.0000
"DIMTXSTY" "style1"
"DIMTXT" 2.5000
"DIMFIT" 5 \e)
(command "dimstyle" "S" "Dim100" "Y")))(graphscr)(princ))

 

 

You could try it also with entmake. See attached. Make sure the DCL and LSP are together and in the ACAD Search Support Patch. See here:http://www.cadtutor.net/forum/showthread.php?9184-Code-posting-guidelines

DSTYLE.dcl

DSTYLE.lsp

Share this post


Link to post
Share on other sites
You could try it also with entmake. See attached. Make sure the DCL and LSP are together and in the ACAD Search Support Patch. See here:http://www.cadtutor.net/forum/showthread.php?9184-Code-posting-guidelines

dear sir

thx for sharing

1 question I select 1:100 scale

but dim style pick 1ft.

Share this post


Link to post
Share on other sites

Sorry, Please take note the program is incomplete and needs more work.

I have not had time to finish it, But it should give you some idea.

If I get some time today I will see what I can do.

Edited by The Buzzard

Share this post


Link to post
Share on other sites
Try this one.

dear sir

thx for reply

i'm using mm drg

but same problem is there

im select 1:100 but dimesion is come in feet

Share this post


Link to post
Share on other sites
dear sir

thx for reply

i'm using mm drg

but same problem is there

im select 1:100 but dimesion is come in feet

 

It is most likely the hard values I am using in the code.

You could remove all the Imperial stuff and keep the metric.

As I mentioned before, I would need some time to work out all the issues. Needs more conditionals.

I just got to the scaling part and did not finish the rest off.

 

 

The values would need to be changed here in this part of the code just as you would set the dimvariables.

You could take your values and use them here. Take note that I have them identified to the right.

;
; DimStyle Create
;
(defun DSTYLE_DIMSTYLE_CREATE (DSTY$ DSCL# AH$ FSTY$)
 (if (null (tblsearch "dimstyle" DSTY$))
   (progn
     (entmake
       (list
  (cons 0 "DIMSTYLE")                                           ; Entity Type
  (cons 100 "AcDbSymbolTableRecord")                            ; Subclass marker
  (cons 100 "AcDbDimStyleTableRecord")                          ; Subclass marker
  (cons 2 DSTY$)                                                ; Dimstyle name
  (cons 70 0)                                                   ; Standard flag value
  (cons 3 "")                                                   ; DIMPOST
  (cons 4 "")                                                   ; DIMAPOST
  (cons 5  AH$)                                                 ; DIMBLK
  (cons 6  AH$)                                                 ; DIMBLK1
  (cons 7  AH$)                                                 ; DIMBLK2
  (cons 40 DSCL#)                                               ; DIMSCALE
  (cons 41 0.0937)                                              ; DIMASZ
  (cons 42 0.0937)                                              ; DIMEXO
  (cons 43 0.38)                                                ; DIMDLI
  (cons 44 0.0625)                                              ; DIMEXE
  (cons 45 0.0)                                                 ; DIMRND
  (cons 46 0.0625)                                              ; DIMDLE
  (cons 47 0.0)                                                 ; DIMTP
  (cons 48 0.0)                                                 ; DIMTM
  (cons 140 0.0937)                                             ; DIMTXT
  (cons 141 0.09)                                               ; DIMCEN
  (cons 142 0.0)                                                ; DIMTSZ
  (cons 143 25.4)                                               ; DIMALTF
  (cons 144 1.0)                                                ; DIMLFAC
  (cons 145 0.0)                                                ; DIMTVP
  (cons 146 1.0)                                                ; DIMTFAC
  (cons 147 0.0625)                                             ; DIMGAP
  (cons 71 0)                                                   ; DIMTOL
  (cons 72 0)                                                   ; DIMLIM
  (cons 73 0)                                                   ; DIMTIH
  (cons 74 0)                                                   ; DIMTOH
  (cons 75 0)                                                   ; DIMSE1
  (cons 76 0)                                                   ; DIMSE2
  (cons 77 0)                                                   ; DIMTAD
  (cons 78 3)                                                   ; DIMZIM
  (cons 170 0)                                                  ; DIMALT
  (cons 171 2)                                                  ; DIMALTD
  (cons 172 0)                                                  ; DIMTOFL
  (cons 173 0)                                                  ; DIMSAH
  (cons 174 0)                                                  ; DIMTIX
  (cons 175 0)                                                  ; DIMSOXD
  (cons 176 1)                                                  ; DIMCLRD
  (cons 177 1)                                                  ; DIMCLRE
  (cons 178 2)                                                  ; DIMCRRT
  (cons 270 4)                                                  ; DIMUNIT
  (cons 271 4)                                                  ; DIMDEC
  (cons 272 4)                                                  ; DIMTDEC
  (cons 273 2)                                                  ; DIMALTU
  (cons 274 2)                                                  ; DIMALTTD
  (cons 275 0)                                                  ; DIMAUNIT
  (cons 276 2)                                                  ; DIMFRAC
  (cons 277 4)                                                  ; DIMLUNIT
  (cons 279 2)                                                  ; DIMTMOVE
  (cons 280 0)                                                  ; DIMJUST
  (cons 281 0)                                                  ; DIMSD1
  (cons 282 0)                                                  ; DIMSD2
  (cons 283 1)                                                  ; DIMTOLJ
  (cons 284 0)                                                  ; DIMTZIN
  (cons 285 0)                                                  ; DIMALTZ
  (cons 286 0)                                                  ; DIMALTTZ
  (cons 287 5)                                                  ; DIMFIT
  (cons 288 0)                                                  ; DIMUPT
  (cons 340 (tblobjname "style" FSTY$))                         ; DIMTXSTY 
  (cons 342 (cdr (assoc 330 (entget (tblobjname "block" AH$))))); DIMLDRBLK
  (cons 343 (cdr (assoc 330 (entget (tblobjname "block" AH$))))); DIMLDRBLK1
  (cons 344 (cdr (assoc 330 (entget (tblobjname "block" AH$))))); DIMLDRBLK2
       )
     )
   )
 )
 (command "._-dimstyle" "_restore" DSTY$)                              ; Set dimstyle current
 (alert (strcat "\nThe current DimStyle name is "DSTY$"."
                "\nThe current DimScale set to "(rtos DSCL# 2 0)"."))
)
;
;;;///////////////////////////////////////////////////////// 

Share this post


Link to post
Share on other sites

Ok, This is complete with the font style now, I did find it in your code. Sorry about that.

See attached. I also modified the DCL to make it look smaller or compact.

 

This looks better.

DSTYLE2.lsp

DSTYLE2.dcl

Document1.JPG

Edited by The Buzzard

Share this post


Link to post
Share on other sites
Ok, This is complete with the font style now, I did find it in your code. Sorry about that.

See attached. I also modified the DCL to make it look smaller or compact.

 

This looks better.

dear sir

thx for reply

nice working

thx again for sharing

Share this post


Link to post
Share on other sites
dear sir

thx for reply

nice working

thx again for sharing

 

Your very welcome,

 

Is there anything that needs adjusting or is this OK?

Share this post


Link to post
Share on other sites
Your very welcome,

 

Is there anything that needs adjusting or is this OK?

dear sir

thx for help

it's possible add button

meter dimension & Milimeter dimension

each dimension style create same layer

(example:- dim style = dim100, layer style = Dim100)

ds1.JPG

Share this post


Link to post
Share on other sites
dear sir

thx for help

it's possible add button

meter dimension & Milimeter dimension

each dimension style create same layer

(example:- dim style = dim100, layer style = Dim100)

 

It is my understanding when dimensioning in metric 1:100 can mean millimeters or meters depending on which you decide to draw in. I do not believe there is a setting for this in the dimension style manager. If you could elaborate a bit more on how you want to arrive at this would be helpful. The dimension variable DIMPOST can place an m or mm after the primary unit if that would help, But I do not think this is what you are after. The layer issue is no big deal and can be easily set up.

Edited by The Buzzard

Share this post


Link to post
Share on other sites
It is my understanding when dimensioning in metric 1:100 can mean millimeters or meters depending on which you decide to draw in. I do not believe there is a setting for this in the dimension style manager. If you could elaborate a bit more on how you want to arrive at this would be helpful. The dimension variable DIMPOST can place an m or mm after the primary unit if that would help, But I do not think this is what you are after. The layer issue is no big deal and can be easily set up.

dear sir

thx for help

Share this post


Link to post
Share on other sites
autolisp,

Attached is the layer fix. Type DSTYLE3 to start program.

 

Great... That's what I wanted to find long ago. We use one of this kind in the company I work for, but I wished I could customize it for my own standard. Now I can do it with your great routine.

You really made it.

Share this post


Link to post
Share on other sites
Great... That's what I wanted to find long ago. We use one of this kind in the company I work for, but I wished I could customize it for my own standard. Now I can do it with your great routine.

You really made it.

 

Thats good, But understand that the arrowheads are custom blocks in this routine. If you get stuck then just ask.

Share this post


Link to post
Share on other sites

Kind of off topic but still related.

 

FWIW, technically speaking you dont really need to search the database for a layer name with entmake. However, you would if you needed to decide to either use ENTMAKE or ENTMOD something like the following:

 

(defun DSTYLE3_LAYER_CREATE (LNAM$ LCLR# LTYP$ LWGT# / #prog)
 (if (null (tblsearch "layer" LNAM$))
   (set '#prog (lambda ( x ) (entmake x)))
   (set '#prog (lambda (x / ent y)
                 (setq ent (entget (tblobjname "LAYER" LNAM$)))
                 (foreach y x
                          (if (not (member (car y) '(0 100 2)))
                            (setq ent (subst y (assoc (car y) ent) ent))))
                 (entmod ent) )))
 (#prog
  (list
    (cons 0   "LAYER")
    (cons 100 "AcDbSymbolTableRecord")
    (cons 100 "AcDbLayerTableRecord")
    (cons 2    LNAM$)
    (cons 6    LTYP$)
    (cons 62   LCLR#)
    (cons 70   0)
    (cons 290  1)
    (cons 370  LWGT#)
    )
  )
(princ)
)

 

So using this...

 

(DSTYLE3_LAYER_CREATE "Test-Layer" 1 "Continuous" 18)
;; would create the layer
(DSTYLE3_LAYER_CREATE "Test-Layer" 2 "Continuous" 18)
;; would override the current layer def.

Edited by Se7en
forgot a slash in the arg list (localization)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×