Jump to content

entmake for dimension styles


MastroLube

Recommended Posts

Hi there, I've a problem creating dimension styles using entmake.

 

This is the lisp I'm using:

 

(vl-load-com)
(defun C:creadim (/)
 (creadimstyle (getstring "\nNome: "))
 )
(defun creadimstyle (dim_name /)
;(setq dim_name (getstring "\nNome: "))
 (setq ;Dim_Name 				"Appoggi"
   
       DIMBLK-Name				"Oblique" ;archtick ClosedFilled
       dimscale				1.0
       quote_scale				100 ;scala di quota
  Arrow_Size 				0.05
  Center_Mark_Size			0.0625
  Decimal_Places			0
  Dimension_Line_Spacing		0.0
  Extension_Above_Dimension_Line	0.0
  Extension_Line_Origin_Offset		0.0
  Gap_From_dimension_Line_to_Text	0.03
  Tolerance_Decimal_places		2
  Text_Movement				0
  Text_Font				"SIMPLEX.SHX"
  Text_Height 				0.1)
 
       (command "_-style" "SIMPLEX" "SIMPLEX.SHX" "0" "1" "" "" "" "")
       ;(setvar "lunits" 2)
       ;(setvar "DIMASSOC" 1)
       (setq ds
       (list
         (cons 0 "DIMSTYLE")
         (cons 100 "AcDbSymbolTableRecord")
         (cons 100 "AcDbDimStyleTableRecord")
         (cons 2 Dim_Name)    ;Dim style name
         (cons 70 0)     ; Standard flag
         (cons 3 ""); DIMPOST
  (cons 4 ""); DIMAPOST
         (cons 5 DIMBLK-Name)    ;DIMBLK-Name of block instead of default arrowhead
         (cons 6 DIMBLK-Name);(cons 6 "ClosedFilled"); DIMBLK1
  (cons 7 "");(cons 7 DIMBLK-Name); DIMBLK2
         (cons 170 0)     ;DIMALT-turns off alternate units
         (cons 40 dimscale)     ;DIMSCALE-sets the overall scale factor applied to all dimensions
         (cons 41 Arrow_Size)    ;DIMASZ-sets the size of the arrow/tick
         (cons 42 Extension_Line_Origin_Offset); DIMEXO
         (cons 43 Dimension_Line_Spacing); DIMDLI
  (cons 44 Extension_Above_Dimension_Line)    ;DIMEXE-specifies how far to extend the extention line beyound the dim line
  (cons 45 0.0); DIMRND

         (cons 46 0)     ;DIMDLE-sets the distance the dimension line extends beyond the extension line

         (cons 47 0.0); DIMTP
	 (cons 48 0.0); DIMTM
         
         (cons 71 0); DIMTOL
	 (cons 72 0); DIMLIM
        
         (cons 73 0)     ;DIMTIH-controls the position of dimension text inside extention lines ;METTE	IL TESTO DI QUOTA ORIZZONTALE
         (cons 74 0)     ;DIMTOH-controls the position of dimension text outside extention lines
         (cons 75 1); DIMSE1 ;1 sopprime la linea di estensione, 0 la lascia 
         (cons 76 1); DIMSE2 ;1 sopprime la linea di estensione, 0 la lascia 
         (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 79 1); DIMAZIN
         (cons 140 Text_Height)    ;DIMTXT-specifies the height of the text in the dim
         		 (cons 141 Center_Mark_Size); DIMCEN
	 (cons 142 0.0); DIMTSZ
         (cons 143 0.5)    ;DIMALTF-controls the scale factor for alt. units
         (cons 144 quote_scale); DIMLFAC ;scala di quota
	 (cons 145 0.0); DIMTVP
	 (cons 146 0.64); DIMTFAC
         (cons 147 Gap_From_dimension_Line_to_Text)    ;DIMGAP-sets the distance from around the dim text
         (cons 170 0); DIMALT
         (cons 171 2)     ;DIMALTD-controls the decimal places for units
         (cons 172 0)     ;DIMTOFL-forces a line inside extension lines

         (cons 173 1); DIMSAH
	 (cons 174 0); DIMTIX
	 (cons 175 0); DIMSOXD
	 (cons 176 256); DIMCLRD
	 (cons 177 256); DIMCLRE
	 (cons 178 256); DIMCRRT
	 (cons 179 0); DIMADEC
         
         (cons 270 2)     ;DIMUNIT-sets the units format for all dims ;2 decimale ; 4architettonico
         (cons 271 Decimal_Places)     ;DIMDEC-sets the number of decimal places of primary units
         (cons 272 Tolerance_Decimal_places); DIMTDEC
         (cons 273 2)     ;DIMALTU-sets the units for alt. units
         (cons 275 0)     ;DIMAUNIT-sets the angular format for angular dims
         (cons 276 1); DIMFRAC
	 (cons 277 2); DIMLUNIT ;2 decimale ; 4architettonico
	 (cons 278 0); DIMDSEP
	 (cons 279 Text_Movement); DIMTMOVE
         (cons 280 0)     ;DIMJUST-controls the horizontal positioning of dim text
         (cons 281 0); DIMSD1
	 (cons 282 0); DIMSD2
	 (cons 283 1); DIMTOLJ
	 (cons 284 3); DIMTZIN
	 (cons 285 1); DIMALTZ
         (cons 286 0)     ;DIMALTTZ-Toggles the suppression in tolerance values
         ;(cons 287 0); DIMFIT
	 ;(cons 288 0); DIMUPT
	 ;(cons 289 0); DIMATFIT
	 (cons 340 (tblobjname "style" "SIMPLEX")); DIMTXSTY
	 ;(cons 341 (cdr (assoc 330 (entget (tblobjname "block" "."))))); DIMLDRBLK
	 ;(cons 342 (cdr (assoc 330 (entget(tblobjname "block" "_Oblique"))))); DIMBLK
	 ;(cons 343 (cdr (assoc 330 (entget(tblobjname "block" "_Oblique"))))); DIMBLK1
	 ;(cons 344 (cdr (assoc 330 (entget(tblobjname "block" "_Oblique"))))); DIMBLK2
	 ;(cons 371 -2); DIMLWD
	 ;(cons 372 -2); DIMLWE
       )
 )
(entmake ds)
 (command "_-dimstyle" "_restore" dim_name)
;(dimsave)
(princ)
)
(defun dimsave ()
(command "DIMSTYLE" "_R" "DIMTEST")
(setvar "DIMTXSTY" "SIMPLEX")
(command "DIMSTYLE" "_S" "DIMTEST" "Y")
)

 

