gilsoto13 发表于 2022-7-6 11:23:53

使用创建名为的dimstyle

嗨,伙计们
 
正如我所了解的,函数是如何工作的。。。我可以改进一下我的日常生活,现在有人要求用不同的方式来做。。。
 
它根据所需比例的名称创建多个尺寸样式。。。
键入E1、E5、E25等。。。你创建你想要的比例。。。但现在我想允许例程创建任何所需的比例,而不是将其限制到特定的比例。。。所以我做了一个价值选择。。。我差点就成功了。。。我唯一不知道该怎么做的是新dimtyle的全名。。
 
红色。。。我不知道怎么写的那一行。。。
在下一个红排。。。应创建的比例。。
 
任何帮助都将不胜感激。。。
 

;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)
(COMMAND "DIMSTYLE""SAVE""ESC1.(strcat (rtos value)2 0)""Y")
(princ (strcat "\nESCALA 1: "(strcat value)" CARGADA..."))
(princ)
)
;;
;;
(defun C:E25 ()
(dimvars)
(COMMAND "DIMSCALE"".25")
(othervars)
(COMMAND "DIMSTYLE""SAVE""ESC1.25""Y")
(prompt "\nESCALA 1:25 CARGADA...")   
(princ)
)
;;
;;

MSasu 发表于 2022-7-6 11:36:12

STRCAT函数用于将两个或多个字符串连接在一起-您需要包括“ESC1”在他的电话里挂线;根据您的示例,如果函数调用包含在字符串中,则不会对其求值,而是将其视为字符串。还要注意RTOS函数,他的模式参数不包括在调用中。
 
因此,不是:
"ESC1.(strcat (rtos value)2 0)"
 
应使用:
(strcat "ESC1." (rtos value 2 0))
 
当做

gilsoto13 发表于 2022-7-6 11:46:25

 
不是那样的。。。
 
命令:es
Escala deseada:7未知命令“(RTOS值2 0))”。按F1键获取帮助。
未知命令“Y”。按F1键获取帮助。
错误的参数类型:stringp 7.0
 
我应该得到
命令:e25未知命令“Y”。按F1键获取帮助。
埃斯卡拉1:25卡加达。。。
 
如果我选择7。。。我应该得到
Escala deseada:7未知命令“Y”。按F1键获取帮助。
埃斯卡拉1:7卡加达。。。
 
应该创建一个名为“ESC1.7”的dmstyle。。。这一步我需要找出如何。。
 
换句话说,我需要使用文本“ESC1.x”创建一个Dimstyle(但我需要使用用户之前输入的“value”来代替“x”)
 
你知道怎么做吗?

alanjt 发表于 2022-7-6 11:52:24

(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)))
)

gilsoto13 发表于 2022-7-6 11:58:45

 
 
对你又成功了,艾伦。。。
 
无论如何,我犯了一个错误,这个错误并没有让程序结束。。。
 
命令:ES
Escala-deseada:22错误参数类型:numberp:“ESC1.22”
命令:
 
现在它创建了dimstyle E1.22,但我希望它完成,这样我就可以知道创建的dimstyle了。。。你知道这个错误的原因是什么吗?
 

(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)
)

 
没有关系。。。我这样解决了。。
 

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

alanjt 发表于 2022-7-6 12:12:42

替换:
(princ (strcat "\nESCALA 1: "(strcat value)" CARGADA..."))
 
使用:
(princ (strcat "\nESCALA 1: " (rtos value 2 0) " CARGADA..."))

gilsoto13 发表于 2022-7-6 12:19:23

所以,结果是这样的。。。
 


;; 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)
)
;;
;;

alanjt 发表于 2022-7-6 12:30:25

无需定义DimStyle:
 
(princ (strcat "\nEscala: " (getvar 'dimstyle) " CARGADA..."))
页: [1]
查看完整版本: 使用创建名为的dimstyle