三维网

标题: 求助:帮忙开发一个AutoCAD小程序 [打印本页]

作者: bigbridge812    时间: 2010-6-3 14:58
标题: 求助:帮忙开发一个AutoCAD小程序
各位高手:
) ?$ q" V; I8 d  j7 [0 c/ l帮忙写一个小程序,lisp就可以,' L8 ?" n3 }8 n( p- p
如图,实现现有所有标注样式的前导不消零,后续消零,因为我们有图纸是从SolidWorks转为AutoCAD的,有这个需求。AutoCAD版本是2008的。) `0 Y! s* L4 E" J3 l; ?) Z
谢谢各位了!: t# ^7 A/ s6 e+ Z4 N# k
长期在线等!
作者: SunVei    时间: 2010-6-3 16:05
后续消零3 a0 G; u3 e0 e2 S% b3 p
DimZin ==> 8
5 t; v7 ]: k9 F" f1 `5 j# ]4 E, _1 q=================3 z/ V6 w6 E3 `! ~# V& m' r$ j  ~
DIMZIN System Variable
5 {2 D: _- e) \6 v2 y! o..." ]* M3 ^3 N! l* d9 Y
8 Suppresses trailing zeros in decimal dimensions (for example, 12.5000 becomes 12.5)
% W& Q1 S& w+ i2 j: x, A....0 V2 o# `5 y$ {- r4 Y  @
1 M# I! ?# t5 A
DIMZIN also affects real-to-string conversions performed by the AutoLISP rtos and angtos functions.
作者: bigbridge812    时间: 2010-6-3 16:40
2# SunVei
! J1 p. ^4 f* Y! I8 p8 V. H) q$ @* g5 l$ ]0 k( t3 j! e% O: |- C: H
能不能详细一点,帮助上也是像你说的,但是不能用,能解释一下么?
- L! u; H/ R6 O6 Q最好可以有个小程序。1 ?. p- y9 N7 ~# M; s
还有前导不消零怎么实现?
作者: SunVei    时间: 2010-6-3 18:43
但是不能用!?
) K8 M& ]+ W3 n0 R挺纳闷底....2 X, b; S1 N! [* W# ~. d
1 Z7 Y2 n3 l; [& x
得就您的文件来比对系统变量值了 (Required *.Dwg)
作者: bigbridge812    时间: 2010-6-4 08:38
4# SunVei
0 Q( e5 f& ~6 i" Q; Y还是谢谢了!
作者: SunVei    时间: 2010-6-4 09:04
Command: DimZin+ I+ Q  t1 a5 X; c# O8 N0 t
Enter new value for DIMZIN <0>:
% D) H# `; Y8 v2 T; u
/ G( P+ ?" W% Y$ c7 X0 Suppresses zero feet and precisely zero inches 2 f9 Z/ [" E' c! a( U
1 Includes zero feet and precisely zero inches
2 l) I$ R4 T4 M' @2 H0 Z2 Includes zero feet and suppresses zero inches
- y7 y$ B3 @! i3 Includes zero inches and suppresses zero feet 5 R9 |8 U( Y0 j3 T$ E5 v0 q
4 Suppresses leading zeros in decimal dimensions (for example, 0.5000 becomes .5000)
- ]/ H3 A+ V/ U& |* K/ E8 Suppresses trailing zeros in decimal dimensions (for example, 12.5000 becomes 12.5) 3 x: Z& k1 h( b/ d/ A# G; q
12 Suppresses both leading and trailing zeros (for example, 0.5000 becomes .5) / j2 v1 p: v* u/ G* J

8 e& n9 e7 N+ t6 x==> 若为 4 前导消零
作者: bigbridge812    时间: 2010-6-5 11:22
6# SunVei 2 s9 a  b, \2 U9 ]3 k0 ~$ g
这个我以前就试过,对于现有的标注好像也没有效果!
作者: czboy    时间: 2010-6-7 19:58
用vba怎样做呢
作者: woaishuijia    时间: 2010-6-7 23:23
本帖最后由 woaishuijia 于 2010-6-8 07:31 编辑
% ^/ V, Q& N5 K. F# e' m  [
0 d! m8 r) L+ W+ T以下是VBA
' R2 m: f* l; f7 ^( }9 C

  1. . s& J4 L9 a/ ~' T
  2.     Dim DS1 As AcadDimStyle, DS2 As AcadDimStyle! Z' x: a! ?/ w) e
  3.     With ThisDrawing* a( ]# r) t9 D  w$ r. m  h) B
  4.         Set DS1 = .ActiveDimStyle" _) `4 B4 W2 M4 z/ n  Z# c
  5.         For Each DS2 In .DimStyles
    5 p, p. F! M7 S5 O+ C; v, I
  6.             .ActiveDimStyle = DS2# W$ o1 M: z2 N7 [4 G1 H
  7.             .SetVariable "dimzin", 8
    ' |: Q  O  N! ^0 P
  8.             .SendCommand "-dimstyle s " & DS2.Name & vbCr & "y "% L0 q. H1 x; ~8 A
  9.         Next5 w1 @& Z% o4 r0 ^7 O: j* j1 n' \
  10.         .ActiveDimStyle = DS1& m4 |" c9 f3 {  \% D" k! Q" o6 P
  11.     End With. \/ U6 k5 d9 w# d2 r7 Y
复制代码

+ r1 V: D: O( C以下是LSP' q; j# I/ d% d# W0 ?% B7 m% y) A8 S
  1. ; {- ?9 B: t8 E' j' d$ \% s
  2. (defun c:aaa(/ dimstylelist dimstylename)& H" U4 @- A6 e$ r+ Y2 N
  3.   (setq dimstylelist(tblnext "dimstyle" t))5 ]: V0 N- @/ U* P2 ~/ Y6 s
  4.   (while dimstylelist$ K% r- \( Z, Y: c  l7 w
  5.     (setq dimstylename(cdr (assoc 2 dimstylelist)))
    ' \0 L2 p" n" P( Q( }+ p
  6.     (command "-dimstyle" "r" dimstylename)+ ^' r6 o/ M+ w& s/ S$ B; B
  7.     (command "setvar" "dimzin" 8)1 F6 t% a9 l9 j$ a9 @  [" u* R' [
  8.     (command "-dimstyle" "s" dimstylename "y")      , h8 y0 i# W* A0 @$ V" d
  9.     (setq dimstylelist(tblnext "dimstyle"))
    8 f% j& k1 H  q" [6 V2 U6 W7 F( @6 D
  10.     )
    # q' u+ K% Z" C1 o" o9 g: [
  11.   (princ)
    8 B. G9 }( y7 F# `& H  m
  12.   )$ u* v; `2 r$ [% k; X
复制代码

作者: bigbridge812    时间: 2010-6-10 09:38
本帖最后由 bigbridge812 于 2010-6-10 10:03 编辑
0 H) X" S2 ~9 l# ^' E" m7 s+ {& b
6 \1 o3 k4 y  ^怎么评分啊?
9 l, _- B* H: B# E  I; s% ^" u感谢9楼!谢谢了
作者: bigbridge812    时间: 2010-6-10 10:06
利用9楼的程序框架还可以进行各种设置,非常感谢!




欢迎光临 三维网 (http://3dportal.cn/discuz/) Powered by Discuz! X3.4