This is what i get:

4CzBOAm.png

And this is what i want to get:

duXxI59.png

 

I've tried to dump the quote entity with

(entget (car (entsel)))

in order to correct the dxf code but i don't get the dimensionstyle dxf code.

 

How can i dump the dimension style dxf codes?

 

Thanks :)

Dennis

Link to comment
Share on other sites

  • 3 years later...

Hello guys, sorry for re-opening this old post but it's related!

 

I get these dimension style with "Closed filled" as arrowheads.

I'm not able to modify that!

I've changed these parts of the code

...
(cons 5 "Oblique") ;DIMBLK-Name of block instead of default arrowhead
(cons 6 "Oblique");(cons 6 "ClosedFilled"); DIMBLK1
(cons 7 "Oblique");(cons 7 DIMBLK-Name); DIMBLK2
:::

But it doesn't work!

Where is the error?

 

An extra question is if I can make it working even with italian version of autocad using the english world "Oblique".

 

Thanks for your help!

Dennis

Link to comment
Share on other sites

  • 5 weeks later...

check out this routine to create Dimstyles, probably you'll find it useful. It does a similar job.

 

Creates a new Dimstye¿le using the scale you type and it will add it to your Dimstyles with a new name depending on the selected scale.

std.lsp

Link to comment
Share on other sites

Perhaps something like this? <insecure coding> :

; (ChangeArrowHeadForDimstyle (getvar 'dimstyle) "_Open30")
; (ChangeArrowHeadForDimstyle (getvar 'dimstyle) "_Origin2")
(defun ChangeArrowHeadForDimstyle ( dimstl blknm / e enx1 enx2 )
  (cond 
    ( (not (setq e (tblsearch "BLOCK" blknm))) (prompt (strcat "\nUnable to find the block: " blknm)) )
    ( (not (setq dms (tblobjname "DIMSTYLE" dimstl))) (prompt (strcat "\nUnable to find the dimstyle: " dimstl)) )
    (t
      (setvar 'dimblk blknm)
      (setq enx2 (entget (cdr (assoc 342 (setq enx1 (entget dms))))))
      (setq enx2 (subst (cons 2 blknm) (assoc 2 enx2) enx2))
      (setq enx2 (subst (cons 360 e) (assoc 360 e) enx2))
      (entmod enx2) (entmod enx1)
      t
    )        
  )
)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...