Jump to content

Recommended Posts

Posted

Hi, Guys

 

As I understood a little bit how do functions work... I could refine my routine a bit and now someone asked for a different way to do it...

 

It creates several dimstyles based on the name of the desired scale...

typing E1, E5, E25 and so... you create the scale you want... but Now I wanted to allow the routine to create any desired scale and not to limit it to specific scales... so I made a value option... and I almost got it working... the only thing that I don`t know how to make it work is the complete name of the new dimtyle..

 

In red... the row that I don`t know how to write...

and in the next red row... the scale as it should be created..

 

any help will be appreciated...

 

 
;STANDARD PARA COTAS HECHO POR FAMILIA GIL
(vmon)
;; DIMENSION VARIABLES
;; THESE VALUES WILL AFFECT ALL NEW DIMSTYLES
;;
(defun dimvars (/)
  (COMMAND "style""RS""romans.shx""0.0"".8""0.00""N""N""N")
(command
"DIMADEC"     "2"             ; Angular decimal places
"DIMALT"      "Off"           ; Alternate units selected
"DIMALTD"     "2"             ; Alternate unit decimal places
"DIMALTF"     "25.4000"       ; Alternate unit scale factor
"DIMALTRND"   "0"             ; Alternate units rounding value
"DIMALTTD"    "2"             ; Alternate tolerance decimal places
"DIMALTTZ"    "0"             ; Alternate tolerance zero suppression
"DIMALTU"     "2"             ; Alternate units
"DIMALTZ"     "0"             ; Alternate unit zero suppression
"DIMAPOST"    ""              ; Prefix and suffix for alternate text
"DIMASO"      "On"
"DIMASSOC"    "2"
"DIMASZ"      "0.15"          ; Arrow size
"DIMATFIT"    "3"             ; Arrow and text fit
"DIMAUNIT"    "0"             ; Angular unit format
"DIMAZIN"     "0"             ; Angular zero supression
"DIMBLK"      "."             ; Arrow block name
"DIMBLK1"     "."             ; First arrow block name
"DIMBLK2"     "."             ; Second arrow block name
"DIMCEN"      "0.1"           ; Center mark size
"DIMCLRD"     "256"           ; Dimension line and leader color
"DIMCLRE"     "256"           ; Extension line color
"DIMCLRT"     "256"             ; Dimension text color
"DIMDEC"      "2"             ; Decimal places
"DIMDLE"      "0.0000"        ; Dimension line extension
"DIMDLI"      "0.1"           ; Dimension line spacing
"DIMDSEP"     "."             ; Decimal separator
"DIMEXE"      "0.05"          ; Extension above dimension line
"DIMEXO"      "0.1"           ; Extension line origin offset
"DIMFIT"      "4"             ; Move text, add leader when text doesn´t fit
"DIMFRAC"     "0"
"DIMGAP"      "0.05"          ; Gap from dimension line to text
"DIMJUST"     "0"             ; Justification of text on dimension line
"DIMLDRBLK"   ""              ; Leader block name
"DIMLFAC"     "1.0000"        ; Linear unit scale factor
"DIMLIM"      "Off"           ; Generate dimension limits
"DIMLUNIT"    "2"             ; Linear unit format
"DIMLWD"      "-2"            ; Dimension line and leader lineweight
"DIMLWE"      "-2"            ; Extension line lineweight
"DIMPOST"     ""              ; Prefix and suffix for dimension text
"DIMRND"      "0.0000"        ; Rounding value
"DIMSAH"      "Off"           ; Separate arrow blocks
"DIMSD1"      "Off"           ; Suppress the first dimension line
"DIMSD2"      "Off"           ; Suppress the second dimension line
"DIMSE1"      "Off"           ; Suppress the first extension line
"DIMSE2"      "Off"           ; Suppress the second extension line
"dimsho"      "on"
"DIMSOXD"     "Off"           ; Suppress outside dimension lines
"DIMTAD"      "2"             ; Place text above the dimension line
"DIMTDEC"     "2"             ; Tolerance decimal places
"DIMTFAC"     "0.8"  
"DIMTIH"      "Off"           ; Text inside extensions is horizontal
"DIMTIX"      "Off"           ; Place text inside extensions
"DIMTM"       "0.0000"        ; Minus tolerance
"DIMTMOVE"    "1"             ; Text movement
"DIMTOFL"     "On"            ; Force line inside extension lines
"DIMTOH"      "Off"           ; Text outside horizontal
"DIMTOL"      "Off"           ; Tolerance dimensioning
"DIMTOLJ"     "2"             ; Tolerance vertical justification
"DIMTP"       "0.0000"        ; Plus tolerance
"DIMTSZ"      "0.0000"        ; Tick size
"DIMTVP"      "0.0000"        ; Text vertical position
"DIMTXSTY"    "RS"            ; Associated Text style
"DIMTXT"      "0.2"           ; Text height
"DIMTZIN"     "0"             ; Tolerance zero suppression
"dimunit"     "2"
"DIMUPT"      "Off"           ; User positioned text
"DIMZIN"      "1"             ; Zero suppression
"DIMFRAC"     "0"             ; Fraction format    (0 is stacked 2 horiz)
"DIMTFAC"     "0.800"         ; Tolerance text height scaling factor
);end command
);end dimvars
;; LTSCALE AND TEXTSIZE VALUES
;;
(defun othervars (/)
  (COMMAND "LTSCALE" (* (getvar 'Dimscale)0.) 
  (COMMAND "TEXTSIZE" (* (getvar 'Dimscale)0.2)) 
);end othervars
;; START OF DIMSTYLES
;;
(defun C:ES ()
  (setq value (getdist "\nEscala deseada: "))
  (dimvars)
  (COMMAND "DIMSCALE" (/ value 100))  
  (othervars)
[color=red]  (COMMAND "DIMSTYLE""SAVE""ESC1.(strcat (rtos value)2 0)""Y")[/color]
 (princ (strcat "\nESCALA 1: "(strcat value)" CARGADA..."))
 (princ) 
)
;;
;;
(defun C:E25 ()
  (dimvars)
  (COMMAND "DIMSCALE"".25")
  (othervars)
[color=red]  (COMMAND "DIMSTYLE""SAVE""ESC1.25""Y")[/color]
  (prompt "\nESCALA 1:25 CARGADA...")   
(princ)
)
;;
;;

Posted

STRCAT function is used to concatenate together two or more strings - you need to include the "ESC1." string in his call; if the function call is included in string, as per your example, it will not be evaluated, but treated just as a string. Pay attention to RTOS function also, his mode arguments aren't included in call.

 

So instead of:

"ESC1.(strcat (rtos value)2 0)"

 

should use:

(strcat "ESC1." (rtos value 2 0))

 

Regards,

Posted
STRCAT function is used to concatenate together two or more strings - you need to include the "ESC1." string in his call; if the function call is included in string, as per your example, it will not be evaluated, but treated just as a string. Pay attention to RTOS function also, his mode arguments aren't included in call.

 

So instead of:

"ESC1.(strcat (rtos value)2 0)"

 

should use:

(strcat "ESC1." (rtos value 2 0))

 

Regards,

 

Didn`t work that way...

 

Command: es

Escala deseada: 7 Unknown command " (RTOS VALUE 2 0))". Press F1 for help.

Unknown command "Y". Press F1 for help.

bad argument type: stringp 7.0

 

I shoud get

Command: e25 Unknown command "Y". Press F1 for help.

ESCALA 1:25 CARGADA...

 

and in the case I select 7... I should get

Escala deseada: 7 Unknown command "Y". Press F1 for help.

ESCALA 1:7 CARGADA...

 

and a dmstyle called "ESC1.7" should be created... that the step I need to find out how..

 

In other words I need to create a Dimstyle using the text "ESC1.x" (but Instead the "x" I need to use the "value" previously entered by user)

 

Will you know how?

Posted
(if (tblsearch "dimstyle" (strcat "ESC1." (rtos value 2 0)))
 (COMMAND "DIMSTYLE" "SAVE" (strcat "ESC1." (rtos value 2 0)) "Y")
 (COMMAND "DIMSTYLE" "SAVE" (strcat "ESC1." (rtos value 2 0)))
)

Posted
(if (tblsearch "dimstyle" (strcat "ESC1." (rtos value 2 0)))
 (COMMAND "DIMSTYLE" "SAVE" (strcat "ESC1." (rtos value 2 0)) "Y")
 (COMMAND "DIMSTYLE" "SAVE" (strcat "ESC1." (rtos value 2 0)))
)

 

 

Yes ... you made it again Alan...

 

Anyway i got an error that doesn`t let the routine to end...

 

Command: ES

Escala deseada: 22 bad argument type: numberp: "ESC1.22"

Command:

 

Right now it creates the dimstyle E1.22, but I would like it to finish so I ould be aware of the dimstyle created... Do you know what could be the reason of this error?

 

 
(defun C:ES ()
  (setq value (getdist "\nEscala deseada: "))
  (dimvars)
  (COMMAND "DIMSCALE" (/ value 100))  
  (othervars)
(if (tblsearch "dimstyle" (strcat "ESC1." (rtos value 2 0)))
  (COMMAND "DIMSTYLE" "SAVE" (strcat "ESC1." (rtos value 2 0)) "Y")
  (COMMAND "DIMSTYLE" "SAVE" (strcat "ESC1." (rtos value 2 0)))
)
 (princ (strcat "\nEscala: " (rtos (getvar 'dimstyle)) " CARGADA..."))
 (princ) 
)

 

Nevermind... I solved it this way..

 

 (setq curdimstyl (getvar 'dimstyle))
 (princ (strcat "\nEscala: " curdimstyl " CARGADA..."))

Posted

Replace:

(princ (strcat "\nESCALA 1: "(strcat value)" CARGADA..."))

 

With:

(princ (strcat "\nESCALA 1: " (rtos value 2 0) " CARGADA..."))

Posted

So, It ended up this way...

 


;; STANDARD PARA DIMENSIONES HECHO PARA FAMILIA GIL
;; Por Paulo Gil Soto , con ayuda de Alan J. Thompson
;; 13 Abril 2010
(vmon)
;; DIMENSION VARIABLES
;; THESE VALUES WILL AFFECT ALL NEW DIMSTYLES
;;
(defun dimvars (/)
  (COMMAND "style""RS""romans.shx""0.0"".8""0.00""N""N""N")
(command
"DIMADEC"     "2"             ; Angular decimal places
"DIMALT"      "Off"           ; Alternate units selected
"DIMALTD"     "2"             ; Alternate unit decimal places
"DIMALTF"     "25.4000"       ; Alternate unit scale factor
"DIMALTRND"   "0"             ; Alternate units rounding value
"DIMALTTD"    "2"             ; Alternate tolerance decimal places
"DIMALTTZ"    "0"             ; Alternate tolerance zero suppression
"DIMALTU"     "2"             ; Alternate units
"DIMALTZ"     "0"             ; Alternate unit zero suppression
"DIMAPOST"    ""              ; Prefix and suffix for alternate text
"DIMASO"      "On"
"DIMASSOC"    "2"
"DIMASZ"      "0.15"          ; Arrow size
"DIMATFIT"    "3"             ; Arrow and text fit
"DIMAUNIT"    "0"             ; Angular unit format
"DIMAZIN"     "0"             ; Angular zero supression
"DIMBLK"      "."             ; Arrow block name
"DIMBLK1"     "."             ; First arrow block name
"DIMBLK2"     "."             ; Second arrow block name
"DIMCEN"      "0.1"           ; Center mark size
"DIMCLRD"     "256"           ; Dimension line and leader color
"DIMCLRE"     "256"           ; Extension line color
"DIMCLRT"     "256"             ; Dimension text color
"DIMDEC"      "2"             ; Decimal places
"DIMDLE"      "0.0000"        ; Dimension line extension
"DIMDLI"      "0.1"           ; Dimension line spacing
"DIMDSEP"     "."             ; Decimal separator
"DIMEXE"      "0.05"          ; Extension above dimension line
"DIMEXO"      "0.1"           ; Extension line origin offset
"DIMFIT"      "4"             ; Move text, add leader when text doesn´t fit
"DIMFRAC"     "0"
"DIMGAP"      "0.05"          ; Gap from dimension line to text
"DIMJUST"     "0"             ; Justification of text on dimension line
"DIMLDRBLK"   ""              ; Leader block name
"DIMLFAC"     "1.0000"        ; Linear unit scale factor
"DIMLIM"      "Off"           ; Generate dimension limits
"DIMLUNIT"    "2"             ; Linear unit format
"DIMLWD"      "-2"            ; Dimension line and leader lineweight
"DIMLWE"      "-2"            ; Extension line lineweight
"DIMPOST"     ""              ; Prefix and suffix for dimension text
"DIMRND"      "0.0000"        ; Rounding value
"DIMSAH"      "Off"           ; Separate arrow blocks
"DIMSD1"      "Off"           ; Suppress the first dimension line
"DIMSD2"      "Off"           ; Suppress the second dimension line
"DIMSE1"      "Off"           ; Suppress the first extension line
"DIMSE2"      "Off"           ; Suppress the second extension line
"dimsho"      "on"
"DIMSOXD"     "Off"           ; Suppress outside dimension lines
"DIMTAD"      "2"             ; Place text above the dimension line
"DIMTDEC"     "2"             ; Tolerance decimal places
"DIMTFAC"     "0.8"  
"DIMTIH"      "Off"           ; Text inside extensions is horizontal
"DIMTIX"      "Off"           ; Place text inside extensions
"DIMTM"       "0.0000"        ; Minus tolerance
"DIMTMOVE"    "1"             ; Text movement
"DIMTOFL"     "On"            ; Force line inside extension lines
"DIMTOH"      "Off"           ; Text outside horizontal
"DIMTOL"      "Off"           ; Tolerance dimensioning
"DIMTOLJ"     "2"             ; Tolerance vertical justification
"DIMTP"       "0.0000"        ; Plus tolerance
"DIMTSZ"      "0.0000"        ; Tick size
"DIMTVP"      "0.0000"        ; Text vertical position
"DIMTXSTY"    "RS"            ; Associated Text style
"DIMTXT"      "0.2"           ; Text height
"DIMTZIN"     "0"             ; Tolerance zero suppression
"dimunit"     "2"
"DIMUPT"      "Off"           ; User positioned text
"DIMZIN"      "1"             ; Zero suppression
"DIMFRAC"     "0"             ; Fraction format    (0 is stacked 2 horiz)
"DIMTFAC"     "0.800"         ; Tolerance text height scaling factor
);end command
);end dimvars
;; LTSCALE AND TEXTSIZE VALUES
;;

(defun othervars (/)
  (COMMAND "LTSCALE" (* (getvar 'Dimscale)0.) 
  (COMMAND "TEXTSIZE" (* (getvar 'Dimscale)0.2)) 
);end othervars

;; START OF DIMSTYLES
;;
(defun C:ES ()
  (setq value (getdist "\nEscala deseada 1:... "))
;; LOAD DIMVARS
  (dimvars)
  (COMMAND "DIMSCALE" (/ value 100))  
;; LOAD OTHERVARS
  (othervars)
;; CREATE NEW DIMSTYLE
(if (tblsearch "dimstyle" (strcat "ESC1." (rtos value 2 0)))
  (COMMAND "DIMSTYLE" "SAVE" (strcat "ESC1." (rtos value 2 0)) "Y")
  (COMMAND "DIMSTYLE" "SAVE" (strcat "ESC1." (rtos value 2 0)))
)
;; FINAL MESSAGE
 (setq curdimstyl (getvar 'dimstyle))
 (princ (strcat "\nEscala: " curdimstyl " CARGADA..."))
 (princ) 
)
;;
;;

Posted

No need to define the DimStyle:

 

(princ (strcat "\nEscala: " (getvar 'dimstyle) " CARGADA..."))

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...