Drupal blog posts https://www.highflybird.com/drupal/ zh-hans 空间之觉:一种建筑现象学 https://www.highflybird.com/drupal/node/179 <span class="field field-name-title field-formatter-string field-type-string field-label-hidden">空间之觉:一种建筑现象学</span> <span class="field field-name-uid field-formatter-author field-type-entity-reference field-label-hidden"><span lang="" about="/drupal/user/1" typeof="schema:Person" property="schema:name" datatype="">highflybird</span></span> <span class="field field-name-created field-formatter-timestamp field-type-created field-label-hidden">周四, 02/18/2021 - 11:41</span> <div class="clearfix text-formatted field field-node--body field-formatter-text-default field-name-body field-type-text-with-summary field-label-hidden has-single"><div class="field__items"><div class="field__item"><div class="tex2jax_process"><p>此文来自:https://ptext.nju.edu.cn/c1/92/c12242a246162/page.htm</p> <p>空间之觉:一种建筑现象学</p> <p>严惟愉</p> <p><br /> “诗人和画家来自于现象学家。”[2]<br /> 艺术家使用现象学的方法意味着对事物本质的纯粹的看,放下了经验和理性的解释。一个作家、画家、导演设置一个场景,必须限定一个行为发生的背景和环境,假想一个地点,而“创造空间”是建筑师的首要任务,因此,这些艺术家不自觉地承担了建筑师的任务。由于没有受到建筑学专业的规则和教条的基础,艺术家更能达到建筑体验的精神度向,也更为直接的显示出建筑艺术的现象学基础。塔可夫斯基[3](Tarkovsky)的电影《乡愁》(Nostalgia)中富有诗意的空间和光的图像,便是这样一部建筑现象学的长诗。它触及建筑学存在的基础,充满了被渐渐忘却的童年时的记忆和经验,通过空间的图像,揭示了物质与现象、有形与无形、庇护与暴露、过去与现在、有限与无限的交融流转。</p> <p> </p> <p>记忆:塔可夫斯基电影《乡愁》中的影像与空间<br /> 塔可夫斯基的影片有一种俄罗斯乡间田园的影像和诗歌风格:《乡愁》序幕的开篇镜头便是绘画般的风景:树、水、狗、模糊的黑白风景,以及风景中缓慢行走的人的黑色剪影;(图1)紧接着影片开始,出现的是迷雾中青葱的意大利乡村风景,一辆大众汽车从画面右侧横穿画面至左,短暂的消失之后又从画面左下侧驶出,安德烈·戈查可夫(Andrei)和尤金尼亚(Eugenia)走出车外。接着是乡村小教堂中逆光的密密阵列的柱子,镜头从二点斜透视缓慢变为一点透视停止下来;山坡上的小木屋安静地伫立在画面上方,如同从山腰上生长出来一般;雾气缭绕的露天浴池,镜头与主人翁的背影、池中的雾气同时向画面左方缓慢移动;戈尔恰科夫和尤金尼亚在旅馆走廊中的谈话,首先听到声音,然后分别看到两位主人公。影片中多处出现古典拉丁式建筑的褐色石块,缀满碧绿针叶的意大利松树,蒸汽氤氲的维尼奥尼温泉浴池的景像。还有多米尼戈(Domenico)水淹的房间,残破的墙面,星星点点的光线,半堵坍塌墙壁上可以打开的门,半透明的绿色和棕色酒瓶,淅沥的雨滴,废墟里水晶般的积雨,跳跃的光影,摆动的水草,潮湿的绿色植被,弥漫的忧郁……</p> <p> </p> <p>塔可夫斯基的影像让人想起绘画,特别是文艺复兴早期的俄罗斯绘画。塔可夫斯基年轻时曾经画过三年画,他的第二部影片《安德烈·鲁勃廖夫》[4](Andrei Rublev)便是关于15世纪俄罗斯肖像画家鲁勃廖夫[5](Rublev),在他的著作中时常会提到达利、凡高、哥雅、拉菲尔等众多的画家。但他本人却强调电影和绘画这两种艺术形式的不同,认为“随着时间的发展,我认为,电影将远离文学和其他艺术形式,成为越来越自主的艺术。” 电影空间与绘画空间有所不同,正如安德列·巴赞[6](Andre Bazin)在《电影是什么》中阐述的:“画框与周围空间毗连,形成一个与自然空间相对立的,与真实空间相对立的内向空间,这个关照性空间仅仅向画内开放……银幕的边缘不是画框,银幕展现的景色似乎可以延伸到外部世界,画框是内向的,银幕是离心的。”[7]正是电影空间的这种特质,使塔可夫斯基得以在银幕内展示无限深远的空间,并且溶入观者,指向观者的内心世界。</p> <p> </p> <p>塔可夫斯基的影像空间大多以一点透视的方式展现,如同戏剧一样,这种传统的空间表达有助于压平银幕图像。《乡愁》通过雾、水、雨、黑夜模糊了影像、空间和形体的边缘,使影像从现实中抽离出来,弱化真实效果,强调出平面感。这样,黑夜、弥散的雾,甚至透空的栏杆都参与到场面调度中来,成为塔可夫斯基电影中空间塑形的参与者。这近乎于中国山水画中的空间场景,也和日本枯山水中使用裸砂的方法如出一辙。正因如此,塔可夫斯基的影像具有一种平面感,它弱化真实空间深度的同时,扩展了心理空间的深度,消除了现象与本质对立的深度模式,空间从背景中走出,变成正文。(图2)</p> <p> </p> <p>门和窗在塔可夫斯基电影中扮演着不可替代的角色,门和窗让光线进来,让视线穿过,人和观众从这里看进来或者看出去,从而创造了一系列令人惊讶的形而上学的美丽(图3)。其中一个经典镜头是:左边一方是狭长的窗,明亮的,下着雨;右边下方是同样狭长的门,里面有块大圆镜子,忽明忽暗地辉映着雨;中间有一张大床,寂寞的俄罗斯诗人横卧着;床上方的栏杆,有优美的线条,却在光影里显得很落寞。这个构图是完美的,从细部来说,有些活泼的对比,比如方和圆,亮和暗,上和下,纤巧和厚重,并且错落有致地安排了三个空间。(图4)</p> <p> </p> <p>废墟,在影片里隐含了一种记忆,但并非简单的象征和隐喻。废墟的特别之处在于抓住了我们的情感,因为它让我们想起那些被遗忘的信仰。比起新的建筑物,人更容易被它打动,废墟剥去了实用和理性的面纱,它不完全是一个建筑物,已经停止扮演建筑物的角色,它显示出记忆的结构骨骼,是一种纯粹忧郁的情绪。房屋与废墟的区别形成了一种潜在的记忆,换言之,房屋、记忆在废墟里得到了统一。虽然在真实的建筑学中很少面对漏雨或被水淹没的房间,但在塔可夫斯基的电影里,这种影像十分有力,这种冲击力来自于房子和水,来自于庇护和暴露、有形和无形、有限和无限的特有意象的溶解(图5)。当代社会似乎有一种取消历史感和擦除时间痕迹的倾向,人们更热衷于以后现代式的无意识的拼贴(Collage)取代现代时期的有意识的剪辑(Montage),时间和空间的特殊形式产生了断断续续的碎片,使人们的记忆显得无所适从。而塔可夫斯基却似乎向我们证明,历史感不仅仅是个体对人类时间存在的意识,或对过去历史规律的意识,而可以是一种新的模糊的和似曾相识的记忆。<br /> 时间是塔可夫斯基电影里与空间紧密相关的另一个重要维度。塔可夫斯基的作品中的影像诗学,正源自于他对时间的描摩。在他的作品中,总是能让观者清楚地意识到时间的存在,一秒钟的流逝——在枯叶飘落,在水面涟漪的波纹和荡漾的水草,在一声轻杳的喟然叹息中。如果说时间是有重量的,那么藉影像所雕刻的时间重量,可以说是一个巨大存在。对塔可夫斯基而言,电影的本质就是“时间”。透过事实的具体形象,电影中的时间仿佛是真实时间的铸形,在人物移动和环境形态中,影像、时间以及与时间牢不可分的物质世界共同构成了电影艺术(图6)。他说道:“在电影里,我们纪录某一空间,是为了创造出时间的幻觉。”[8]在塔可夫斯基的《雕刻时光》一书中,他表示:“我至今仍无法忘怀出现于上个世纪的那部天才之作、揭开电影序幕的影片《火车进站》[9](L'Arrivee d'un Train en Gare de La Ciotat)……那正是电影诞生的时刻,它不只是技术问题,也不只是一种再现世界的新方法,而是一种全新的美学原则的诞生。因为人类首度发现了留取时间印象的方法。”[10]</p> <p> </p> <p>电影是时间的艺术,并且是惟一可以用时间长度来计量的艺术。当爱森斯坦用“特写镜头”把某个人物突现出来的时候,他仿佛是在进行剪辑,并在时间上重新加以安排,从而揭示出壁画的戏剧性实质。爱森斯坦事实上是从“单纯的空间艺术”中挖掘出潜在的时间维度[11]。而塔可夫斯基更多地像巴赞主张的那样,使用长镜头来表达时间的绵延。当我们看到《乡愁》里流落异乡的戈查可夫,手捧着闪烁的微弱烛火,小心翼翼的横越荒芜的温泉水池,从银幕这端到那端,随着烛火的移动,影像建构了另一个流动的时空(图7)。闪烁烛火的“动”和缓慢到几乎让人察觉不出移动的镜头摇摄的“静”在这一个长镜头内,构筑了属于戈查可夫、属于影像本体的时间宇宙,涵涉其内的是交融了主人翁记忆与追寻情感的厚度,投射于外的则是某种经验在时间的长度中延伸、强化、凝聚。这样的时空犹如存在于每个人心底的幽冥之境,过去与现在、记忆与渴望在此刻交织成一片时空的混沌,简单的影像下触及的是内心世界深层活动状态。塔可夫斯基说道:“时间或空间两者都不存在于与人类范畴相关的事物之外。”时间成了每个人的自我宇宙的计量器,每一段生命轨迹中细微的情感质量变化,都形成不同的时间宇宙。记忆、欲望、追寻,电影承载了某种时间的流逝、消耗和延展,也召唤观者以自我生命经验的共鸣(图8)。</p> <p> </p> <p>塔可夫斯基在《雕刻时光》中曾明确表示他的电影中没有象征和隐喻,水就是简单的水,雨就表达雨的经验。直觉,在塔可夫斯基的影片中显得尤其重要。《乡愁》的风景充满了作者的心灵感受,用一个患有强烈思乡症者的目光反映出来。对大自然及其不断变化的形态与气候的深切感受,从宽广的地平线到对一片树叶上的细微纹理的审视,都是艺术家在生活中寻找到的无限的美和魅力所在。塔可夫斯基似乎正沿着胡塞尔[12]所说的“回到事物本身”(zur焎k zu den Sachen selbst)的路在行走,而且,与柏格森[13]的直觉主义和法国新浪潮电影的“电影是每秒二十四格的真实”[14]不同的是,塔可夫斯基强调的却是一种现象学的意象,一种藉本质直观(Wesenschau)把经验还原为现象,强调意象活动和意向性(Intentionalit妕)体验,包含主体意识的意象性真实的现象学真实。</p> <p><br />  </p> <p>绵延:一种空间知觉</p> <p> </p> <p>德勒兹[15]曾指责现象学没有理解电影,将电影与自然感觉相对立,从而贬低了电影的重要性。[16]他把画面分为两种:一种是有机流动的状态,为画面—运动的状态;另一种是晶体状态,为画面—时间状态。德勒兹认为塔可夫斯基的电影属于画面—晶体一种,趋向于对纯时间的表现。</p> <p> </p> <p>纯时间指的就是柏格森所说的绵延(Duration),是一种强调主观意识的时空观念。柏格森在《时间与自由意志》里批评了康德的时空观,他认为康德在现象与本体之间划了一道无法越过的鸿沟,“康德设想一方面有物自体(Sachen an sich),一方面有纯粹的时间和纯粹的空间,物自体通过这种时间和空间被折射出来……时间和空间不在我们之外,也不在我们之内;内外的区别自身是时间与空间的作用……他把现象界连根带叶交给我们的悟性,而对本体界则不许我们问津。”[17]柏格森似乎在设法跨越康德设置的鸿沟,他认为“这道鸿沟也许不是他(康德)所设想的那样难以越过。”[18]柏格森试图通过“绵延”来统摄以上对象,试图使内在意识与物理时空统一起来。</p> <p> </p> <p>在康德的观念里,空间并非实在之物,空间是“外感所有一切现象之方式”[19],时间则是“内感之方式”,亦非实在之物。而时间与空间,“合而言之,为一切感性直观之纯粹方式,而使先天的综合命题之所以可能者。”[20]柏格森却坚信“空间是实在的东西”,并且说道:“康德远未动摇我们这个信仰。”[21]柏格森首先承认物质世界,认为物理学时间是可测量的,因此是纯一的。同样,空间是纯一的,因为空间是可度量的。他认为,绵延不等同于时间,“时间是纯一的,它的各个瞬间被串在一根线上,而绵延是多样性的,它的各个瞬间相互渗透。”他把时间理解为一种被人工重造出来的自我,以及种种简单的心理状态,这些状态可以彼此凑合再分开,而把绵延理解为一种内心状态,其先后各个阶段是独特无二的。柏格森认为时间有两种概念,他指出:“对时间确有两种可能的概念,一种是纯粹的,没有杂物在内,一种偷偷地引入了空间的观念。”这就是他所说的抽象的时间和具体的绵延,“真正绵延的各个瞬间是相互渗透的而不是并排置列的。”[22]</p> <p> </p> <p>柏格森认为时间和空间两者是不能相互还原的,他提出这样一个命题:如果能证明两者之一能还原为其中另一者,才能否定事物具有时间与空间这两种形式。“无论怎样,我们若不事先问明二者之一是否不能还原为其中之另一,则我们终不能承认纯一的东西具有两种形式,即时间与空间。”他否定了“那些企图把二者之一还原为另一的哲学家,由于他们为时间观念之明显的简单性所迷误,就认为他们能把绵延变为广度。”[23]</p> <p> </p> <p>可以如此理解:柏格森的绵延是时间、空间,加上其在身内意识组织渗透的过程。柏格森实际上假定了空间与时间的界限,把“空间”与“时间”定义在狭义的物理学范围内,他所说的空间指的是物理学空间,时间指的也正是物理学时间,这样的定义为他的“绵延”理论留出了位置。因此,我们可以认为柏格森的“空间”和康德的“空间”并非一个词语,因此,他的空间实在论和康德的空间非实在论也并非完全矛盾。尽管柏格森的思想不像康德一丝不苟,但这个被梅洛-庞蒂[24]称为“一个搞乱了哲学与文学的人”[25]还是为我们开启了另一扇重要的门——知觉的门。</p> <p> </p> <p>人的感觉和知觉是人向世界开放的第一个器官,也是世界向人进入的第一道关口。梅洛-庞蒂在《知觉现象学》里,分析了知觉世界的结构以后,阐述了我们感觉到的外部世界的性质、空间位置、深度和运动的具体经验,展开了我们所有的知觉经验的外部世界。<br /> 在梅洛—庞蒂看来,城市空间不仅仅是一个物体(客观实在),“巴黎的城市空间不是一个有千万种面貌的物体,不是知觉的总和,也不是所有知觉的规律。我在游览巴黎时得到的每一个鲜明的知觉——咖啡馆,人的脸,码头边的杨树,塞纳河的湾道,就如一个人在他的手势、步态和嗓音中表现出的同一种情绪——同样清楚地出现在巴黎的整个存在中,都表明巴黎的某种风格或某种意义。当我第一次到巴黎时,走出车站最初看到的大街,如同我最初听到的一个陌生人的话语,只不过是一种很模糊但已是独一无二的本质表现。”[26]空间存在于意识之中,而且任何空间都有联系着它的各部分思维支撑着。假如人在黑夜里失去器官知觉,便失去了空间深度。“黑夜不是在我面前的一个物体,它围绕着我,它通过我的器官进入我,它窒息我的回忆,它几乎抹去我的个人认知。我不再以我的知觉器官作为掩护,以便从那里看物体的轮廓在远处展现。黑夜没有轮廓,它接触我,它的统一性就是超自然的神秘统一性。但只要黑夜远处隐隐约约充满喊叫声和光线,它就能整个地活跃起来,它是一种没有平面、没有表面、没有它和我之间距离的一种深度。”[27]黑暗屏蔽了知觉,也因此屏蔽了空间,如同电影院中的黑暗,压平了真实空间的深度,而打开了电影空间与画面的深度。<br /> 梅洛-庞蒂以绘画中的“透视”来说明一个重要的道理,即艺术家在一个二维的平面上,做出了一个虚假的三维深度。他认为人们看见了深度,而深度并不是真实可见的,因为深度是从我们身体开始,到物体的距离来计算的。这个奥秘是一个虚假的奥秘,人们并非真实的看见了深度,即使看见了,也是另一种深度,是人的视觉本身遮蔽了一些东西,而又向人们敞开了一些东西。</p> <p> </p> <p>梅洛-庞蒂强调主体的重要,认为主体是一种既在知觉中,又被知觉到的主体,即知觉的中心。他批评了萨特和海德格尔的存在主义,超越了伯格森的空间实在论,对康德和胡塞尔著作中的某些康德主义的概念也进行了扬弃。《知觉现象学》认为哲学的第一个行动,应该是深入到先在的客观世界中去重新发现现象,重新唤醒知觉,并私下使其自身成为一种事实和一种知觉。</p> <p> </p> <p>空间、物质和时间,在建筑里会纠缠集结,穿越意识,融入一个单一的向度,融入存在的基本的物质性里。人们在这样的空间中能辨别出自己,此时,这种空间的尺度变成了我们存在的一个部分。建筑学是人类和外部世界之间的调和的一种艺术,知觉正是这种调和发生的媒介。建筑学是所有艺术形式中最能全面反映人类知觉的空间艺术,建筑学中引入现象学方法可以开辟出一种视野,确立一种观念和态度。正是在这个意义上,建筑现象学使建筑艺术走出单纯的社会—建筑师—使用者的研究方式,使建筑学成为一种主体间性(Intersubjektivit妕)的对话交流方式。</p> <p><br />  </p> <p>身体:一种建筑现象学</p> <p> </p> <p>作为艺术实践的建筑学与社会实践的建筑学有所不同,它们可以被认为是两种不同的建筑学。当代西方建筑学由于物质功能需求的减少而更多地倾向于艺术领域,因此,作为当代艺术理论重要基础的现象学在建筑学中终究有了合理地位,并且越来越多地为建筑师所接受。建筑师们认为与其他艺术形式相比,建筑更能全面的反映人类的知觉,体现现象学的意义。<br /> 帕拉斯玛(Juhani Palasmma)[28]在他的文章《建筑七感》(An Architecture of the Seven Senses)中,列举了人对建筑的七种知觉,完整的阐述了作为现象学的知觉在建筑学中的作用。帕拉斯玛认为,不同的建筑可以有不同的感觉特征,除了通常流行的“眼睛的建筑学”或者说“视觉建筑学”,还应该有一种肌肤的、触觉的建筑学,一种重新认识听觉、嗅觉和味觉的建筑学。柯布西耶的建筑明显倾向于视觉,相反的,始于门德尔松(Erich Mendelson)和汉斯·夏隆(Hans Scharoun)的表现主义建筑,则倾向于塑性和触觉,倾向于反对视觉主义的透视中心论。帕拉斯玛采用现象学的方法分析了建筑中人的各种感受,强调身体,即知觉主体经验的重要。帕拉斯玛研究建筑中的现象学问题,其现象学理论依据主要源自于法国哲学家梅洛-庞蒂和加斯东·巴士拉(Gaston Bachelard)。巴士拉晚年通过自己女儿(胡塞尔的门徒)了解到现象学,但他的现象学与现象学运动中严格意义的现象学哲学有所不同,尤其在意识中的直接被给与的内在直观方面,即直观所与方面很难和胡塞尔接近,在操作性概念结构的方法方面也与现象学有相互矛盾。巴士拉自己不希望把自己与胡塞尔的纯粹现象学联系起来,他反对“哲学沉思”,主张“现象技术”,他的哲学是一种“行动的哲学”,甚至是一种“唯物主义的现象学”[29]。可以认为,帕拉斯玛从巴士拉那里获得了比较直接的动力,在把现象学应用于建筑学领域方面做出了大胆的尝试。</p> <p> </p> <p>他说道:“眼睛是一种强调距离和间隔的器官,而触摸则强调亲近、私密和友爱的感受。我们这个年代,光变成纯粹定量的物质,窗户失去它作为开启和关闭、室内和室外、私密和公共、阴影和光明等等两个世界之间的介质的特征,窗户变成了纯粹是墙面上的一个缺口。因而失去了它本体论的意味。用路易斯·巴拉干(Luis Barragan)的观点来说,对大多数的当代住宅而言,把墙面上窗户的数量减少一半,也许会更令人愉快。同样,对大多数公共空间而言,把光线强度减小一半,也许更令人高兴。”[30]</p> <p> </p> <p>“手是一个复杂的器官,是一个三角地,来自四面八方的生命信息源源不断的在这里汇聚,汇聚成行为的河流。人的双手有它们自己的历史,有它们自己的文明。它们也因此显得特别美丽。雕塑家的手是认识世界和独立思考的器官,因此,手是雕塑家的眼睛。手可以阅读,阅读物体的肌理、重量、密度和温度。当我们握住门的把手就是和建筑握手。触觉感知把我们和时间及传统联系在一起。”[31]这正如康德所说:手是人外在的大脑。</p> <p> </p> <p>建筑学中,人的行动蕴藏着一个潜在的暗示,就像草地上的垫脚石是人脚的印痕和图像。当我们打开一扇门,身体的重量便遇到了门的重量,踩上台阶时腿便度量着踏步,人的手和门的把手相遇,整个身体倾斜着、戏剧性的穿过空间。“我们身体周围的物体反映出可能的行为”——柏格森在《物质与记忆》里这样说道。值得回味的建筑体验往往不仅仅是简单的视网膜的图像,建筑学的元素不仅是视觉单位和完形。当走进路易·康的萨尔克(salk)生物楼前巨大的室外空间时,一种不可抗拒的诱惑引领我们直接走向它那素混凝土墙面,去触摸那像丝绒般平滑温暖的表面。皮肤能准确的追踪有温度变化的空间,如树阴下凉爽的、生机勃勃的影子,阳光照射下温暖的光斑。</p> <p> </p> <p>阿尔瓦·阿尔托在他的建筑里,有意识的关注到所有的知觉,“家具的一个片断形成一个人日常生活的一部分,它不应当过于光滑耀眼,它也不应当不利于声音和声音的吸收,等等。与人接触的最为亲密的一个片断,如一只椅子,就不应当用那些导热性能太好的材料来制造。”[32]与纯粹的视觉美学相比,阿尔托更感兴趣于物品与使用者的身体相遇。</p> <p> </p> <p>阿尔托的建筑展现出肌肤与触觉的在场。他的建筑综合了错位、斜面、不规则形和多重节奏,以此来唤醒身体、肌肉和触觉的经验。他依*手工精心制作的表面纹理和细部,唤起了人们的触觉,创造了温暖亲切的氛围。阿尔托的建筑不是基于笛卡尔式的理想主义的视觉建筑学,而是基于感觉的真实;同样,也不是基于统一和完形,而是感觉的聚合物(图8-11)。阿尔托的建筑常常显得笨拙和未完成的样子,但它们却可以被理解为:真实的物质与空间在“肉身”(Flesh)中相遇——不是作为理想化的视觉构筑物。</p> <p> </p> <p>相反的是,在当代建筑中,我们很少看到像阿尔托这样专注于人类知觉的建筑师。今天的建筑师,更多地热衷于视觉图像的冲击和新技术的表现。生活世界的物质实体被虚拟现实所代替,虽然真实的“物质性”愈来愈陌生,但虚拟的“世界”却正在成为“另一种物化”。雷姆·库哈斯更多地显示出他社会学家的天才,他的技巧更多显示在社会学而不是建筑学领域;赫尔佐格是一个技术高明的试验家,他关注建筑自身,表现出对建筑与材料丰富实体感的偏爱,但这种物质主义并未能唤起人们的回忆,更多地是充满着如同博依斯[33](J. Beuys, 1921-1986)艺术中表现出的新奇躁动和陌生不安。因为缺失记忆,赫尔佐格便像个技术领航员,他未能进入我们的精神领域,他的建筑亦不属于现象学领域。而另外一类建筑师,如斯维尔·费恩、索托·莫拉、格兰·默科特、阿尔瓦罗·西扎、安藤忠雄等,也包括年迈的伍重,却能让我们不断地在其建筑中找到某些回忆和知觉的共鸣(图12)。</p> <p><br /> 结语:唤起失忆的空间</p> <p> </p> <p>今天的建筑患了失忆症,正在失去知觉,失去记忆,它们很少能够进入诗的领域,或能够唤醒世界潜意识的意像。当代建筑热衷于视觉冲击,缺少直觉和恍惚的话语,缺少一些悲情、伤感和回忆的情绪。建筑学应该再次追问它在物质性和实用性上的功能和存在,使之能触及人类深层意识,触及梦和情感——如同塔可夫斯基、帕拉斯玛和梅洛-庞蒂揭示的那样,使之成为艺术实践中不可或缺的风景。人类器官正在失去知觉的今天,“影像感知”越来越多地代替“真实感知”,“影像空间”更多地取代“真实空间”。艺术愈来愈多地依赖于复制,复制本身已变为一种艺术,正如同本雅明[34](Walter Benjamin)所说的,机器复制使艺术从仪式中解放出来成为另一种实践[35]。而复制的先天不足在于主体的缺席,亦如詹姆逊(Fredric Jameson)所认为:复制的核心是主体的丧失,即“主体之死”[36]。塔可夫斯基用他电影画面的本体论和现象学经验做出了回答,让我们察觉到艺术可以如此唤醒主体,唤起知觉和记忆,艺术作品更是人、观者与作品的对话。</p> <p> </p> <p>“回到事物本身”(zur焎k zu den Sachen selbst)是现象学家的第一个行动,也可以成为艺术家和建筑师创作的重要方法。当建筑学进入现象学的领域,我们便再次意识到当代建筑学中面临的三个困境:一为“历史之轻”;二为“知觉之弱”;三为“主体之死”。“历史之轻”关于时间与记忆,“知觉之弱”关于直觉与物质性, “主体之死”关于身体性。如果我们以现象学的方式追问,这三个问题便成为:在当代建筑中,作为人类世界历史感之体现的记忆是否存在以及如何存在?作为人类知觉之体现的建筑物质性是否存在以及如何呈现?以及作为主体的身体是否依然存在于建筑之中以及如何存在于建筑之中?这便是本文探讨的三个主题。</p> <p> </p> <p>建筑学的永恒使命是去创造能体现人类存在的物化隐喻,建构人类生存于斯的存在。正如阿尔多·罗西(Aldo Rossi)在《城市建筑学》(Architecture of City)中说道:“不同的时间和空间观念与我们的历史文化息息相关,因为我们生活在我们自己营建的地景之中,并且,无论在任何情况下都以之为参照”。[37]如果有一天在我们广褒大地之中,建筑师唤醒了人们的共同记忆——如同阿尔多·罗西所说的集体记忆,那么我们便找到了一条路,一条经由现象学通向刻有记忆印痕的未来之路。</p> <p> </p> <p>注释:<br /> [1] 施皮格伯格在《现象学运动》中,在定义现象学时提供了四种划分:最广义的现象学/广义的现象学/严格意义上的现象学/最严格意义上的现象学(《现象学运动》,41页)。根据中国学者倪梁康“略作改造”的后之解释,可以这样理解:施皮格伯格为现象学划分四个不同范围:1、最广义的现象学:符合现象学的公认标准,但主观上没有参加现象学运动的人。含布伦塔诺、斯通普夫等;2、广义的现象学:胡塞尔1913年设想和表述的方法意义上的现象学。含某一阶段的海德格尔、萨特,伽达默尔,某个时期的德里达;3、严格意义上的现象学:关注意识现象,尤为关注主观显现方式。含早期哥廷根学派、慕尼黑学派,舍勒、梅洛-庞蒂、古尔维奇等;4、最严格意义上的现象学:胡塞尔本人逐渐发展起来的现象学,“胡塞尔现象学”。本文使用的“现象学”,基本定义在上述第一种现象学上,即,最广义的现象学。<br /> [2] Van Den Berg, J. H. (1914- ), Phenomenological Approach to Psychiatry, Psychology of the Sickbed.(转引自Gaston Bachelard , The Poetics of Space. Translated by Maria Jolas. New York: Orion Press, 1964; Boston: Beacon Press, 1969.)J. H. van den Berg, Ph. D., M. D.1914年生于荷兰,1946年毕业于Utrech University,专攻精神医学——神经病学,博士论文谈的是关于精神病学自体移植方法及其在精神分裂症方面的运用。自1951年起,陆续担任Utrech University、Duquesne University和南非大学等的学校的客座教授,并于1975年起,在美国、加拿大和南非等地巡回演讲。<br /> [3] 塔可夫斯基(Andrei Tarkovsky,1932.4.4-1986.12.28),苏联著名导演、电影大师,代表作品有《伊万的童年》、《安德烈·鲁勃廖夫》、《镜子》、《潜行者》、《乡愁》等。<br /> [4] 《安德烈·鲁勃廖夫》(Andrei Rublev),塔可夫斯基1966年作品,阿纳托里·索洛尼岑主演,获得戛纳电影节国际影评联合会奖,片长205分钟。<br /> [5] 安德烈·鲁勃廖夫(Andrei Rublev,1360-1430),15世纪俄国东正教圣像派画家。<br /> [6] 安德烈·巴赞(Andre Bazin,1918-1948),法国电影理论家,主编《电影手册》,被誉为“新浪潮电影之父”,主要著作:《电影是什么》四卷。<br /> [7] 巴赞:《电影是什么》,99页,崔君衍译,中国电影出版社,1987。<br /> [8] 塔可夫斯基:《导演艺术讲义》。见《导演艺术讲义》,李宝强编译:《七部半--塔可夫斯基的电影世界》,323页,中国电影出版社,2002。<br /> [9] 《火车进站》,1895年,世界第一部公开放映的电影,片长半分钟。<br /> [10] 塔可夫斯基:《雕刻时光》(Sculpting in Time),译自Juhani Palasmma, Space and Image in Tarkovsky's Nostalgia: Notes as a Phenomenology of Architecture. Alberto P巖ez-G梞ez and Stephen Parcell, Chora 1 (Montreal: McGill-Queen's University Press, 1994).<br /> [11] 尤特凯维奇(Sergei Yutkevich):《论电影艺术》。<br /> [12] 胡塞尔(Edmund Husserl,1859-1938),德国哲学家,现象学运动的重要创始人之一,被认为是20世纪最重要的哲学家之一。主要著作《逻辑研究》、《纯粹现象学和现象学哲学的观念Ⅰ》、《生活世界现象学》以及生前未发表的《欧洲科学的危机与先验现象学》、《观念Ⅱ》等。<br /> [13] 柏格森(Henri Bergson,1859-1941),法国哲学家,直觉主义和生命哲学的代表人物之一。主要著作《论意识的直接材料》(即英文版《时间与自由意志》,1889)、《创造进化论》(1907)。<br /> [14] 法国新浪潮电影代表人物吕克·戈达尔(Jean-Luc Godard)提出的电影理论。<br /> [15] 吉尔·德勒兹(Gilles Deleuze,1925-1995),法国哲学家、文学评论家。主要著作《尼采与哲学》、《重复与差异》、《千座高原》等。<br /> [16] 德勒兹:《哲学与权利的谈判》,77页,商务印书馆,2000。<br /> [17] 柏格森:《时间与自由意志》,160页,商务印书馆,2002。<br /> [18] 柏格森:《时间与自由意志》,161页,商务印书馆,2002。<br /> [19] 康德:《纯粹理性批判》62页,商务印书馆,1997。<br /> [20] 康德:《纯粹理性批判》63页,商务印书馆,1997。<br /> [21] 柏格森:《时间与自由意志》,62页,商务印书馆,2002。<br /> [22] 柏格森:《时间与自由意志》,66页,商务印书馆,2002。<br /> [23] 柏格森:《时间与自由意志》,66页,商务印书馆,2002。<br /> [24] 梅洛-庞蒂(Maurice Merleau-Ponty,1908-1961),法国哲学家,被称为“法国最伟大的现象学家”,其主要著作为《知觉现象学》、《行为的结构》、《哲学赞词》、《眼与心》等。《知觉现象学》是法国第一部主题中标有“现象学”的系统研究著作。施皮格伯格在《现象学运动》中认为:在把现象学作为哲学这一点上,梅洛-庞蒂比大多数其他法国哲学家,包括萨特在内,都走得更远。<br /> [25] 梅洛-庞蒂:《完善中的柏格森》,见《哲学赞词》,172页,商务印书馆,2000。<br /> [26] 梅洛-庞蒂:《知觉现象学》(英文版名为:The Phenemeology of Perception,trans. By C. Smith),357页。<br /> [27] 梅洛-庞蒂:《知觉现象学》(英文版名为:The Phenemeology of Perception,trans. By C. Smith),360页。<br /> [28] 帕拉斯玛(Juhani Palasmma),芬兰建筑师、建筑理论家。帕拉斯玛主要研究建筑的现象学问题,其现象学理论依据主要源自于法国哲学家梅洛-庞蒂和加斯东·巴士拉(Gaston Bachelard,1884-1966)。<br /> [29] 赫伯特·施皮格伯格:《现象学运动》,56页,王炳文等译,商务印书馆,1995。<br /> [30] Juhani Palasmma, An Architecture of the Seven Senses. a+u, July 1994.<br /> [31] Juhani Palasmma, An Architecture of the Seven Senses. a+u, July 1994.<br /> [32] Alvar Aalto, Rationalism and Man, 1935.<br /> [33] 约瑟夫·博依斯(J. Beuys, 1921-1986),德国艺术家,激浪派艺术代表人之一。<br /> [34] 瓦尔特·本雅明(Walter Benjamin, 1892-1940),德国思想家,“西方马克思主义”美学的代表人物之一,被誉为欧洲真正的知识分子。<br /> [35] 沃尔特·本雅明:《机器复制时代的艺术》。见《经验与贫乏》,268页,百花文艺出版社,1999。这里的“仪式”向“实践”转化,指的是艺术的社会功能发生变化,它不再建立在礼仪膜拜的基础上,而是建立在“政治”的根基上。<br /> [36] 詹姆逊:《文化转向》,5页。詹姆逊所说“主体之死”指的是个性本身的终结,针对现代主义以个人、私人风格为创造的基础的结束而言。<br /> [37] Aldo Rossi, Architecture of City. Cambridge: MIT Press 1982</p> <p> </p> <p>参考文献<br /> 1. Alberto P巖ez-G梞ez and Stephen Parcell, Chora 1 (Montreal: McGill-Queen's University Press, 1994).<br /> 2. Juhani Palasmma, An Architecture of the Seven Senses (a+u, July 1994).<br /> 3. Juhani Palasmma, The Eyes of The Skin- Architecture and the Sense (London: Academy 1996).<br /> 4. Andrei Tarkovsky, Sculpting in Time (London: Bodley Head 1968).<br /> 5. Sigfried Giedion, Space,Time and Architecture (Cambridge, Mass: Harvard University Press 1997).<br /> 6. K. Michael Hays, Architecture Theory since 1968 (Cambridge, Mass: MIT Press 2000).<br /> 7. Henri Lefebvre, The Production of Space (Cambridge: Blackwell 1991).<br /> 8. Aldo Rossi, Architecture of City (Cambridge: MIT Press 1982).<br /> 9. Vittorio Gregotti, Inside Architecture (Cambridge: MIT Press 1996).<br /> 10. 柏格森:《时间与自由意志》,吴士栋译,商务印书馆,2002。<br /> 11. 康德:《纯粹理性批判》,蓝公武译,商务印书馆,1997。<br /> 12. 赫伯特·施皮格伯格:《现象学运动》,王炳文等译,商务印书馆,1995。<br /> 13. 伽达默尔:《现象学运动》,邓安庆译,载于:《伽达默尔集》,上海远东出版社,2003。<br /> 14. 梅洛-庞蒂:《知觉现象学》,姜志辉译,商务印书馆,2001。<br /> 15. 梅洛-庞蒂:《哲学赞词》,杨大春译,商务印书馆,2000。<br /> 16. 倪梁康编:《面对实事本身--现象学经典文选》,东方出版社,2000。<br /> 17. 安德烈·巴赞:《电影是什么?》,崔君衍译,中国电影出版社,1987。<br /> 18. 李宝强编译:《七部半--塔可夫斯基的电影世界》,中国电影出版社,2002。<br /> 19. 吉尔·德勒兹:《哲学与权利的谈判》,刘汉全译,商务印书馆,2000。<br /> 20. 詹姆逊:《文化转向》,胡亚敏等译,中国社会科学出版社,2000。</p></div></div></div> </div> <div class="field field-node-field-blog-tags field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-blog-tags field-type-entity-reference field-label-above"><h3 class="field__label">标签</h3><div class="field__items"><div class="field__item field__item--空间之觉-建筑现象"> <span class="field__item-wrapper"><a href="/drupal/taxonomy/term/85" hreflang="zh-hans">空间之觉 建筑现象</a></span> </div></div> </div> <div class="field field-node-field-category field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-category field-type-entity-reference field-label-hidden"><div class="field__items"><div class="field__item field__item--建筑"> <span class="field__item-wrapper"><a href="/drupal/architecture" hreflang="zh-hans">建筑</a></span> </div></div> </div> <section class="field field-node--field-blog-comments field-formatter-comment-default field-name-field-blog-comments field-type-comment field-label-above display-mode-threaded comment-bundle-comment comment-wrapper"> <a name="comments"></a></section> Thu, 18 Feb 2021 03:41:37 +0000 highflybird 179 at https://www.highflybird.com/drupal Logistic映射的LISP实现 https://www.highflybird.com/drupal/node/162 <span class="field field-name-title field-formatter-string field-type-string field-label-hidden">Logistic映射的LISP实现</span> <span class="field field-name-uid field-formatter-author field-type-entity-reference field-label-hidden"><span lang="" about="/drupal/user/1" typeof="schema:Person" property="schema:name" datatype="">highflybird</span></span> <span class="field field-name-created field-formatter-timestamp field-type-created field-label-hidden">周四, 02/04/2021 - 12:53</span> <div class="clearfix text-formatted field field-node--body field-formatter-text-default field-name-body field-type-text-with-summary field-label-hidden has-single"><div class="field__items"><div class="field__item"><div class="tex2jax_process"><p>关于Logistic映射,请参考集智百科词条:</p> <p> <a href="https://wiki.swarma.org/index.php/Logistic%E6%98%A0%E5%B0%84">Logistic映射</a></p> <p>这里讲得很详细。我摘抄几句:</p> <p>Logistic映射,又称单峰映象,是一个二次多项式映射(递归关系),经常作为典型范例来说明复杂的混沌现象是如何从非常简单的非线性动力学方程中产生的。</p> <p>生物学家罗伯特·梅 Robert May [1]在1976年的一篇论文中推广了这一映射,[2]它在一定程度上是一个时间离散的人口统计模型,类似于皮埃尔·弗朗索瓦·韦胡斯特 Pierre Francois Verhulst 首次提出的方程。 </p> <p>Logistic映射的数学表达式表示为:</p> <p> \[\displaystyle{x(t+1)=\mu x(t)(1-x(t))}\]</p> <p>美国物理学家费根鲍姆从中发现了费根鲍姆常数(第一常数),这是一个普适的常数,一个很重要的常数。</p> <p>其大小 \( \delta \approx 4.66920 16091 02990 67185 32038 20466 20161 72581 85577 47576 86327 45651 34300 4134.....\)</p> <script type="text/javascript" src="https://www.highflybird.com/drupal/core/assets/vendor/jquery/jquery.min.js"></script><script src="https://www.highflybird.com/drupal/libraries/colorbox/jquery.colorbox.js"></script><link href="http://www.highflybird.com/drupal/libraries/colorbox/example1/colorbox.css" media="screen" rel="stylesheet" /> <script> <!--//--><![CDATA[// ><!-- $(document).ready(function(){ $(".group1").colorbox({ rel: 'group1' ,transition:'fade', speed:500,maxWidth:'80%'}); }); //--><!]]> </script><p>我用AutoLISP简单实现了logistic映射,代码如下:</p> <div class="geshifilter"> <pre class="cadlisp geshifilter-cadlisp" style="font-family:monospace;"><span style="color: #6699CC; font-style: italic;">;;; Logistic混沌映射的LISP实现</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> Logistic <span style="color: #336699; font-weight: bold;">(</span>r x0 <span style="color: #66cc66; font-weight: bold;">/</span> i xn x<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> i <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> x x0<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">while</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">and</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;"><</span> i <span style="color: #FF9900;">50</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">not</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">equal</span> x <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> xn <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> r x <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">-</span> <span style="color: #FF9900;">1</span> x<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> 1e<span style="color: #66cc66; font-weight: bold;">-</span>8<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> x xn<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> i <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">1+</span> i<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">entmakeX</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> . <span style="color: #9933CC;">"POINT"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> <span style="color: #FF9900;">10</span> r x <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #6699CC; font-style: italic;">;;; 测试程序</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> c:tt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> r0 x0<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> r0 <span style="color: #FF9900;">0.0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">repeat</span> <span style="color: #FF9900;">401</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> x0 1e<span style="color: #66cc66; font-weight: bold;">-</span>8<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">repeat</span> <span style="color: #FF9900;">1001</span> <span style="color: #336699; font-weight: bold;">(</span>logistic r0 x0<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> x0 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> x0 <span style="color: #FF9900;">0.001</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> r0 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> r0 <span style="color: #FF9900;">0.01</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span>  </pre></div> <p>生成的图像大致如下:</p> <p> <a class="group1" data-rel="hi" href="http://www.highflybird.com/drupal/sites/default/files/2021-02/logistic_lisp.jpg" title="logistic by lisp.jpg"><br /> <img src="http://www.highflybird.com/drupal/sites/default/files/2021-02/logistic_lisp.jpg" width="800" /></a></p> <p>更精美的图形可以用C++编写,下面是核心代码:</p> <div class="geshifilter"> <pre class="cpp geshifilter-cpp" style="font-family:monospace;"><span style="color: #0000ff;">void</span> Fractal<span style="color: #008080;">::</span><span style="color: #007788;">Logistic</span><span style="color: #008000;">(</span><span style="color: #0000ff;">int</span> sx1,<span style="color: #0000ff;">int</span> sy1,<span style="color: #0000ff;">int</span> sx2,<span style="color: #0000ff;">int</span> sy2,CDC<span style="color: #000040;">*</span> pMemDC<span style="color: #008000;">)</span> <span style="color: #008000;">{</span> <span style="color: #0000ff;">double</span> x<span style="color: #008000;">(</span><span style="color: #0000dd;">0</span><span style="color: #008000;">)</span>,xx<span style="color: #008000;">(</span><span style="color: #0000dd;">0</span><span style="color: #008000;">)</span>,y<span style="color: #008000;">(</span><span style="color: #0000dd;">0</span><span style="color: #008000;">)</span>,yy<span style="color: #008000;">(</span><span style="color: #0000dd;">0</span><span style="color: #008000;">)</span>,cx<span style="color: #008000;">(</span><span style="color: #0000dd;">0</span><span style="color: #008000;">)</span>,cy<span style="color: #008000;">(</span><span style="color: #0000dd;">0</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span> m_isBusy <span style="color: #000080;">=</span> <span style="color: #0000ff;">true</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">for</span> <span style="color: #008000;">(</span><span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> sx1<span style="color: #008080;">;</span> i <span style="color: #000080;"><=</span> sx2<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span> <span style="color: #0000ff;">for</span><span style="color: #008000;">(</span><span style="color: #0000ff;">int</span> j <span style="color: #000080;">=</span> sy1<span style="color: #008080;">;</span>j <span style="color: #000080;"><=</span> sy2<span style="color: #008080;">;</span> j<span style="color: #000040;">++</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span> x <span style="color: #000080;">=</span> cxmin<span style="color: #000040;">+</span>i<span style="color: #000040;">*</span>dx<span style="color: #008080;">;</span> y <span style="color: #000080;">=</span> cymin<span style="color: #000040;">+</span>j<span style="color: #000040;">*</span>dy<span style="color: #008080;">;</span> xx <span style="color: #000080;">=</span> x<span style="color: #008080;">;</span> yy <span style="color: #000080;">=</span> x<span style="color: #000040;">*</span>y<span style="color: #000040;">*</span><span style="color: #008000;">(</span><span style="color: #0000dd;">1</span><span style="color: #000040;">-</span>y<span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">int</span> n <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">while</span><span style="color: #008000;">(</span> <span style="color: #0000dd;">fabs</span><span style="color: #008000;">(</span>y<span style="color: #000040;">-</span>yy<span style="color: #008000;">)</span> <span style="color: #000080;">></span> <span style="color:#800080;">1e-14</span> <span style="color: #000040;">&&</span> n <span style="color: #000080;"><</span> maxIter<span style="color: #008000;">)</span> <span style="color: #008000;">{</span> y <span style="color: #000080;">=</span> yy<span style="color: #008080;">;</span> yy <span style="color: #000080;">=</span> x<span style="color: #000040;">*</span>y<span style="color: #000040;">*</span><span style="color: #008000;">(</span><span style="color: #0000dd;">1</span><span style="color: #000040;">-</span>y<span style="color: #008000;">)</span><span style="color: #008080;">;</span> n<span style="color: #000040;">++</span><span style="color: #008080;">;</span> <span style="color: #008000;">}</span> <span style="color: #0000ff;">int</span> k <span style="color: #000080;">=</span> <span style="color: #008000;">(</span>y<span style="color: #000040;">-</span>cymin<span style="color: #008000;">)</span><span style="color: #000040;">/</span>dy<span style="color: #008080;">;</span> fPutPixel<span style="color: #008000;">(</span>i,k,n,H0,S0,L0,pMemDC,grad<span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #008000;">}</span> <span style="color: #008000;">}</span> <span style="color: #008000;">}</span>  </pre></div> <p>生成的图像:</p> <p> <a class="group1" href="http://www.highflybird.com/drupal/sites/default/files/2021-02/logistic.jpg" title="logistic by c++.jpg"><br /> <img src="http://www.highflybird.com/drupal/sites/default/files/2021-02/logistic.jpg" width="800" /></a> </p> </div></div></div> </div> <div class="field field-node-field-blog-tags field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-blog-tags field-type-entity-reference field-label-above"><h3 class="field__label">标签</h3><div class="field__items"><div class="field__item field__item--logistic-映射-lisp"> <span class="field__item-wrapper"><a href="/drupal/taxonomy/term/47" hreflang="zh-hans">Logistic 映射 LISP</a></span> </div></div> </div> <div class="field field-node-field-category field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-category field-type-entity-reference field-label-hidden"><div class="field__items"><div class="field__item field__item--编程"> <span class="field__item-wrapper"><a href="/drupal/programming" hreflang="zh-hans">编程</a></span> </div></div> </div> <section class="field field-node--field-blog-comments field-formatter-comment-default field-name-field-blog-comments field-type-comment field-label-above display-mode-threaded comment-bundle-comment comment-wrapper"> <a name="comments"></a></section> Thu, 04 Feb 2021 04:53:55 +0000 highflybird 162 at https://www.highflybird.com/drupal 利用DynamicWrapperX实现字符转换 https://www.highflybird.com/drupal/node/155 <span class="field field-name-title field-formatter-string field-type-string field-label-hidden">利用DynamicWrapperX实现字符转换</span> <span class="field field-name-uid field-formatter-author field-type-entity-reference field-label-hidden"><span lang="" about="/drupal/user/1" typeof="schema:Person" property="schema:name" datatype="">highflybird</span></span> <span class="field field-name-created field-formatter-timestamp field-type-created field-label-hidden">周二, 01/26/2021 - 01:30</span> <div class="clearfix text-formatted field field-node--body field-formatter-text-default field-name-body field-type-text-with-summary field-label-hidden has-single"><div class="field__items"><div class="field__item"><div class="tex2jax_process"><p>以下的代码需要DynamicWrapperX的支持。关于DynamicWrapperX的介绍,请看这个帖子:</p> <p><a href="http://bbs.mjtd.com/forum.php?mod=viewthread&tid=172340&highlight=dynamicwrapper">http://bbs.mjtd.com/forum.php?mod=viewthread&tid=172340&highlight=dynamicwrapper</a></p> <p><a href="http://bbs.mjtd.com/forum.php?mod=viewthread&tid=85724&highlight=dynamicwrapper">http://bbs.mjtd.com/forum.php?mod=viewthread&tid=85724&highlight=dynamicwrapper</a></p> <p>最新版本是2.2.0,其下载地址是:</p> <p><a href="http://dynwrapx.script-coding.com/dwx/pages/dynwrapx.php?lang=en">http://dynwrapx.script-coding.com/dwx/pages/dynwrapx.php?lang=en</a></p> <p>利用它,可以用LISP实现字符的转换(包括简体转繁体,GB2312转BIG5,GBK等等)。</p> <p>下面是其实现代码:</p> <div class="geshifilter"> <pre class="cadlisp geshifilter-cadlisp" style="font-family:monospace;"><span style="color: #6699CC; font-style: italic;">;|*************************************************************; 软件作者: Highflybird ; 软件用途: 通过DynamicWrapperX插件实现汉字简繁转换(字符集转换) ; 日期地点: 2016.05.14 深圳 ; 程序语言: AutoLISP,Visual LISP ; 版本号: Ver. 1.16.0514 ; ===============================================================; ================================================================ 本软件为开源软件: 以下是开源申明: ---------------------------------------------------------------- 本页面的软件遵照 GPL协议开放源代码,您可以自由传播和修改,在遵照 下面的约束条件的前提下:   一. 只要你在本开源软件的每一副本上明显和恰当地出版版权声明,保持 此许可证的声明和没有担保的声明完整无损,并和程序一起给每个其 他的程序接受者一份许可证的副本,你就可用任何媒体复制和发布你 收到的原始程序的源代码。你也可以为转让副本的实际行动收取一定 费用,但必须事先得到的同意。 二. 你可以修改本开源软件的一个或几个副本或程序的任何部分,以此形 成基于程序的作品。只要你同时满足下面的所有条件,你就可以按前 面第一款的要求复制和发布这一经过修改的程序或作品。 1.你必须在修改的文件中附有明确说明:你修改了这一文件及具体的修 改日期。 2.你必须使你发布或出版的作品(它包含程序的全部或一部分,或包含 由程序的全部或部分衍生的作品)允许第三方作为整体按许可证条款 免费使用。 3.如果修改的程序在运行时以交互方式读取命令,你必须使它在开始进 入常规的交互使用方式时打印或显示声明: 包括适当的版权声明和没 有担保的声明(或者你提供担保的声明);用户可以按此许可证条款 重新发布程序的说明;并告诉用户如何看到这一许可证的副本。(例 外的情况: 如果原始程序以交互方式工作,它并不打印这样的声明, 你的基于程序的作品也就不用打印声明。 三. 只要你遵循一、二条款规定,您就可以自由使用并传播本源代码,但 必须原封不动地保留原作者信息。 ================================================================ **************************************************************|;</span>   <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;; 说明:此程序仅在简体中文系统中测试通过,繁体中文可能需做改变</span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> C:test <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> DWX l1 l2 l3<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> DWX <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-create-object</span> <span style="color: #9933CC;">"DynamicWrapperX"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span>DWX:CharsetAPI DWX<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;(DWX:FileIO DWX)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> l1 '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #9933CC;">"CAD简繁转化"</span> DWX:GB2312<span style="color: #66cc66; font-weight: bold;">-></span>GBK DWX:GB2312<span style="color: #66cc66; font-weight: bold;">-></span>BIG5<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> l2 '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #9933CC;">"CAD簡繁轉化"</span> DWX:GBK<span style="color: #66cc66; font-weight: bold;">-></span>GB2312 DWX:GBK<span style="color: #66cc66; font-weight: bold;">-></span>BIG5<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> l3 '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #9933CC;">"CAD虏羉锣て"</span> DWX:BIG5<span style="color: #66cc66; font-weight: bold;">-></span>GBK DWX:BIG5<span style="color: #66cc66; font-weight: bold;">-></span>GB2312<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">foreach</span> n <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> l1 l2 l3<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strcat</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>Before: "</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> n<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">foreach</span> f <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cdr</span> n<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strcat</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>After "</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vl-princ-to-string</span> f<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #9933CC;">": "</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">apply</span> f <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> DWX <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> n<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;; (if (setq Name (Getfiled "请选择文件" "c:/" "" 8))</span> <span style="color: #6699CC; font-style: italic;">;;; (progn</span> <span style="color: #6699CC; font-style: italic;">;;; (setq text (DWX:ReadTxt DWX Name nil))</span> <span style="color: #6699CC; font-style: italic;">;;; (setq str1 (DWX:GB2312->BIG5 DWX text))</span> <span style="color: #6699CC; font-style: italic;">;;; (setq file (open "C:\\CharConvert-tw.lsp" "w"))</span> <span style="color: #6699CC; font-style: italic;">;;; (princ str1 file)</span> <span style="color: #6699CC; font-style: italic;">;;; (close file)</span> <span style="color: #6699CC; font-style: italic;">;;; (setq str2 (DWX:GB2312->GBK DWX text))</span> <span style="color: #6699CC; font-style: italic;">;;; (setq file (open "C:\\CharConvert-HK.lsp" "w"))</span> <span style="color: #6699CC; font-style: italic;">;;; (princ str2 file)</span> <span style="color: #6699CC; font-style: italic;">;;; (close file)</span> <span style="color: #6699CC; font-style: italic;">;;; )</span> <span style="color: #6699CC; font-style: italic;">;;; )</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-release-object</span> DWX<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;; GB2312->GBK 简体转繁体 </span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> DWX:GB2312<span style="color: #66cc66; font-weight: bold;">-></span>GBK <span style="color: #336699; font-weight: bold;">(</span>DWX STR<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span>DWX:LCMapString DWX STR <span style="color: #FF9900;">67108864</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;67108864, LCMAP_TRADITIONAL_CHINESE</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;; GBK->GB2312 繁体转简体 </span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> DWX:GBK<span style="color: #66cc66; font-weight: bold;">-></span>GB2312 <span style="color: #336699; font-weight: bold;">(</span>DWX STR <span style="color: #66cc66; font-weight: bold;">/</span> nlen pStr<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span>DWX:LCMapString DWX STR <span style="color: #FF9900;">33554432</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;33554432, LCMAP_SIMPLIFIED_CHINESE</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;; BIG5->GBK BIG5转繁体 </span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> DWX:BIG5<span style="color: #66cc66; font-weight: bold;">-></span>GBK <span style="color: #336699; font-weight: bold;">(</span>DWX str<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span>DWX:ANSI<span style="color: #66cc66; font-weight: bold;">-></span>Unicode DWX str <span style="color: #FF9900;">950</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;ANSI/OEM Traditional Chinese (Taiwan; Hong Kong SAR, PRC)</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;; GBK->BIG5 繁体转BIG5 </span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> DWX:GBK<span style="color: #66cc66; font-weight: bold;">-></span>BIG5 <span style="color: #336699; font-weight: bold;">(</span>DWX str<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span>DWX:Unicode<span style="color: #66cc66; font-weight: bold;">-></span>ANSI DWX str <span style="color: #FF9900;">950</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">; Chinese Traditional (Big5)</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;; GB2312->BIG5 简体转BIG5 </span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> DWX:GB2312<span style="color: #66cc66; font-weight: bold;">-></span>BIG5 <span style="color: #336699; font-weight: bold;">(</span>DWX STR<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span>DWX:GBK<span style="color: #66cc66; font-weight: bold;">-></span>BIG5 DWX <span style="color: #336699; font-weight: bold;">(</span>DWX:GB2312<span style="color: #66cc66; font-weight: bold;">-></span>GBK DWX STR<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;; BIG5->GB2312 BIG5转简体 </span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> DWX:BIG5<span style="color: #66cc66; font-weight: bold;">-></span>GB2312 <span style="color: #336699; font-weight: bold;">(</span>DWX STR<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span>DWX:GBK<span style="color: #66cc66; font-weight: bold;">-></span>GB2312 DWX <span style="color: #336699; font-weight: bold;">(</span>DWX:BIG5<span style="color: #66cc66; font-weight: bold;">-></span>GBK DWX STR<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span>     <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;; JPN->GBK 日文转繁体 </span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> DWX:JPN<span style="color: #66cc66; font-weight: bold;">-></span>GBK <span style="color: #336699; font-weight: bold;">(</span>DWX str<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span>DWX:ANSI<span style="color: #66cc66; font-weight: bold;">-></span>Unicode DWX str <span style="color: #FF9900;">932</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;; GBK->JPN 繁体转日文 </span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> DWX:GBK<span style="color: #66cc66; font-weight: bold;">-></span>JPN <span style="color: #336699; font-weight: bold;">(</span>DWX str<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span>DWX:Unicode<span style="color: #66cc66; font-weight: bold;">-></span>ANSI DWX str <span style="color: #FF9900;">932</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;; For a locale specified by identifier,maps an input character</span> <span style="color: #6699CC; font-style: italic;">;;; string to another using a specified transformation, or </span> <span style="color: #6699CC; font-style: italic;">;;; generates a sort key for the input string. </span> <span style="color: #6699CC; font-style: italic;">;;; 1024 -- LOCALE_USER_DEFAULT </span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> DWX:LCMapString <span style="color: #336699; font-weight: bold;">(</span>DWX STR MapFlags <span style="color: #66cc66; font-weight: bold;">/</span> nlen pStr<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> nLen <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'LCMapStringW <span style="color: #FF9900;">1024</span> MapFlags str <span style="color: #66cc66; font-weight: bold;">-</span><span style="color: #FF9900;">1</span> <span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pStr <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'memAlloc <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> nLen nLen <span style="color: #FF9900;">2</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">1</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> nLen <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'LCMapStringW <span style="color: #FF9900;">1024</span> MapFlags str <span style="color: #66cc66; font-weight: bold;">-</span><span style="color: #FF9900;">1</span> pStr nLen<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> str <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'StrGet pStr <span style="color: #9933CC;">"w"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'MemFree pStr<span style="color: #336699; font-weight: bold;">)</span> str <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;; ANSI->Unicode 指定代码页转换为Unicode </span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> DWX:ANSI<span style="color: #66cc66; font-weight: bold;">-></span>Unicode <span style="color: #336699; font-weight: bold;">(</span>DWX STR Code <span style="color: #66cc66; font-weight: bold;">/</span> nLen pStr<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> nLen <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'MultiByteToWideChar Code <span style="color: #FF9900;">0</span> str <span style="color: #66cc66; font-weight: bold;">-</span><span style="color: #FF9900;">1</span> <span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pStr <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'memAlloc <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> nLen nLen <span style="color: #FF9900;">2</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">1</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> nLen <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'MultiByteToWideChar Code <span style="color: #FF9900;">0</span> str <span style="color: #66cc66; font-weight: bold;">-</span><span style="color: #FF9900;">1</span> pStr nLen<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> str <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'StrGet pStr <span style="color: #9933CC;">"w"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'MemFree pStr<span style="color: #336699; font-weight: bold;">)</span> str <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;; Unicode->ANSI Unicode转换为指定代码页 </span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> DWX:Unicode<span style="color: #66cc66; font-weight: bold;">-></span>ANSI <span style="color: #336699; font-weight: bold;">(</span>DWX STR Code <span style="color: #66cc66; font-weight: bold;">/</span> nLen pStr<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> nLen <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'WideCharToMultiByte Code <span style="color: #FF9900;">0</span> str <span style="color: #66cc66; font-weight: bold;">-</span><span style="color: #FF9900;">1</span> <span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pStr <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'memAlloc <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">1+</span> nLen<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">1</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> nLen <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'WideCharToMultiByte Code <span style="color: #FF9900;">0</span> str <span style="color: #66cc66; font-weight: bold;">-</span><span style="color: #FF9900;">1</span> pStr nLen <span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> str <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'StrGet pStr <span style="color: #9933CC;">"s"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'MemFree pStr<span style="color: #336699; font-weight: bold;">)</span> str <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;; 注册字符集转换的API </span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> DWX:CharSetAPI <span style="color: #336699; font-weight: bold;">(</span>DWX<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"Kernel32"</span> <span style="color: #9933CC;">"MultiByteToWideChar"</span> <span style="color: #9933CC;">"i=llslpl"</span> <span style="color: #9933CC;">"r=l"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"Kernel32"</span> <span style="color: #9933CC;">"WideCharToMultiByte"</span> <span style="color: #9933CC;">"i=llwlplpp"</span> <span style="color: #9933CC;">"r=l"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"Kernel32"</span> <span style="color: #9933CC;">"LCMapStringA"</span> <span style="color: #9933CC;">"i=llslpl"</span> <span style="color: #9933CC;">"r=l"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"Kernel32"</span> <span style="color: #9933CC;">"LCMapStringW"</span> <span style="color: #9933CC;">"i=llwlpl"</span> <span style="color: #9933CC;">"r=l"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"Kernel32"</span> <span style="color: #9933CC;">"lstrlen"</span> <span style="color: #9933CC;">"i=p"</span> <span style="color: #9933CC;">"r=l"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vl-load-com</span><span style="color: #336699; font-weight: bold;">)</span></pre></div> <p> </p> </div></div></div> </div> <div class="field field-node-field-category field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-category field-type-entity-reference field-label-hidden"><div class="field__items"><div class="field__item field__item--编程"> <span class="field__item-wrapper"><a href="/drupal/programming" hreflang="zh-hans">编程</a></span> </div></div> </div> <section class="field field-node--field-blog-comments field-formatter-comment-default field-name-field-blog-comments field-type-comment field-label-above display-mode-threaded comment-bundle-comment comment-wrapper"> <a name="comments"></a></section> Mon, 25 Jan 2021 17:30:53 +0000 highflybird 155 at https://www.highflybird.com/drupal 用Javascript画图 https://www.highflybird.com/drupal/node/154 <span class="field field-name-title field-formatter-string field-type-string field-label-hidden">用Javascript画图</span> <span class="field field-name-uid field-formatter-author field-type-entity-reference field-label-hidden"><span lang="" about="/drupal/user/1" typeof="schema:Person" property="schema:name" datatype="">highflybird</span></span> <span class="field field-name-created field-formatter-timestamp field-type-created field-label-hidden">周二, 01/26/2021 - 00:35</span> <div class="clearfix text-formatted field field-node--body field-formatter-text-default field-name-body field-type-text-with-summary field-label-hidden has-single"><div class="field__items"><div class="field__item"><div class="tex2jax_process"><meta charset="UTF-8" /> <p><canvas height="400" id="myc" style="border:1px solid black" width="800"></canvas></p> <title></title> <script> <!--//--><![CDATA[// ><!-- //x,y是初始点 //length初始树枝长度 //ratio 树枝长度与比例 //n 迭代次数 var n=0; function drawTree(ctx,x,y,length,ratio) { var cross={}; var value=[]; cross.x=x; cross.y=y-length; cross.arc=Math.PI/2; value.push(cross); growBranch(ctx,value,length*ratio,ratio); } function growBranch(ctx,value,bralen,ratio) { n=n+1; if(n==15) return; var value1=[]; value.forEach(function(item,index) { var arc1=item.arc+(Math.PI*4)/(3*2); var arc2=item.arc-(Math.PI*4)/(3*2); //分支1 var bx=Math.cos(arc1)*bralen; var by=Math.sin(arc1)*bralen; ctx.moveTo(item.x,item.y); ctx.lineTo(item.x+bx,item.y+by); var cross={}; cross.x=item.x+bx; cross.y=item.y+by; cross.arc=arc1; value1.push(cross) //分支2 var bx1=Math.cos(arc2)*bralen; var by1=Math.sin(arc2)*bralen; ctx.moveTo(item.x,item.y); ctx.lineTo(item.x+bx1,item.y+by1); var cross1={}; cross1.x=item.x+bx1; cross1.y=item.y+by1; cross1.arc=arc2; value1.push(cross1); }); ctx.stroke(); growBranch(ctx,value1,bralen*ratio,ratio); } function beginDraw() { var canvas=document.getElementById('myc'); var ctx=canvas.getContext('2d'); ctx.fillStyle='#000'; ctx.fillRect(0,0,800,400); ctx.strokeStyle='rgb(46,139,87)'; //ctx.strokeStyle='#fff'; drawTree(ctx,400,500,200,0.7); ctx.stroke(); var btn = document.getElementById("button"); btn.setAttribute("disabled", true); } window.onload = function() { var btn = document.getElementById("button"); //btn.addEventListener('click',function() {alert('你点击了按钮哦!')},false); btn.addEventListener('click', function (){beginDraw()},false); } //--><!]]> </script> <p><input id="button" type="button" value="点我见证奇迹" /></p> </div></div></div> </div> <div class="field field-node-field-category field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-category field-type-entity-reference field-label-hidden"><div class="field__items"><div class="field__item field__item--编程"> <span class="field__item-wrapper"><a href="/drupal/programming" hreflang="zh-hans">编程</a></span> </div></div> </div> <section class="field field-node--field-blog-comments field-formatter-comment-default field-name-field-blog-comments field-type-comment field-label-above display-mode-threaded comment-bundle-comment comment-wrapper"> <a name="comments"></a></section> Mon, 25 Jan 2021 16:35:06 +0000 highflybird 154 at https://www.highflybird.com/drupal 垃圾文件清理工具 https://www.highflybird.com/drupal/node/150 <span class="field field-name-title field-formatter-string field-type-string field-label-hidden">垃圾文件清理工具</span> <span class="field field-name-uid field-formatter-author field-type-entity-reference field-label-hidden"><span lang="" about="/drupal/user/1" typeof="schema:Person" property="schema:name" datatype="">highflybird</span></span> <span class="field field-name-created field-formatter-timestamp field-type-created field-label-hidden">周日, 01/24/2021 - 11:56</span> <div class="clearfix text-formatted field field-node--body field-formatter-text-default field-name-body field-type-text-with-summary field-label-hidden has-single"><div class="field__items"><div class="field__item"><div class="tex2jax_process"><p>在工作中,我们需要清理一些在程序过程中产生的垃圾或者无需保留文件,但是因为不知情或者经常忘记的缘故,这些文件便积累起来,分布在各个目录中,难于查找和删除。特别是对于CAD作图的人来说,有时候形成一些.dwl, .plt, .err, .log, .ac$, .tmp等之类的文件,长期以来,既不美观,又浪费空间,的确有必要清理一下。而且下面这个程序可以帮你达到目的。网上有这样类似的程序,但可能比较庞杂,不会像这样针对特别目的。</p> <p>程序截图:</p> <p><a href="https://www.highflybird.com/blog/wp-content/uploads/2014/08/vb-cadcleaner.jpg"><img alt="vb-cadcleaner" height="239" loading="lazy" src="https://www.highflybird.com/blog/wp-content/uploads/2014/08/vb-cadcleaner-300x239.jpg" width="300" /></a></p> <p><a href="https://www.highflybird.com/blog/wp-content/uploads/2014/08/CADCleaner.zip">CADCleaner</a></p> <p>很久之前我就写了这个程序,开始时是用VLISP程序写的,后来我在学习VB的过程中,又把程序再次写了一遍,最后我用VC++重写。所以这个程序有三种版本的。这里我先发布VB语言的。</p> <p>关于这个程序的源码我就不发布了,附件仅仅包含程序。这里贴出一段关键代码,就是用API 查找特定文件的代码:</p> <div class="geshifilter"> <pre class="vb geshifilter-vb" style="font-family:monospace;"><span style="color: #008000;">'**********************************************************************************************************************</span> <span style="color: #008000;">'查找函数</span> <span style="color: #E56717; font-weight: bold;">Public</span> <span style="color: #E56717; font-weight: bold;">Function</span> FindFilesAPI(path <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span>, SearchStr <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Variant</span>, FileCount <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Long</span>, DirCount <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Long</span>) <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Double</span> <span style="color: #151B8D; font-weight: bold;">Dim</span> FileName <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span> <span style="color: #008000;">'文件名</span> <span style="color: #151B8D; font-weight: bold;">Dim</span> Extension <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span> <span style="color: #008000;">'文件后缀</span> <span style="color: #151B8D; font-weight: bold;">Dim</span> DirName <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span> <span style="color: #008000;">'子目录名</span> <span style="color: #151B8D; font-weight: bold;">Dim</span> dirNames() <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span> <span style="color: #008000;">'目录数组</span> <span style="color: #151B8D; font-weight: bold;">Dim</span> nDir <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Long</span> <span style="color: #008000;">'当前路径的目录数</span> <span style="color: #151B8D; font-weight: bold;">Dim</span> i <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Long</span> <span style="color: #008000;">'循环计数器变量</span> <span style="color: #151B8D; font-weight: bold;">Dim</span> hSearch <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Long</span> <span style="color: #008000;">'搜索句柄变量</span> <span style="color: #151B8D; font-weight: bold;">Dim</span> WFD <span style="color: #151B8D; font-weight: bold;">As</span> WIN32_FIND_DATA <span style="color: #151B8D; font-weight: bold;">Dim</span> Cont <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Long</span>   <span style="color: #8D38C9; font-weight: bold;">If</span> Right(path, 1) <> chr(92) <span style="color: #8D38C9; font-weight: bold;">Then</span> path = path & chr(92) <span style="color: #008000;">'搜索子目录</span> nDir = 0 <span style="color: #151B8D; font-weight: bold;">ReDim</span> dirNames(nDir) Cont = <span style="color: #00C2FF; font-weight: bold;">True</span> hSearch = FindFirstFile(path & <span style="color: #800000;">"*"</span>, WFD) <span style="color: #8D38C9; font-weight: bold;">If</span> hSearch <> INVALID_HANDLE_VALUE <span style="color: #8D38C9; font-weight: bold;">Then</span> <span style="color: #8D38C9; font-weight: bold;">Do</span> <span style="color: #8D38C9; font-weight: bold;">While</span> Cont FileName = StripNulls(WFD.cFileName) <span style="color: #8D38C9; font-weight: bold;">If</span> (FileName <> <span style="color: #800000;">"."</span>) <span style="color: #8D38C9; font-weight: bold;">And</span> (FileName <> <span style="color: #800000;">".."</span>) <span style="color: #8D38C9; font-weight: bold;">Then</span> <span style="color: #008000;">'遍历目录并累计文件总数</span> <span style="color: #8D38C9; font-weight: bold;">If</span> GetFileAttributes(path & FileName) <span style="color: #8D38C9; font-weight: bold;">And</span> FILE_ATTRIBUTE_DIRECTORY <span style="color: #8D38C9; font-weight: bold;">Then</span> dirNames(nDir) = FileName DirCount = DirCount + 1 nDir = nDir + 1 <span style="color: #151B8D; font-weight: bold;">ReDim</span> <span style="color: #151B8D; font-weight: bold;">Preserve</span> dirNames(nDir) <span style="color: #8D38C9; font-weight: bold;">Else</span> <span style="color: #8D38C9; font-weight: bold;">If</span> isCheckAll <span style="color: #8D38C9; font-weight: bold;">Or</span> UserForm1.ZERO.Value <span style="color: #8D38C9; font-weight: bold;">And</span> WFD.nFileSizeLow = 0 <span style="color: #8D38C9; font-weight: bold;">Then</span> <span style="color: #8D38C9; font-weight: bold;">If</span> isCheckAll <span style="color: #8D38C9; font-weight: bold;">Then</span> FindFilesAPI = FindFilesAPI + (WFD.nFileSizeHigh * MAXDWORD) + WFD.nFileSizeLow <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span> FileCount = FileCount + 1 UserForm1.List1.AddItem path & FileName <span style="color: #8D38C9; font-weight: bold;">Else</span> Extension = Mid(FileName, InStrRev(FileName, <span style="color: #800000;">"."</span>) + 1) <span style="color: #8D38C9; font-weight: bold;">If</span> CheckType(Extension, SearchStr) <span style="color: #8D38C9; font-weight: bold;">Then</span> FindFilesAPI = FindFilesAPI + (WFD.nFileSizeHigh * MAXDWORD) + WFD.nFileSizeLow FileCount = FileCount + 1 UserForm1.List1.AddItem path & FileName SendMessage LHwnd, WM_VSCROLL, SB_BOTTOM, 0& <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span> <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span> <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span> <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span> Cont = FindNextFile(hSearch, WFD) <span style="color: #008000;">'获取下一个文件或者文件夹</span> <span style="color: #8D38C9; font-weight: bold;">Loop</span> Cont = FindClose(hSearch) <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span> <span style="color: #008000;">'如果子目录存在则遍历之</span> <span style="color: #8D38C9; font-weight: bold;">If</span> nDir > 0 <span style="color: #8D38C9; font-weight: bold;">And</span> UserForm1.INC.Value <span style="color: #8D38C9; font-weight: bold;">Then</span> <span style="color: #8D38C9; font-weight: bold;">For</span> i = 0 <span style="color: #8D38C9; font-weight: bold;">To</span> nDir - 1 FindFilesAPI = FindFilesAPI + FindFilesAPI(path & dirNames(i) & chr(92), SearchStr, FileCount, DirCount) <span style="color: #8D38C9; font-weight: bold;">Next</span> i <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span> <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span></pre></div> <p>VC版本的:</p> <div class="geshifilter"> <pre class="cpp geshifilter-cpp" style="font-family:monospace;"><span style="color: #0000ff;">int</span> CCADCleanerDlg<span style="color: #008080;">::</span><span style="color: #007788;">Search</span><span style="color: #008000;">(</span>CString PathName<span style="color: #008000;">)</span> <span style="color: #008000;">{</span> CString FileName<span style="color: #008080;">;</span> HANDLE hScan<span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span> WIN32_FIND_DATAW FindFileData<span style="color: #008080;">;</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">(</span>PathName.<span style="color: #007788;">Right</span><span style="color: #008000;">(</span><span style="color: #0000dd;">1</span><span style="color: #008000;">)</span> <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #008000;">(</span>chr<span style="color: #008000;">(</span><span style="color: #0000dd;">92</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span> hScan <span style="color: #000080;">=</span> FindFirstFile<span style="color: #008000;">(</span>PathName <span style="color: #000040;">+</span>_T<span style="color: #008000;">(</span><span style="color: #FF0000;">"*"</span><span style="color: #008000;">)</span>,<span style="color: #000040;">&</span>FindFileData<span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #008000;">}</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">{</span> hScan <span style="color: #000080;">=</span> FindFirstFile<span style="color: #008000;">(</span>PathName <span style="color: #000040;">+</span>_T<span style="color: #008000;">(</span><span style="color: #FF0000;">"*"</span><span style="color: #008000;">)</span>,<span style="color: #000040;">&</span>FindFileData<span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #008000;">}</span>   <span style="color: #0000ff;">if</span> <span style="color: #008000;">(</span> hScan <span style="color: #000040;">!</span><span style="color: #000080;">=</span> INVALID_HANDLE_VALUE<span style="color: #008000;">)</span> <span style="color: #008000;">{</span> BOOL cont <span style="color: #000080;">=</span> TRUE<span style="color: #008080;">;</span> <span style="color: #0000ff;">while</span> <span style="color: #008000;">(</span>cont<span style="color: #008000;">)</span> <span style="color: #008000;">{</span> FileName <span style="color: #000080;">=</span> FindFileData.<span style="color: #007788;">cFileName</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">(</span>FileName<span style="color: #000040;">!</span><span style="color: #000080;">=</span>_T<span style="color: #008000;">(</span><span style="color: #FF0000;">"."</span><span style="color: #008000;">)</span> <span style="color: #000040;">&&</span> FileName<span style="color: #000040;">!</span><span style="color: #000080;">=</span>_T<span style="color: #008000;">(</span><span style="color: #FF0000;">".."</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">(</span>FindFileData.<span style="color: #007788;">dwFileAttributes</span> <span style="color: #000040;">&</span> FILE_ATTRIBUTE_DIRECTORY<span style="color: #008000;">)</span> <span style="color: #008000;">{</span> DirCount<span style="color: #000040;">++</span><span style="color: #008080;">;</span> Search<span style="color: #008000;">(</span>PathName<span style="color: #000040;">+</span>FileName<span style="color: #000040;">+</span>chr<span style="color: #008000;">(</span><span style="color: #0000dd;">92</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #008000;">}</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">{</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">(</span>Check<span style="color: #008000;">(</span>FileName,FindFileData.<span style="color: #007788;">nFileSizeLow</span>,FindFileData.<span style="color: #007788;">nFileSizeHigh</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span> <span style="color: #666666;">//m_strInfo = (PathName+FileName);</span> m_list.<span style="color: #007788;">AddString</span><span style="color: #008000;">(</span>PathName<span style="color: #000040;">+</span>FileName<span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #666666;">//m_Info.SetWindowText(m_strInfo);</span> <span style="color: #666666;">//m_list.SendMessage(LB_ADDSTRING,NULL,(LPARAM)(FileName.GetBuffer()));</span> <span style="color: #666666;">//SendMessage(m_listWnd,LB_ADDSTRING,NULL,(LPARAM)(FileName.GetBuffer()));</span> <span style="color: #666666;">//m_list.SendMessage(WM_VSCROLL,SB_BOTTOM,NULL);</span> FileCount<span style="color: #000040;">++</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">(</span>FindFileData.<span style="color: #007788;">nFileSizeHigh</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span> TotalSize <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color: #008000;">(</span>FindFileData.<span style="color: #007788;">nFileSizeLow</span> <span style="color: #000040;">+</span> FindFileData.<span style="color: #007788;">nFileSizeHigh</span> <span style="color: #000040;">*</span> FOUR_GB<span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #008000;">}</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">{</span> TotalSize <span style="color: #000040;">+</span><span style="color: #000080;">=</span> FindFileData.<span style="color: #007788;">nFileSizeLow</span><span style="color: #008080;">;</span> <span style="color: #008000;">}</span> <span style="color: #008000;">}</span> <span style="color: #008000;">}</span> <span style="color: #008000;">}</span> cont <span style="color: #000080;">=</span> FindNextFile<span style="color: #008000;">(</span>hScan,<span style="color: #000040;">&</span>FindFileData<span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #008000;">}</span> FindClose<span style="color: #008000;">(</span>hScan<span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">return</span> TRUE<span style="color: #008080;">;</span> <span style="color: #008000;">}</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">{</span> <span style="color: #0000ff;">return</span> ERROR<span style="color: #008080;">;</span> <span style="color: #008000;">}</span> <span style="color: #008000;">}</span></pre></div> <p>截图:<br /> <a href="https://www.highflybird.com/blog/wp-content/uploads/2014/08/cadcleanerVC.jpg"><img alt="cadcleaner(VC)" height="234" loading="lazy" src="https://www.highflybird.com/blog/wp-content/uploads/2014/08/cadcleanerVC-300x234.jpg" width="300" /></a><br /> <a href="https://www.highflybird.com/blog/wp-content/uploads/2014/08/CADCleanerVC.zip">CADCleaner(VC)</a><br /> 当然是用C语言编写的快些了。</p> </div></div></div> </div> <div class="field field-node-field-blog-tags field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-blog-tags field-type-entity-reference field-label-above"><h3 class="field__label">标签</h3><div class="field__items"><div class="field__item field__item--垃圾文件-清理-"> <span class="field__item-wrapper"><a href="/drupal/taxonomy/term/45" hreflang="zh-hans">垃圾文件 清理 </a></span> </div></div> </div> <div class="field field-node-field-category field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-category field-type-entity-reference field-label-hidden"><div class="field__items"><div class="field__item field__item--编程"> <span class="field__item-wrapper"><a href="/drupal/programming" hreflang="zh-hans">编程</a></span> </div></div> </div> <section class="field field-node--field-blog-comments field-formatter-comment-default field-name-field-blog-comments field-type-comment field-label-above display-mode-threaded comment-bundle-comment comment-wrapper"> <a name="comments"></a></section> Sun, 24 Jan 2021 03:56:16 +0000 highflybird 150 at https://www.highflybird.com/drupal 简体繁体转换 https://www.highflybird.com/drupal/node/149 <span class="field field-name-title field-formatter-string field-type-string field-label-hidden">简体繁体转换</span> <span class="field field-name-uid field-formatter-author field-type-entity-reference field-label-hidden"><span lang="" about="/drupal/user/1" typeof="schema:Person" property="schema:name" datatype="">highflybird</span></span> <span class="field field-name-created field-formatter-timestamp field-type-created field-label-hidden">周日, 01/24/2021 - 11:49</span> <div class="clearfix text-formatted field field-node--body field-formatter-text-default field-name-body field-type-text-with-summary field-label-hidden has-single"><div class="field__items"><div class="field__item"><div class="tex2jax_process"><p>简体字和繁体字的互相转化程序,可用于CAD的文字处理。</p> <p>以下是其实现代码:</p> </p> <div class="geshifilter"> <pre class="cadlisp geshifilter-cadlisp" style="font-family:monospace;"><span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;; 說明:此程序用于繁體字和簡體字的相互轉化,可以用于AutoCAD 的</span> <span style="color: #6699CC; font-style: italic;">;;; 字符。實際上簡體字和繁體字并不是一一對應的,有時候可能</span> <span style="color: #6699CC; font-style: italic;">;;; 一個簡體字對應多個繁體字,而繁體字一般來說只對應一個簡</span> <span style="color: #6699CC; font-style: italic;">;;; 體字。</span> <span style="color: #6699CC; font-style: italic;">;;; 程序中GB 碼是指的的中國大陸的簡體中文,GBK 碼是指的的香</span> <span style="color: #6699CC; font-style: italic;">;;; 港的繁體中文,BIG5是臺灣的繁體中文。如果應用于CAD 圖形</span> <span style="color: #6699CC; font-style: italic;">;;; 轉換,文字中出現問號或者亂碼,可能是由于沒有相應字體的</span> <span style="color: #6699CC; font-style: italic;">;;; 支持,請更換文字樣式。譬如:ChineseSet.shx,gbcbig.shx.</span> <span style="color: #6699CC; font-style: italic;">;;; 作者:Highflybird</span> <span style="color: #6699CC; font-style: italic;">;;; 日期:2013.01.23</span> <span style="color: #6699CC; font-style: italic;">;;; 修改:2013.04.20</span> <span style="color: #6699CC; font-style: italic;">;;; 地點:中國 深圳</span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;; 開源軟件,轉載請注明</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;; 首先確保你做了如下工作:(在winxp以上版本,可能需要管理員權限)</span> <span style="color: #6699CC; font-style: italic;">;;; 此函數為是否注冊了插件的檢查</span> <span style="color: #6699CC; font-style: italic;">;;; 用vlax-create-object 創建一個實例。用vlax-invoke調用其方法.</span> <span style="color: #6699CC; font-style: italic;">;;; 方法有: GB_GBK,GBK_GB,GB_BIG5,BIG5_GB,GBK_BIG5,BIG5_GBK等.</span> <span style="color: #6699CC; font-style: italic;">;;; 其功能顧名思義,如:GB_GBK就是把GB簡體轉化為GBK繁體。</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> Register <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> obj<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vl-load-com</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> obj <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-create-object</span> <span style="color: #9933CC;">"CharConverter.Converter"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-release-object</span> obj<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strlen</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">VL-PRINC-TO-STRING</span> <span style="color: #66cc66; font-weight: bold;">+</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">19</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">startapp</span> <span style="color: #9933CC;">"regsvr32 /s "</span>F:XCharConverter.dll<span style="color: #9933CC;">""</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;把這里面的路徑替換成自己的路徑</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">startapp</span> <span style="color: #9933CC;">"regsvr32 /s "</span>F:XCharConverter.x64.dll<span style="color: #9933CC;">""</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;如果是64位的系統</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;; 功能:用對話框形式轉化兩岸三地的文字</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> C:DLG <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> Dialog<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> Dialog <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-create-object</span> <span style="color: #9933CC;">"CharConverter.Dialog"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> Dialog <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">progn</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> Dialog 'doit<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-release-object</span> Dialog<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;; 功能:簡體字符串和繁體字符串互相轉化(此程序為LISP,無需插件)</span> <span style="color: #6699CC; font-style: italic;">;;; 輸入:字符串</span> <span style="color: #6699CC; font-style: italic;">;;; 輸出:被轉化后的字符串</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> Text:CharConvert <span style="color: #336699; font-weight: bold;">(</span>Converter IsRev text <span style="color: #66cc66; font-weight: bold;">/</span> Index NewTxt Str From to<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> IsRev <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> From TraditionalCharset To SimpleCharSet <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> From SimpleCharSet To TraditionalCharset <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> NewTxt <span style="color: #9933CC;">""</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">while</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/=</span> text <span style="color: #9933CC;">""</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> str <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">substr</span> text <span style="color: #FF9900;">1</span> <span style="color: #FF9900;">1</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">></span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">ascii</span> str<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">128</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">progn</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> str <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">substr</span> text <span style="color: #FF9900;">1</span> <span style="color: #FF9900;">2</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> text <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">substr</span> text <span style="color: #FF9900;">3</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> index <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">VL-POSITION</span> str From<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> str <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">nth</span> index To<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> str <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">substr</span> text <span style="color: #FF9900;">1</span> <span style="color: #FF9900;">1</span><span style="color: #336699; font-weight: bold;">)</span> text <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">substr</span> text <span style="color: #FF9900;">2</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> newtxt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strcat</span> newtxt str<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> newtxt <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;; 功能:把含文字實體的CAD圖元進行簡繁轉換</span> <span style="color: #6699CC; font-style: italic;">;;; 輸入:含文字實體的CAD圖元</span> <span style="color: #6699CC; font-style: italic;">;;; 輸出:被轉化后的CAD圖元</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> ConvertEntity <span style="color: #336699; font-weight: bold;">(</span>Ent Converter How <span style="color: #66cc66; font-weight: bold;">/</span> dxf obj typ txt name blk TMPLST d<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> dxf <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">entget</span> ent<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> obj <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-ename->vla-object</span> ent<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> Typ <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cdr</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">assoc</span> <span style="color: #FF9900;">0</span> dxf<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cond</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-property-available-p</span> obj 'textstring<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;單行文字,多行文字,容差等等。</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> txt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-get-TextString</span> obj<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;取得文字內容</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-put-textstring</span> obj <span style="color: #336699; font-weight: bold;">(</span>Func Converter How txt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;修改文字內容</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> Typ <span style="color: #9933CC;">"ATTDEF"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">progn</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> txt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-get-tagstring</span> obj<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-put-tagstring</span> obj <span style="color: #336699; font-weight: bold;">(</span>Func Converter How txt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-property-available-p</span> obj 'TextOverride<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;尺寸標注</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> txt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-get-TextOverride</span> obj<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;取得文字內容</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-put-TextOverride</span> obj <span style="color: #336699; font-weight: bold;">(</span>Func Converter How txt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;修改文字內容</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> Typ <span style="color: #9933CC;">"ACAD_TABLE"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;表格</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> TMPLST <span style="color: #339933;font-weight: bold;">nil</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">foreach</span> n dxf <span style="color: #6699CC; font-style: italic;">;此處用DXF表(用vla方法比較啰嗦)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> d <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> n<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">or</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> d <span style="color: #FF9900;">1</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> d <span style="color: #FF9900;">3</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> txt <span style="color: #336699; font-weight: bold;">(</span>Func Converter How <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cdr</span> n<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;取得并修改文字內容</span> TMPLST <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> d txt<span style="color: #336699; font-weight: bold;">)</span> TMPLST<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> TMPLST <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> n TMPLST <span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">entmod</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">reverse</span> TMPLST<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-update</span> obj<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;需要更新一下</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> Typ <span style="color: #9933CC;">"INSERT"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;對于插入塊</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">foreach</span> Att <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> obj 'GetAttributes<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> txt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-get-tagstring</span> Att<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-put-tagstring</span> Att <span style="color: #336699; font-weight: bold;">(</span>Func Converter How txt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> txt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-get-textstring</span> Att<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-put-textstring</span> Att <span style="color: #336699; font-weight: bold;">(</span>Func Converter How txt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> name <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-get-name</span> obj<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;取得塊名</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> blk <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-item</span> <span style="color: #66cc66; font-weight: bold;">*</span>BLK name<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-for</span> n blk <span style="color: #336699; font-weight: bold;">(</span>ConvertEntity <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-vla-object->ename</span> n<span style="color: #336699; font-weight: bold;">)</span> Converter How<span style="color: #336699; font-weight: bold;">)</span><span style="color: #6699CC; font-style: italic;">;遞歸進去,用于處理嵌套</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-update</span> obj<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;需要更新一下</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;; 測試程序一,把一個文本文件里面的文字進行簡繁轉化</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> C:TT <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> BASE EXTN FILE KEY NAME OUTFILE PATH STR How OBJ LNG<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> STR <span style="color: #9933CC;">"(1)GB->GBK;(2)GBK->GB;(3)GB->BIG5;(4)BIG5->GB;(5)GBK->BIG5;(6)BIG5->GBK"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> LNG <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">getvar</span> 'locale<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cond</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> LNG <span style="color: #9933CC;">"CHS"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> STR <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strcat</span> <span style="color: #9933CC;">"请选择方式: "</span> STR <span style="color: #9933CC;">"<默认>"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> LNG <span style="color: #9933CC;">"CHT"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> STR <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strcat</span> <span style="color: #9933CC;">"叫匡拒よΑ: "</span> STR <span style="color: #9933CC;">"<纐粄>"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #339933;font-weight: bold;">T</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> STR <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strcat</span> <span style="color: #9933CC;">"請選擇方式: "</span> STR <span style="color: #9933CC;">"<默認>"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">initget</span> <span style="color: #9933CC;">"1 2 3 4 5 6 S T"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> key <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">getkword</span> STR<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> name <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">getfiled</span> <span style="color: #9933CC;">"Select a text File"</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">getvar</span> 'DWGPREFIX<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #9933CC;">"*"</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">and</span> name <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> file <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">open</span> name <span style="color: #9933CC;">"R"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">progn</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cond</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> key <span style="color: #9933CC;">"1"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How 'GB_GBK<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> key <span style="color: #9933CC;">"2"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How 'GBK_GB<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> key <span style="color: #9933CC;">"3"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How 'GB_BIG5<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> key <span style="color: #9933CC;">"4"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How 'BIG5_GB<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> key <span style="color: #9933CC;">"5"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How 'GBK_BIG5<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> key <span style="color: #9933CC;">"6"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How 'BIG5_GBK<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> key <span style="color: #9933CC;">"S"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How <span style="color: #339933;font-weight: bold;">nil</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> key <span style="color: #9933CC;">"T"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How <span style="color: #339933;font-weight: bold;">T</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #339933;font-weight: bold;">t</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How 'GB_GBK<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> path <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vl-filename-directory</span> name<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> extn <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vl-filename-extension</span> name<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> base <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vl-filename-base</span> name<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">and</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">null</span> extn<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> extn <span style="color: #9933CC;">""</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> outfile <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">open</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strcat</span> path <span style="color: #9933CC;">""</span> base <span style="color: #9933CC;">"轉"</span> extn<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #9933CC;">"w"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> obj <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-create-object</span> <span style="color: #9933CC;">"CharConverter.converter"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">while</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> str <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">read-line</span> file<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;(setq str (Text:CharConvert nil How str)) ;如果你不用插件,可以用此方式</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> str <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> obj How str<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">write-line</span> str Outfile<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">close</span> outfile<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">close</span> file<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-release-object</span> obj<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;; 測試程序二,把選中的CAD文本簡繁轉化(需要先注冊插件)</span> <span style="color: #6699CC; font-style: italic;">;;; 當然你也可稍加修改,就能把標注,表格,及符號表的說明等轉化。</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> C:Test <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> i key Sel Ent <span style="color: #66cc66; font-weight: bold;">*</span>DOC <span style="color: #66cc66; font-weight: bold;">*</span>BLK How CONVERTER LNG STR FUNC<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> STR <span style="color: #9933CC;">"(1)GB->GBK;(2)GBK->GB;(3)GB->BIG5;(4)BIG5->GB;(5)GBK->BIG5;(6)BIG5->GBK"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> LNG <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">getvar</span> 'locale<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cond</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> LNG <span style="color: #9933CC;">"CHS"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> STR <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strcat</span> <span style="color: #9933CC;">"请选择方式: "</span> STR <span style="color: #9933CC;">"<默认>"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> LNG <span style="color: #9933CC;">"CHT"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> STR <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strcat</span> <span style="color: #9933CC;">"叫匡拒よΑ: "</span> STR <span style="color: #9933CC;">"<纐粄>"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #339933;font-weight: bold;">T</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> STR <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strcat</span> <span style="color: #9933CC;">"請選擇方式: "</span> STR <span style="color: #9933CC;">"<默認>"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">initget</span> <span style="color: #9933CC;">"1 2 3 4 5 6 S T"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> key <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">getkword</span> STR<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> sel <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">ssget</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> . <span style="color: #9933CC;">"*TEXT,INSERT,ATTDEF,TOLERANCE,DIMENSION,ACAD_TABLE"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">progn</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cond</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> key <span style="color: #9933CC;">"1"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How 'GB_GBK<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> key <span style="color: #9933CC;">"2"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How 'GBK_GB<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> key <span style="color: #9933CC;">"3"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How 'GB_BIG5<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> key <span style="color: #9933CC;">"4"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How 'BIG5_GB<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> key <span style="color: #9933CC;">"5"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How 'GBK_BIG5<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> key <span style="color: #9933CC;">"6"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How 'BIG5_GBK<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> key <span style="color: #9933CC;">"S"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How <span style="color: #339933;font-weight: bold;">nil</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> key <span style="color: #9933CC;">"T"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How <span style="color: #339933;font-weight: bold;">T</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #339933;font-weight: bold;">t</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> How 'GB_GBK<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> <span style="color: #66cc66; font-weight: bold;">*</span>DOC <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-get-ActiveDocument</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-get-acad-object</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> <span style="color: #66cc66; font-weight: bold;">*</span>BLK <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-get-blocks</span> <span style="color: #66cc66; font-weight: bold;">*</span>DOC<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> Converter <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-create-object</span> <span style="color: #9933CC;">"CharConverter.converter"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> Converter <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> Func <span style="color: #339933;font-weight: bold;">vlax-invoke</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;如果加載了插件,則可以用invoke方式</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> Func Text:CharConvert<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;實際上此處函數可自定,不僅是簡繁轉換</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-StartUndoMark</span> <span style="color: #66cc66; font-weight: bold;">*</span>DOC<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> i <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">repeat</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">sslength</span> sel<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> ent <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">ssname</span> sel i<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span>ConvertEntity Ent converter How<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> i <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">1+</span> i<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-EndUndoMark</span> <span style="color: #66cc66; font-weight: bold;">*</span>DOC<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-release-object</span> converter<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-release-object</span> <span style="color: #66cc66; font-weight: bold;">*</span>DOC<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"n轉化完畢,請驗證!"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;;漢字轉化字符表</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;; 以下程序用于格式化簡繁字庫</span> <span style="color: #6699CC; font-style: italic;">;;; 如果你想要添加本程序中沒有的字庫,請按照一一對應的方式添加</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> C:FormatSet <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> A1 A2 F1 F2 F3 F4 I L1 L2 S1 S2<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> f1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">open</span> <span style="color: #9933CC;">"f:zqylsp簡體字.txt"</span> <span style="color: #9933CC;">"R"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> f2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">open</span> <span style="color: #9933CC;">"f:zqylsp繁體字.txt"</span> <span style="color: #9933CC;">"R"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> f3 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">open</span> <span style="color: #9933CC;">"f:zqylspSimpleList.txt"</span> <span style="color: #9933CC;">"w"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> f4 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">open</span> <span style="color: #9933CC;">"f:zqylspTraditionalList.txt"</span> <span style="color: #9933CC;">"w"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> i <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> l1 <span style="color: #339933;font-weight: bold;">nil</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">while</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> s1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">read-line</span> f1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">while</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/=</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> a1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">substr</span> s1 <span style="color: #FF9900;">1</span> <span style="color: #FF9900;">2</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #9933CC;">""</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">and</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">zerop</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">rem</span> i <span style="color: #FF9900;">20</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"n"</span> f3<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #336699; font-weight: bold;">(</span>vl<span style="color: #66cc66; font-weight: bold;">-</span>string<span style="color: #66cc66; font-weight: bold;">-></span><span style="color: #339933;font-weight: bold;">list</span> a1<span style="color: #336699; font-weight: bold;">)</span> f3<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> l1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> a1 l1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> s1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">substr</span> s1 <span style="color: #FF9900;">3</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> i <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">1+</span> i<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> i <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> l2 <span style="color: #339933;font-weight: bold;">nil</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">while</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> s2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">read-line</span> f2<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">while</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/=</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> a2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">substr</span> s2 <span style="color: #FF9900;">1</span> <span style="color: #FF9900;">2</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #9933CC;">""</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">and</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">zerop</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">rem</span> i <span style="color: #FF9900;">20</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"n"</span> f4<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #336699; font-weight: bold;">(</span>vl<span style="color: #66cc66; font-weight: bold;">-</span>string<span style="color: #66cc66; font-weight: bold;">-></span><span style="color: #339933;font-weight: bold;">list</span> a2<span style="color: #336699; font-weight: bold;">)</span> f4<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> l2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> a2 l2<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> s2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">substr</span> s2 <span style="color: #FF9900;">3</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> i <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">1+</span> i<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;(setq l1 (ACAD_STRLSORT l1))</span> <span style="color: #6699CC; font-style: italic;">;(setq l2 (ACAD_STRLSORT l2))</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">close</span> f1<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">close</span> f2<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">close</span> f3<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">close</span> f4<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;下面代碼用于測試</span> <span style="color: #6699CC; font-style: italic;">;;;(MISC:Test 1000 '( (Text:CharConvert txt IsRev) (vlax-invoke Converter How txt)))</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> C:test2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> f obj<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> obj <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-create-object</span> <span style="color: #9933CC;">"CharConverter.converter"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> obj 'BIG5_GB <span style="color: #9933CC;">"い地チ㎝瓣"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> obj 'GBK_BIG5 <span style="color: #9933CC;">"中華人民共和國"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> obj 'GB_GBK <span style="color: #9933CC;">"中华人民共和国"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> obj 'GBK_GB <span style="color: #9933CC;">"中華人民共和國"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> obj 'BIG5_GBK <span style="color: #9933CC;">"い地チ㎝瓣"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> obj 'GBK_BIG5 <span style="color: #9933CC;">"中華人民共和國"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> f <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">open</span> <span style="color: #9933CC;">"d:/temp/1.txt"</span> <span style="color: #9933CC;">"W"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">write-line</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> obj 'GB_Big5 <span style="color: #9933CC;">"中华人民共和国"</span><span style="color: #336699; font-weight: bold;">)</span> f<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">close</span> f<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-release-object</span> obj<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;; 注冊加載</span> <span style="color: #336699; font-weight: bold;">(</span>Register<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"nTT --轉換文本文件,nTest --轉換含文本的CAD圖元,nDLG --對話框形式轉換.這幾個命令可自行修改."</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span><span style="color: #336699; font-weight: bold;">)</span></pre></div> </div></div></div> </div> <div class="field field-node-field-blog-tags field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-blog-tags field-type-entity-reference field-label-above"><h3 class="field__label">标签</h3><div class="field__items"><div class="field__item field__item--简体--繁体--转换-"> <span class="field__item-wrapper"><a href="/drupal/taxonomy/term/43" hreflang="zh-hans">简体 繁体 转换 </a></span> </div></div> </div> <div class="field field-node-field-category field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-category field-type-entity-reference field-label-hidden"><div class="field__items"><div class="field__item field__item--编程"> <span class="field__item-wrapper"><a href="/drupal/programming" hreflang="zh-hans">编程</a></span> </div></div> </div> <section class="field field-node--field-blog-comments field-formatter-comment-default field-name-field-blog-comments field-type-comment field-label-above display-mode-threaded comment-bundle-comment comment-wrapper"> <a name="comments"></a></section> Sun, 24 Jan 2021 03:49:13 +0000 highflybird 149 at https://www.highflybird.com/drupal 曲线的转弯半径和曲率 https://www.highflybird.com/drupal/node/148 <span class="field field-name-title field-formatter-string field-type-string field-label-hidden">曲线的转弯半径和曲率</span> <span class="field field-name-uid field-formatter-author field-type-entity-reference field-label-hidden"><span lang="" about="/drupal/user/1" typeof="schema:Person" property="schema:name" datatype="">highflybird</span></span> <span class="field field-name-created field-formatter-timestamp field-type-created field-label-hidden">周日, 01/24/2021 - 11:39</span> <div class="clearfix text-formatted field field-node--body field-formatter-text-default field-name-body field-type-text-with-summary field-label-hidden has-single"><div class="field__items"><div class="field__item"><div class="tex2jax_process"><p>在下面的这个帖子中讨论了椭圆的曲率和转弯半径<br /> <a href="http://bbs.mjtd.com/thread-62980-1-1.html">http://bbs.mjtd.com/thread-62980-1-1.html</a><br /> 现在我把这个主题深化一下,讨论一下曲线的两个函数:<br /> vlax-curve-getSecondDeriv<br /> vlax-curve-getFirstDeriv<br /> 这两个函数是什么意思呢?<br /> 我们考察AutoCAD里面的曲线类,主要是圆,椭圆,弧和样条曲线,多段线由这几种组合而成。<br /> 椭圆和样条曲线实际上都是由参数形成,因此,对于这类曲线,它们每点的坐标可以由参数方程表达:<br /> 譬如椭圆 x=a*cos(t); y=b*sin(t);<br /> 样条曲线也有方程,假设样条曲线的参数方程为: X= f(t);<br /> Y=g(t);<br /> 因此可以对参数方程求导,得到每一点的切线矢量,曲线上每一点对应于一个参数 t0 ,<br /> 这个切线矢量的 的X值就是 f(t)在t0处的一阶导数,Y值就是g(t)在t0处的一阶导数,<br /> 即( f'(t0), g'(t0),0)<br /> 因而我们就理解了vlax-curve-getFirstDeriv 函数返回值的意义,<br /> 对于vlax-curve-getSecondDeriv的意义类似,只不过这次换成了二阶导数。<br /> 即( f''(t0), g''(t0),0)</p> <p>那么如何求样条曲线或者椭圆的每一点的曲率及其半径呢?<br /> 根据参数方程的求曲率公式,若曲线由下面参数方程给出:<br /> \[\left\{\begin{array}{l}x=\varphi(t) \\ y=\psi(t) \end{array}\right.\]<br /> 那么曲率如何计算?提示:<br /> \[K=\frac{\left|\varphi^{\prime}(t) \psi^{\prime \prime}(t)-\varphi^{\prime \prime}(t) \psi^{\prime}(t)\right|}{\left[\varphi^{\prime 2}(t)+\psi^{\prime 2}(t)\right]^{3 / 2}}\]<br /> 下面是求值代码:</p> <div class="geshifilter"> <pre class="cadlisp geshifilter-cadlisp" style="font-family:monospace;"><span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;;功能: 获取椭圆上一点处的曲率和离心半径(适用于单次利用此法)</span> <span style="color: #6699CC; font-style: italic;">;;;参数: 椭圆实体和椭圆上的一点</span> <span style="color: #6699CC; font-style: italic;">;;;返回: 此处离心圆圆心、离心半径及其曲率(离心率)</span> <span style="color: #6699CC; font-style: italic;">;;;说明: 如果要在CAD中几何作图,可以参考此贴:</span> <span style="color: #6699CC; font-style: italic;">;;; http://bbs.mjtd.com/thread-62980-1-1.html</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> ELL:GetCurvature <span style="color: #336699; font-weight: bold;">(</span>en pt <span style="color: #66cc66; font-weight: bold;">/</span> obj a b px x y v1 v2 rad cen<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> obj <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-ename->vla-object</span> en<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> a <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-get-MajorRadius</span> obj<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;椭圆的半长轴</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> b <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-get-MinorRadius</span> obj<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;椭圆的半短轴</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getclosestpointto</span> en pt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;保证此点在椭圆上</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> px <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getParamAtPoint</span> en pt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;此点的椭圆参数</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> v1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getFirstDeriv</span> en px<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;此点的一阶矢量</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> v2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">-</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cadr</span> v1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> v1<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">caddr</span> v1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;此点的切线矢量</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> x <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> a <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">sin</span> px<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> y <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> b <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cos</span> px<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> rad <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">expt</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> x x<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> y y<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">1.5</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> a b<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;得到转弯半径</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> cen <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">polar</span> pt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">angle</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> v2<span style="color: #336699; font-weight: bold;">)</span> rad<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;圆心</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> cen rad<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;圆心及半径</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;; 利用参数方程的求椭圆的曲率及其离心半径(适用于多次利用此法)</span> <span style="color: #6699CC; font-style: italic;">;;; 功能: 获取椭圆上一点处的转弯半径和离心圆圆心</span> <span style="color: #6699CC; font-style: italic;">;;; 参数: 椭圆实体和曲线上的一点</span> <span style="color: #6699CC; font-style: italic;">;;; 返回: 此处离心圆圆心、离心半径</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> ELL:GetCurvature1 <span style="color: #336699; font-weight: bold;">(</span>en a b pt <span style="color: #66cc66; font-weight: bold;">/</span> px v1 v2 x y rad cen<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getclosestpointto</span> en pt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;保证此点在椭圆上</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> px <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getParamAtPoint</span> en pt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;此点的椭圆参数</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> v1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getFirstDeriv</span> en px<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;此点的一阶矢量</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> v2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">-</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cadr</span> v1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> v1<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">caddr</span> v1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;此点的切线矢量</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> x <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> a <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">sin</span> px<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> y <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> b <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cos</span> px<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> rad <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">expt</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> x x<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> y y<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">1.5</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> a b<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;得到转弯半径</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> cen <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">polar</span> pt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">angle</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> v2<span style="color: #336699; font-weight: bold;">)</span> rad<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;圆心</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> cen rad<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;圆心及半径</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;; 一般平面曲线参数方程的曲率离心公式</span> <span style="color: #6699CC; font-style: italic;">;;; 功能: 获取曲线上一点处的离心半径和离心圆圆心</span> <span style="color: #6699CC; font-style: italic;">;;; 参数: 曲线实体和曲线上的一点</span> <span style="color: #6699CC; font-style: italic;">;;; 返回: 此处离心圆圆心、离心半径</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> CUR:GetCurvature <span style="color: #336699; font-weight: bold;">(</span>en pt <span style="color: #66cc66; font-weight: bold;">/</span> ob px v1 v2 v3 x1 y1 x2 y2 cen rad d1 d2<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> ob <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-ename->vla-object</span> en<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getclosestpointto</span> en pt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;保证此点在曲线上</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> px <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getParamAtPoint</span> en pt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;此点的曲线参数</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> v1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getFirstDeriv</span> en px<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;此点的一阶矢量</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> v2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getSecondDeriv</span> en px<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;此点的二阶矢量</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> v3 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">-</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cadr</span> v1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> v1<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">caddr</span> v1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;此点的切线矢量</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> x1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> v1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;一阶导数的 X值</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> y1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cadr</span> v1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;一阶导数的 Y值</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> x2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> v2<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;二阶导数的 X值</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> y2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cadr</span> v2<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;二阶导数的 Y值</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> d1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">expt</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> y1 y1<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> x1 x1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">1.5</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> d2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">-</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> x1 y2<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> x2 y1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;转弯内外的判定</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/=</span> d2 <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;如果不为直线段</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">progn</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> rad <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> d1 d2<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-method-applicable-p</span> ob 'GetBulge<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;如果为多段线(含圆弧)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;"><</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-GetBulge</span> ob <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">fix</span> px<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;如果此段凸度小于0</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> rad <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">-</span> rad<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">polar</span> pt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">angle</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> v3<span style="color: #336699; font-weight: bold;">)</span> rad<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">abs</span> rad<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;圆心及半径</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span></pre></div> <p> </p> <p>一些测试代码:</p> <div class="geshifilter"> <pre class="cadlisp geshifilter-cadlisp" style="font-family:monospace;"><span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;;测试程序1: 获取曲线一点处的曲率和离心半径</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> c:tt1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> ent pnt ret<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> ent <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">entsel</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>请选取曲线:"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">while</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pnt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">getpoint</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>点取一点"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pnt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">trans</span> pnt <span style="color: #FF9900;">1</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pnt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getclosestpointto</span> ent pnt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> ret <span style="color: #336699; font-weight: bold;">(</span>CUR:GetCurvature ent pnt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>离心半径是:"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> ret<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">and</span> ret <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">apply</span> 'Ent:Make_Circle ret<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;;测试程序2: 获取椭圆一点处的曲率和离心半径,并比较两种方法</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> c:tt2 <span style="color: #336699; font-weight: bold;">(</span> <span style="color: #66cc66; font-weight: bold;">/</span> ent obj a b pnt par 1st 2st r1 r2 r3<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">and</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> ent <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">entsel</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>请选取椭圆:"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> obj <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-ename->vla-object</span> ent<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-property-available-p</span> obj 'MajorRadius<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;这个地方应该加出错处理</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> a <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-get-MajorRadius</span> obj<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> b <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-get-MinorRadius</span> obj<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">while</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pnt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">getpoint</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>点取一点:"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pnt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">trans</span> pnt <span style="color: #FF9900;">1</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pnt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getclosestpointto</span> ent pnt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> par <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getparamatpoint</span> ent pnt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> 1st <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getFirstDeriv</span> ent par<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> 2st <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getSecondDeriv</span> ent par<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> r1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">distance</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> 2st<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;这个secondDeriv并不意味着半径</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> r2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cadr</span> <span style="color: #336699; font-weight: bold;">(</span>ELL:GetCurvature1 ent a b pnt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> r3 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cadr</span> <span style="color: #336699; font-weight: bold;">(</span>CUR:getcurvature ent pnt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>Radius 1 is:"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> r1<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>Radius 2 is:"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> r2<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>Radius 3 is:"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> r3<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span>UTI:Bench <span style="color: #FF9900;">10000</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> 'ELL:GetCurvature1 ent a b pnt<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> 'CUR:getcurvature ent pnt<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;;测试程序3: 动态演示曲线的离心半径</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> c:tt3 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> CIR ENT LIN PNT PT0 RET 1ST 2ST CEN PAR PT2 VEC<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> ent <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">entsel</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>请选取曲线:"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> cir <span style="color: #336699; font-weight: bold;">(</span>Ent:Make_Circle '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">1</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> lin <span style="color: #336699; font-weight: bold;">(</span>ent:make_Line '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> vec <span style="color: #336699; font-weight: bold;">(</span>ent:make_Line '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> lin <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-ename->vla-object</span> lin<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> vec <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-ename->vla-object</span> vec<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> cir <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-ename->vla-object</span> cir<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-put-color</span> lin <span style="color: #FF9900;">1</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-put-color</span> cir <span style="color: #FF9900;">3</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-put-color</span> vec <span style="color: #FF9900;">6</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>按空格或者回车退出!"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">while</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pt0 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">grread</span> <span style="color: #FF9900;">5</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">5</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pnt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">trans</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cadr</span> pt0<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">1</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pnt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getclosestpointto</span> ent pnt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> par <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getparamatpoint</span> ent pnt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> 1st <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getFirstDeriv</span> ent par<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> 2st <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getSecondDeriv</span> ent par<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> ret <span style="color: #336699; font-weight: bold;">(</span>CUR:GetCurvature ent pnt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">progn</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pt2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">mapcar</span> '<span style="color: #66cc66; font-weight: bold;">+</span> pnt 2st<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> cen <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> ret<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-put</span> Cir 'Center cen <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-put</span> cir 'Radius <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cadr</span> ret<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-put</span> lin 'StartPoint cen<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-put</span> lin 'EndPoint pnt<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-put</span> vec 'StartPoint pt2<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-put</span> vec 'EndPoint pnt<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-erase</span> cir<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-erase</span> lin<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vla-erase</span> vec<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;;测试程序4: 由曲线的离心半径描绘其轨迹</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> c:tt4 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> ent lst par px1 px2 pxn pnt Inf cen<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> ent <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">entsel</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>请选取曲线:"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">progn</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> px1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getStartParam</span> ent<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> px2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getendparam</span> ent<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pxn <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">-</span> px2 px1<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">0.02</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> par px1<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">while</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;"><=</span> par px2<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pnt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-curve-getpointatparam</span> ent par<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> Inf <span style="color: #336699; font-weight: bold;">(</span>CUR:GetCurvature ent pnt<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> cen <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> Inf<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> lst <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> cen lst<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> par <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> par pxn<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> lst <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">reverse</span> lst<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span>Ent:Make_LWPoly lst <span style="color: #FF9900;">1</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span></pre></div> <p> </p> <p>相关联代码:</p> <div class="geshifilter"> <pre class="cadlisp geshifilter-cadlisp" style="font-family:monospace;"><span style="color: #6699CC; font-style: italic;">;;;************************************************************;</span> <span style="color: #6699CC; font-style: italic;">;;;实体创建部分</span> <span style="color: #6699CC; font-style: italic;">;;;************************************************************;</span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;;创建一个点</span> <span style="color: #6699CC; font-style: italic;">;;;输入: 一个三维或者二维的点</span> <span style="color: #6699CC; font-style: italic;">;;;输出: 点实体的图元名</span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> Ent:Make_Point <span style="color: #336699; font-weight: bold;">(</span>p<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">entmakex</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> . <span style="color: #9933CC;">"POINT"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> <span style="color: #FF9900;">10</span> p<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;;创建一个带颜色的点(此函数为测试或者其他用途)</span> <span style="color: #6699CC; font-style: italic;">;;;输入: 一个三维或者二维的点表和一个颜色号</span> <span style="color: #6699CC; font-style: italic;">;;;输出: 点实体的图元名</span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> Ent:MakePoint<span style="color: #66cc66; font-weight: bold;">-</span><span style="color: #FF9900;">1</span> <span style="color: #336699; font-weight: bold;">(</span>p c<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">entmakex</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> . <span style="color: #9933CC;">"POINT"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> <span style="color: #FF9900;">10</span> p<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> <span style="color: #FF9900;">62</span> c<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;;创建一条直线段</span> <span style="color: #6699CC; font-style: italic;">;;;输入: 两个三维或者二维的点</span> <span style="color: #6699CC; font-style: italic;">;;;输出: 线段实体的图元名</span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> Ent:Make_Line <span style="color: #336699; font-weight: bold;">(</span>p q<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">entmakeX</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> . <span style="color: #9933CC;">"LINE"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> <span style="color: #FF9900;">10</span> p<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> <span style="color: #FF9900;">11</span> q<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;;创建一个由三条直线组成的三角形</span> <span style="color: #6699CC; font-style: italic;">;;;输入: 三个三维或者二维的点</span> <span style="color: #6699CC; font-style: italic;">;;;输出: 由三条直线组成的三角形</span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> Ent:Make_Triangle <span style="color: #336699; font-weight: bold;">(</span>p1 p2 p3<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">mapcar</span> 'Ent:Make_Line <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> p1 p2 p3<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> p2 p3 p1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;;创建一个三维多段线</span> <span style="color: #6699CC; font-style: italic;">;;;输入: 三维的点集</span> <span style="color: #6699CC; font-style: italic;">;;;输出: 三维多段线实体</span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> Ent:Make_Poly <span style="color: #336699; font-weight: bold;">(</span>pts Closed <span style="color: #66cc66; font-weight: bold;">/</span> e<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> Closed <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> e <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">Entmake</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> . <span style="color: #9933CC;">"POLYLINE"</span><span style="color: #336699; font-weight: bold;">)</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">70</span> . <span style="color: #FF9900;">9</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> e <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">Entmake</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> . <span style="color: #9933CC;">"POLYLINE"</span><span style="color: #336699; font-weight: bold;">)</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">70</span> . <span style="color: #FF9900;">8</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">foreach</span> p pts <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">entmake</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> . <span style="color: #9933CC;">"VERTEX"</span><span style="color: #336699; font-weight: bold;">)</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">70</span> . <span style="color: #FF9900;">32</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> <span style="color: #FF9900;">10</span> p<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">entmake</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> . <span style="color: #9933CC;">"SEQEND"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">entlast</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;;创建轻多段线</span> <span style="color: #6699CC; font-style: italic;">;;;输入: 二维的点集</span> <span style="color: #6699CC; font-style: italic;">;;;输出: 轻多段线实体名</span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> Ent:Make_LWPoly <span style="color: #336699; font-weight: bold;">(</span>pts closed <span style="color: #66cc66; font-weight: bold;">/</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">entmakeX</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">append</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> . <span style="color: #9933CC;">"LWPOLYLINE"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">100</span> . <span style="color: #9933CC;">"AcDbEntity"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">100</span> . <span style="color: #9933CC;">"AcDbPolyline"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> <span style="color: #FF9900;">90</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">length</span> pts<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;顶点个数</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">mapcar</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">function</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">lambda</span> <span style="color: #336699; font-weight: bold;">(</span>x<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> <span style="color: #FF9900;">10</span> x<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> pts<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;多段线顶点</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> <span style="color: #FF9900;">70</span> closed<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;闭合的</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #6699CC; font-style: italic;">;;; 创建圆实体</span> <span style="color: #6699CC; font-style: italic;">;;; 输入: 圆心C和半径R</span> <span style="color: #6699CC; font-style: italic;">;;; 输出: 圆的实体名</span> <span style="color: #6699CC; font-style: italic;">;;;-------------------------------------------------------------</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> Ent:Make_Circle <span style="color: #336699; font-weight: bold;">(</span>C R<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">entmakex</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> . <span style="color: #9933CC;">"CIRCLE"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> <span style="color: #FF9900;">10</span> C<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cons</span> <span style="color: #FF9900;">40</span> R<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span></pre></div> <p> </p> <p>程序1效果演示:</p> <figure><img alt="" height="718" loading="lazy" src="https://www.highflybird.com/blog/wp-content/uploads/2020/02/t11.gif" width="938" /></figure> <p>程序2效果演示:</p> <figure><img alt="" height="650" loading="lazy" sizes="(max-width: 399px) 100vw, 399px" src="https://www.highflybird.com/blog/wp-content/uploads/2020/02/ell-1.jpg" srcset="https://www.highflybird.com/blog/wp-content/uploads/2020/02/ell-1.jpg 399w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/ell-1-184x300.jpg 184w" width="399" /></figure> </div></div></div> </div> <div class="field field-node-field-blog-tags field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-blog-tags field-type-entity-reference field-label-above"><h3 class="field__label">标签</h3><div class="field__items"><div class="field__item field__item--曲率-转弯半径"> <span class="field__item-wrapper"><a href="/drupal/taxonomy/term/41" hreflang="zh-hans">曲率 转弯半径</a></span> </div></div> </div> <div class="field field-node-field-category field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-category field-type-entity-reference field-label-hidden"><div class="field__items"><div class="field__item field__item--编程"> <span class="field__item-wrapper"><a href="/drupal/programming" hreflang="zh-hans">编程</a></span> </div></div> </div> <section class="field field-node--field-blog-comments field-formatter-comment-default field-name-field-blog-comments field-type-comment field-label-above display-mode-threaded comment-bundle-comment comment-wrapper"> <a name="comments"></a></section> Sun, 24 Jan 2021 03:39:13 +0000 highflybird 148 at https://www.highflybird.com/drupal 小问题,大思考 https://www.highflybird.com/drupal/node/147 <span class="field field-name-title field-formatter-string field-type-string field-label-hidden">小问题,大思考</span> <span class="field field-name-uid field-formatter-author field-type-entity-reference field-label-hidden"><span lang="" about="/drupal/user/1" typeof="schema:Person" property="schema:name" datatype="">highflybird</span></span> <span class="field field-name-created field-formatter-timestamp field-type-created field-label-hidden">周日, 01/24/2021 - 11:28</span> <div class="clearfix text-formatted field field-node--body field-formatter-text-default field-name-body field-type-text-with-summary field-label-hidden has-single"><div class="field__items"><div class="field__item"><div class="tex2jax_process"><p>一个博士朋友的儿子刚上初中不久,他就提出了下面的一个问题,我感觉很有深度,很难得,现在贴出来说说。</p> <p>如下面图所示:已知线段AB和一点P,n等分线段,得到n+1个点与P连线。</p> <p>问:<strong>n趋于无穷大时,这些连线长的平均值趋向一个定数吗? 如果是,该怎样求?</strong></p> <figure><img alt="" height="569" loading="lazy" sizes="(max-width: 911px) 100vw, 911px" src="https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson.jpg" srcset="https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson.jpg 911w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-300x187.jpg 300w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-768x480.jpg 768w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-480x300.jpg 480w" width="911" /></figure> <p>粗看起来好像没什么难度,然而稍微计算一下,就发现不那么简单,博士拿出了Maple这个数学软件,用求极限法得到了一个并不简单的结果:</p> <figure><img alt="" height="324" loading="lazy" sizes="(max-width: 1024px) 100vw, 1024px" src="https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-1-1024x324.png" srcset="https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-1-1024x324.png 1024w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-1-300x95.png 300w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-1-768x243.png 768w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-1-500x158.png 500w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-1.png 1210w" width="1024" /></figure> <p>后来,我觉得这个极限可以化为积分,得到了相同的结果:</p> <figure><img alt="" height="91" loading="lazy" sizes="(max-width: 876px) 100vw, 876px" src="https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-3.png" srcset="https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-3.png 876w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-3-300x31.png 300w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-3-768x80.png 768w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-3-500x52.png 500w" width="876" /></figure> <p>其中的字母含义如下:</p> <figure><img alt="" height="422" loading="lazy" sizes="(max-width: 977px) 100vw, 977px" src="https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-4.png" srcset="https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-4.png 977w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-4-300x130.png 300w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-4-768x332.png 768w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-4-500x216.png 500w" width="977" /></figure> <p>这个结果显然不是初中的知识了。</p> <p>这个小孩很有天赋,他还把这个问题做引申发散开来。</p> <p>首先,他问这样的平均距离除了对直线有外,对圆也有么?</p> <p>我开始用积分算了一下,得到一个巨复杂的结果:</p> <figure><img alt="" height="523" loading="lazy" sizes="(max-width: 1024px) 100vw, 1024px" src="https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-5-1024x523.png" srcset="https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-5-1024x523.png 1024w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-5-300x153.png 300w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-5-768x392.png 768w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-5-1536x784.png 1536w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-5-500x255.png 500w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-5.png 1696w" width="1024" /></figure> <p>后来稍微优化了一下,</p> <figure><img alt="" height="107" loading="lazy" sizes="(max-width: 1024px) 100vw, 1024px" src="https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-6-1024x107.png" srcset="https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-6-1024x107.png 1024w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-6-300x31.png 300w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-6-768x80.png 768w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-6-1536x160.png 1536w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-6-500x52.png 500w, https://www.highflybird.com/blog/wp-content/uploads/2020/02/cqjson-6.png 1691w" width="1024" /></figure> <p>但可以看出,这已经不是可以用初等函数来表达的了,已经用了椭圆积分来表达了。然后,他又继续问了一个问题,<strong>在一个三角形内,是否存在这样的一个点,使得点到这三条线段的上述平均值相等?</strong></p> <p>在我看来,一般情况下存在这个点,原因如下:<br /> 因为一点(x,y)到线段的平均值的积分解是一个与x,y有关的二元函数<br /> 因此 另   p1p2的 值  设为f1(x,y), p2p3的值设置为f2(x,y),p3p1的值设置为f3(x,y)<br /> 显然有  f1(x,y)=f2(x,y); f2(x,y)=f3(x,y)<br /> 这是一个二元方程组,应该有一个解,但 估计无法用公式求解,只能数值求解了。</p> <p>下面贴出一些LISP代码来验证求解。</p> </p> <div class="geshifilter"> <pre class="cadlisp geshifilter-cadlisp" style="font-family:monospace;"><span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> ALG:AverageLength <span style="color: #336699; font-weight: bold;">(</span>p p1 p2 <span style="color: #66cc66; font-weight: bold;">/</span> A A1 A2 A3 A4 H HH L RT V<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> L <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">distance</span> p1 p2<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> v <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">trans</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">mapcar</span> '<span style="color: #66cc66; font-weight: bold;">-</span> p p1<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">0</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">mapcar</span> '<span style="color: #66cc66; font-weight: bold;">-</span> p2 p1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> h <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">abs</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> v<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> a <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">-</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">caddr</span> v<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">></span> L <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">progn</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> a <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> a L<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> h <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> h L<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> hh <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> h h<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> a1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> a a<span style="color: #336699; font-weight: bold;">)</span> hh<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> a2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> a1 a a <span style="color: #FF9900;">1</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> a3 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">sqrt</span> a1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> a4 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">sqrt</span> a2<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">equal</span> hh <span style="color: #FF9900;">0</span> 1e<span style="color: #66cc66; font-weight: bold;">-</span>8<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> rt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> a <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">-</span> a4 a3<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> a4<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> rt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> a <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">-</span> a4 a3<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> hh <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">-</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">log</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> a <span style="color: #FF9900;">1</span> a4<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">log</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> a a3<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> a4 <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> rt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> <span style="color: #FF9900;">0.5</span> rt L<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">distance</span> p p1<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #6699CC; font-style: italic;">;(1/2)*a*sqrt(a^2+h^2)-(1/2)*h^2*ln(-a+sqrt(a^2+h^2))+(1/2)*b*sqrt(b^2+h^2)+(1/2)*h^2*ln(b+sqrt(b^2+h^2))</span> <span style="color: #6699CC; font-style: italic;">;;;采用积分法</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> ALG:AverageLength2 <span style="color: #336699; font-weight: bold;">(</span>p p1 p2 <span style="color: #66cc66; font-weight: bold;">/</span> A AH B BH H HH L V rt<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> L <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">distance</span> p1 p2<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> v <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">trans</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">mapcar</span> '<span style="color: #66cc66; font-weight: bold;">-</span> p p1<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">0</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">mapcar</span> '<span style="color: #66cc66; font-weight: bold;">-</span> p2 p1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> h <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">abs</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> v<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> a <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">caddr</span> v<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> b <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">-</span> L a<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">equal</span> L <span style="color: #FF9900;">0</span> 1e<span style="color: #66cc66; font-weight: bold;">-</span>8<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">distance</span> p p1<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">equal</span> h <span style="color: #FF9900;">0</span> 1e<span style="color: #66cc66; font-weight: bold;">-</span>8<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> a a<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> b b<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">2</span> L<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> a <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> a L<span style="color: #336699; font-weight: bold;">)</span> b <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> b L<span style="color: #336699; font-weight: bold;">)</span> h <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> h L<span style="color: #336699; font-weight: bold;">)</span> hh <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> h h<span style="color: #336699; font-weight: bold;">)</span> ah <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">sqrt</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> a a<span style="color: #336699; font-weight: bold;">)</span> hh<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> bh <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">sqrt</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> b b<span style="color: #336699; font-weight: bold;">)</span> hh<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> rt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> hh <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">log</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> b bh<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">-</span> ah a<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> rt <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> <span style="color: #FF9900;">0.5</span> L <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> RT <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> a ah<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> b bh<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #6699CC; font-style: italic;">;;;收敛很慢</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> ALG:AverageLength1 <span style="color: #336699; font-weight: bold;">(</span>p p1 p2 <span style="color: #66cc66; font-weight: bold;">/</span> A AV D H HH I L N S UN V X<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> L <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">distance</span> p1 p2<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> v <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">trans</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">mapcar</span> '<span style="color: #66cc66; font-weight: bold;">-</span> p p1<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">0</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">mapcar</span> '<span style="color: #66cc66; font-weight: bold;">-</span> p2 p1<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> h <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">abs</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">car</span> v<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> a <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">-</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">caddr</span> v<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">></span> L <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">progn</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> n <span style="color: #FF9900;">1000</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> i <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> s <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> hh <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> h h<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> un <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> L n<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">repeat</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">1+</span> n<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> x <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> a <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> i un<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> d <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">sqrt</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> x x<span style="color: #336699; font-weight: bold;">)</span> hh<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> s <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> s d<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> i <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">1+</span> i<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> av <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> s <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">1+</span> n<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">distance</span> p p1<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> ALG:AverageLengthOfCircle <span style="color: #336699; font-weight: bold;">(</span>p c r <span style="color: #66cc66; font-weight: bold;">/</span> A D I L N U X Y<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> p <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">mapcar</span> '<span style="color: #66cc66; font-weight: bold;">-</span> p c<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> i <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> l <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> n <span style="color: #FF9900;">36000</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> u <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> pi n<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">repeat</span> n <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> a <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> i u<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> x <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> r <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cos</span> a<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> y <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> r <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">sin</span> a<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> d <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">distance</span> p <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> x y<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> l <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> d l<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> i <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">1+</span> i<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> l n<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> c:xx <span style="color: #336699; font-weight: bold;">(</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">initget</span> <span style="color: #FF9900;">9</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> p <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">getpoint</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>直线外一点:"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;; (initget 9)</span> <span style="color: #6699CC; font-style: italic;">;;; (setq c (getpoint "\n圆心:"))</span> <span style="color: #6699CC; font-style: italic;">;;; (initget 15)</span> <span style="color: #6699CC; font-style: italic;">;;; (setq r (getdist C "\n半径:"))</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> c '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> r <span style="color: #FF9900;">1</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> z <span style="color: #336699; font-weight: bold;">(</span>ALG:AverageLengthOfCircle p c r<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>所求的值为: "</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">rtos</span> z <span style="color: #FF9900;">2</span> <span style="color: #FF9900;">20</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> c:gg <span style="color: #336699; font-weight: bold;">(</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> i <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> p0 '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">0</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> l <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> x <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> n <span style="color: #FF9900;">1000000</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> u <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> <span style="color: #FF9900;">1.0</span> n<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">repeat</span> n <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> y <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cos</span> x<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> d <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">distance</span> p0 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">list</span> x y<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> l <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">+</span> l d<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> x <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> i u<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> i <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">1+</span> i<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> v <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> l n<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>所求的值为: "</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">rtos</span> v <span style="color: #FF9900;">2</span> <span style="color: #FF9900;">20</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> c:ccc<span style="color: #336699; font-weight: bold;">(</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">initget</span> <span style="color: #FF9900;">9</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> p <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">getpoint</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>直线外一点:"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> p <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">trans</span> p <span style="color: #FF9900;">1</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">initget</span> <span style="color: #FF9900;">9</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> p1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">getpoint</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>直线第一点:"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> p1 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">trans</span> p1 <span style="color: #FF9900;">1</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">initget</span> <span style="color: #FF9900;">9</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> p2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">getpoint</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>直线第一点:"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> p2 <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">trans</span> p2 <span style="color: #FF9900;">1</span> <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> x <span style="color: #336699; font-weight: bold;">(</span>ALG:AverageLength p p1 p2<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strcat</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>所求的平均值是:"</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">rtos</span> x <span style="color: #FF9900;">2</span> <span style="color: #FF9900;">20</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> x1 <span style="color: #336699; font-weight: bold;">(</span>ALG:AverageLength1 p p1 p2<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strcat</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>极限法所求的平均值是:"</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">rtos</span> x1 <span style="color: #FF9900;">2</span> <span style="color: #FF9900;">20</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> x2 <span style="color: #336699; font-weight: bold;">(</span>ALG:AverageLength2 p p1 p2<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strcat</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>积分法所求的平均值是:"</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">rtos</span> x2 <span style="color: #FF9900;">2</span> <span style="color: #FF9900;">20</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #6699CC; font-style: italic;">;;; (UTI:BENCH 1000</span> <span style="color: #6699CC; font-style: italic;">;;; (list</span> <span style="color: #6699CC; font-style: italic;">;;; (list 'ALG:AverageLength p p1 p2)</span> <span style="color: #6699CC; font-style: italic;">;;; (list 'ALG:AverageLength1 p p1 p2)</span> <span style="color: #6699CC; font-style: italic;">;;; )</span> <span style="color: #6699CC; font-style: italic;">;;; )</span>   <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span></pre></div> <p>有兴趣的不妨测试一下。</p> </div></div></div> </div> <div class="field field-node-field-blog-tags field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-blog-tags field-type-entity-reference field-label-above"><h3 class="field__label">标签</h3><div class="field__items"><div class="field__item field__item--天才-平均值-椭圆函数"> <span class="field__item-wrapper"><a href="/drupal/taxonomy/term/40" hreflang="zh-hans">天才 平均值 椭圆函数</a></span> </div></div> </div> <div class="field field-node-field-category field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-category field-type-entity-reference field-label-hidden"><div class="field__items"><div class="field__item field__item--编程"> <span class="field__item-wrapper"><a href="/drupal/programming" hreflang="zh-hans">编程</a></span> </div></div> </div> <section class="field field-node--field-blog-comments field-formatter-comment-default field-name-field-blog-comments field-type-comment field-label-above display-mode-threaded comment-bundle-comment comment-wrapper"> <a name="comments"></a></section> Sun, 24 Jan 2021 03:28:07 +0000 highflybird 147 at https://www.highflybird.com/drupal CAD问题小百科 https://www.highflybird.com/drupal/node/146 <span class="field field-name-title field-formatter-string field-type-string field-label-hidden">CAD问题小百科</span> <span class="field field-name-uid field-formatter-author field-type-entity-reference field-label-hidden"><span lang="" about="/drupal/user/1" typeof="schema:Person" property="schema:name" datatype="">highflybird</span></span> <span class="field field-name-created field-formatter-timestamp field-type-created field-label-hidden">周日, 01/24/2021 - 11:14</span> <div class="clearfix text-formatted field field-node--body field-formatter-text-default field-name-body field-type-text-with-summary field-label-hidden has-single"><div class="field__items"><div class="field__item"><div class="tex2jax_process"><p>我是搬运工:</p> <p>从这里摘录了一些常见的CAD小问题:</p> <p><a href="https://www.cnblogs.com/JJBox/p/10848766.html">https://www.cnblogs.com/JJBox/p/10848766.html</a></p> <p><strong>一、词典问题集合</strong><br /> 这是一个常见的问题。<br /> 先说解决方案:<br /> 方法1:可以用删除词典的方法: </p> <pre> (dictremove(namedobjdict)"ACAD_DGNLINESTYLECOMP")</pre> <p>方法2:<br /> 如果你有用源泉建筑插件可以用pua命令也可以用桌子带有的工具,<br /> <a href="https://knowledge.autodesk.com/support/autocad/troubleshooting/caas/sfdcarticles/sfdcarticles/AutoCAD-DWG-files-unexpectedly-increase-in-file-size.html" rel="noreferrer noopener" target="_blank">点我</a><br /> 方法3:<br /> 另存R14格式,再保存成你的版本。<br /> 关闭之后再次打开,保存,速度变快。(尝试清理词典)</p> <p>高版本貌似pu就有选项了就可以了...</p> <p>这个问题症状如下:<br /> 1、CAD保存慢:<br /> 2、cad很多线型!(尝试清理词典)CAD不能粘贴,出现_pasteclip:<br /> 3、dgn线型的问题,天正也会导致这个问题(尝试清理词典)<br /> 4、在无天正的CAD状态下打开含有天正图元的DWG,装上天正,然后转旧版本;<br /> 5、CAD每次保存都会出现这个: *警告* 多重从属对象,句柄“FXXXXX”;(尝试清理词典)</p> <p><strong>二、注册问题</strong></p> <p>cad 打开就闪退 用Everything搜索 删除 flexnet 目录下所有文件,这是由于注册文件导致的...需要重新注册...<br /> cad2012~CAD2017打开慢,在注册表编辑器中找到下面位置:<br /> HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R18.2\ACAD-A005:804\InfoCenter\InfoCenterOn 然后把值改为0<br /> 也可能是默认打印机设置为网络打印机,网络打印机关机了,检索不到,造成缓慢...代码的结局方案可以看我另一篇代码解决网络打印机的问题:<a href="https://www.cnblogs.com/JJBox/p/10413783.html" rel="noreferrer noopener" target="_blank">博文</a></p> <p><strong>三、权限问题</strong><br /> win10禁止拖拉程序到绘图区?<br /> 运行regedit,注册表 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA <br /> 然后把值改为0<br /> 但是我告诉你...会导致win10的商店用不了..貌似内置应用也用不了..你可能是正版家庭版win用户,建议更换专业版。。。<br /> win10的cad用ctrl+q会是_copyclip<br /> 把一个cad改成兼容性win7执行就可以了...但是貌似治标不治本,形而上学啊....万一兼容性会导致某些问题呢....<br /> 你可能是正版受害者.....<br /> CAD搜索报错,高版本ctrl+u弹界面<br /> CAD因为会搜索当前dwg路径的所有文件,如果dwg在桌面,那么快捷方式无效会导致报错.<br /> 说实话没找到解决方案,桌子为什么那么蛋疼做这个东西...</p> <p><strong>四、CAD界面跳动</strong><br /> Statusbar,autowrap,0 ;2018关闭命令栏跳动(跳动也可以去关闭坐标显示)</p> <p><strong>五、CAD操作问题</strong><br /> 属性名称不能相同,做成属性块之后会红字显示,并且用ATTSYNC更新时候会出错,拉伸属性的时候会出错.<br /> 有时候在位编辑之后,保存在位编辑了,可是参照面板无法动了,这个时候只要保存一下,然后ctrl+z,就可以解决了..蛮神奇的...<br /> 代码的话看我另一篇<a href="https://www.cnblogs.com/JJBox/p/10367110.html" rel="noreferrer noopener" target="_blank">win32打开参照面板的博文</a>的主函数上面,<br /> 原理就是发送命令,无他...有知道原因的告诉我一下..</p> <p><strong>六、复制粘贴问题</strong><br /> 症状1: cad2008复制粘贴就崩溃但是高版本不会,可能是天正电气的一个bug导致的.<br /> 症状2: 之前也试过,用高版本的CAD清理了之后,就可以,画了一些东西之后就又不行了.<br /> 解答: 要重新用最新版的天正和其匹配的cad进行转旧出来.</p> <p><strong>七、CAD安装问题</strong><br /> cad2007遇到了这种情况<img alt="" height="160" loading="lazy" sizes="(max-width: 408px) 100vw, 408px" src="https://www.highflybird.com/blog/wp-content/uploads/2020/03/cad2007Inst1.png" srcset="https://www.highflybird.com/blog/wp-content/uploads/2020/03/cad2007Inst1.png 408w, https://www.highflybird.com/blog/wp-content/uploads/2020/03/cad2007Inst1-300x118.png 300w" width="408" /><img alt="" height="183" loading="lazy" sizes="(max-width: 734px) 100vw, 734px" src="https://www.highflybird.com/blog/wp-content/uploads/2020/03/cad2007Inst.png" srcset="https://www.highflybird.com/blog/wp-content/uploads/2020/03/cad2007Inst.png 734w, https://www.highflybird.com/blog/wp-content/uploads/2020/03/cad2007Inst-300x75.png 300w, https://www.highflybird.com/blog/wp-content/uploads/2020/03/cad2007Inst-500x125.png 500w" width="734" /><br /> 安装问题安装CAD出现C++2005问题的解决方法,出现此问题,<br /> 原因大部分就是因为安装路径目录或是下载的安装包有中文字体,导致电脑不能识别,只要把中文该成英文字母形式就可以了。<br /> 详见: <a href="https://jingyan.baidu.com/article/6f2f55a163750bb5b93e6c87.html" rel="noreferrer noopener" target="_blank">cad2012安装的问题</a><br /> cad2020安装时候出现1603安装失败:<br /> <img alt="" height="279" loading="lazy" sizes="(max-width: 366px) 100vw, 366px" src="https://www.highflybird.com/blog/wp-content/uploads/2020/03/cad2020Inst.png" srcset="https://www.highflybird.com/blog/wp-content/uploads/2020/03/cad2020Inst.png 366w, https://www.highflybird.com/blog/wp-content/uploads/2020/03/cad2020Inst-300x229.png 300w" width="366" />运行,cmd,输入:"C:\Program Files (x86)\Common Files\Autodesk Shared\AdskLicensing\Current\AdskLicensingService\AdskLicensingService.exe"<br /> CAD2020激活界面问题 许可管理器不起作用或未正确安装<br /> <a href="https://knowledge.autodesk.com/zh-hans/search-result/caas/sfdcarticles/sfdcarticles/CHS/Hybrid-Sleep-or-Hibernate-power-settings-impact-on-Autodesk-2020-product-licensing.html" rel="noreferrer noopener" target="_blank">混合电源设置会影响Autodesk 2020产品许可</a><br /> 下载里面的<a href="http://help.autodesk.com.s3.amazonaws.com/sfdcarticles/kA23A000000hiNG/Autodesk%20Licensing%20Service%20v9.0.3.46.zip" rel="noreferrer noopener" target="_blank">Autodesk Licensing Service v9.0.3.46.zip </a><br /> 安装即可.<br /> 20190713:这个方法并不是很好,似乎是我使用了最新的win1903的最新更新导致? 因为我今天打开又遇到了...<br /> 20191205:开启此服务,注意是不是你的电脑管家或者360优化关闭了相关服务.<br /> 右击我的电脑-管理-服务与应用程序-服务<br /> <img alt="" height="72" loading="lazy" sizes="(max-width: 670px) 100vw, 670px" src="https://www.highflybird.com/blog/wp-content/uploads/2020/03/CADbug1.png" srcset="https://www.highflybird.com/blog/wp-content/uploads/2020/03/CADbug1.png 670w, https://www.highflybird.com/blog/wp-content/uploads/2020/03/CADbug1-300x32.png 300w, https://www.highflybird.com/blog/wp-content/uploads/2020/03/CADbug1-500x54.png 500w" width="670" /><br /> 删除所有注册表,再安装开始-运行-输入“regedit”,打开注册表,找到下面的注册表路径:HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R18.0<br /> 右击鼠标删除 R18.0 整个键值。<br /> 找到下面的注册表路径:<br /> HKEY_CORRENT_user\SOFTWARE\Autodesk\AutoCAD\R18.0<br /> 右击鼠标删除 R18.0 整个键值。<br /> 最后一步,也是最重要的,找到下面的注册表路径:<br /> HKEY_LOCAL_MACHINE\SOFTWARE\Classes\installer\Products 的下面,<br /> 右击鼠标删除“7D2F38751008某某某”开头的键值,删除以后就可以重新安装了 </p> <p><strong>八、图块编辑问题</strong><br /> 很危险的问题****因为进块编辑器,编辑之后就退出,结果一卡,这个块把模型原有的图替代了,会丢失整个模型块表...<br /> 你的图要重画咯~~~~~~<br /> 画图记得备份,备份器c#的代码实现我公开在<a href="https://www.cnblogs.com/JJBox/p/10401833.html" rel="noreferrer noopener" target="_blank">这里</a><br /> 某些人: Acad2014和浩辰2018.... <br /> 瓦蓝:     win7下Acad2012字体问题集合</p> <p><strong>九、字体问题</strong><br /> cad 两台电脑的宋体相同,但是一台电脑保存另一台出现问号,删除KT_ST.ttf,<br /> <a href="https://www.cnblogs.com/JJBox/p/10919629.html" rel="noreferrer noopener" target="_blank">更为详尽的说明</a>和<a href="https://www.cnblogs.com/JJBox/p/10919629.html" rel="noreferrer noopener" target="_blank">代码的解决方案</a><br /> cad 高版本面板乱码,参照面板弹出之后,其他面板会乱码,删除所有cad支持目录的fonst文件夹中的.ttf  .ttc之类的字体,<br /> 包括插件和cad自带目录,高版本不知道为什么桌子自带这样的问题,真的令人头痛.....<br /> 插入或者绑定外部参照出现文字偏移,请不要使用"新宋体.TTF",<br /> 详见<a href="https://www.cnblogs.com/JJBox/p/10226119.html" rel="noreferrer noopener" target="_blank">点我</a> <br /> 什么都不加载,启动cad时也乱码: 系统问题,区域改成新加坡重启后,可以加载了,再改回中国,应当就ok了。</p> <p><strong>十、多窗口问题</strong><br /> CAD一个程序中打开多个窗口设置:<br /> 1、命令行输入SDI,回车,输入0,回车。<br /> 2、点击工具条上“窗口”,再点击下面的选项。<br /> 3、选择不同的在同一窗口打开多个文件的方式。<br /> 4、打开cad工具栏中:工具-选项-系统-(去掉单文档兼容模式前面的勾),然后就好了。<br /> 5、在工具栏的空白处点右键,然后在“选项卡”前面打上对勾,就可以在同一个cad程序里面打开多个cad文件了。</p> <p><strong>十一、打印问题</strong><br /> 打印cad用pdf factory的时候发生打印错误,<br /> 提示:内部错误:PrepareDispatcher was unable to launch the<br /> 发生在联网打印就不行,断网打印就可以...官网的bat我也下载了,也不行.......<br /> 解决:我先是升级win10到1903版本.....<br /> <a href="https://www.microsoft.com/zh-cn/software-download/windows10" rel="noreferrer noopener" target="_blank">升级工具</a><br /> 开心了一个小时之后,我做了局域网共享的操作之后,发现又出现了!所以我肯定了是共享文件夹的方式出现了问题,<br /> 经过查询之后,我发现了要设置防火墙允许通过的列表中:远程桌面,远程协助,远程关机,<br /> 这几个要关掉.貌似就是这几个导致的(只是貌似,因为我先运行了下面的.bat)文件和打印机共享、网络发现、SMBDirect上的文件和打印机共享这几个要开启.<br /> 之前这个仁兄写的是关闭防火墙的,我建议他打开防火墙,所以你们可以用这个工具的最新版来解决局域网共享:<br /> <a href="https://zhuanlan.zhihu.com/p/24178142" rel="noreferrer noopener" target="_blank">局域网共享一键修复.bat</a></p> <p><strong>十二、杂项</strong><br /> 1、cad 菜单选择打开文件的时候,等半天才出现文件打开对话框,<a href="https://knowledge.autodesk.com/support/autocad/troubleshooting/caas/sfdcarticles/sfdcarticles/Browse-dialog-box-slow-to-open.html" rel="noreferrer noopener" target="_blank">点我</a><br /> 2、cad 复制中断产生的不可见图元,无法刷新,<a href="https://www.cnblogs.com/JJBox/p/11464977.html" rel="noreferrer noopener" target="_blank">点我</a><br /> 3、怪事1,CAD在局域网联机工作,一直可以保存的,但是突然变成只读,但是直接关掉CAD会丢失了文件!<br /> 怪事2:CAD在本机工作或联机工作,保存出现错误,生成了文件,但是直接关掉CAD会丢失了文件!<br /> 以上似乎是win7的问题,局域网共享的问题,详细我已经没有测试条件了...建议换win10<br /> 在企业版win中,我发现了加载了自己的插件,然后闪退,致命错误...这就很不解了....换专业版<br /> 在家庭版win中,使用源泉,貌似会发生不可思议的加载失效事情....换专业版<br /> 4、选项卡预览关闭<br /> 将FILETABPREVIEW系统变量的值设为0,将显示方式变为列表,无法关闭预览<br /> 5、autocad打开时多个文件时任务栏也同时出现多个窗口的解决办法:<br /> 打开CAD; 输入taskbar命令;CAD2011默认为1,改为0即可。</p> </div></div></div> </div> <div class="field field-node-field-category field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-category field-type-entity-reference field-label-hidden"><div class="field__items"><div class="field__item field__item--技巧"> <span class="field__item-wrapper"><a href="/drupal/skill" hreflang="zh-hans">技巧</a></span> </div></div> </div> <section class="field field-node--field-blog-comments field-formatter-comment-default field-name-field-blog-comments field-type-comment field-label-above display-mode-threaded comment-bundle-comment comment-wrapper"> <a name="comments"></a></section> Sun, 24 Jan 2021 03:14:52 +0000 highflybird 146 at https://www.highflybird.com/drupal 去教育版戳记讨论及源码(ARX,LISP版) https://www.highflybird.com/drupal/node/133 <span class="field field-name-title field-formatter-string field-type-string field-label-hidden">去教育版戳记讨论及源码(ARX,LISP版)</span> <span class="field field-name-uid field-formatter-author field-type-entity-reference field-label-hidden"><span lang="" about="/drupal/user/1" typeof="schema:Person" property="schema:name" datatype="">highflybird</span></span> <span class="field field-name-created field-formatter-timestamp field-type-created field-label-hidden">周四, 01/21/2021 - 22:02</span> <div class="clearfix text-formatted field field-node--body field-formatter-text-default field-name-body field-type-text-with-summary field-label-hidden has-single"><div class="field__items"><div class="field__item"><div class="tex2jax_process"><p>CAD教育版戳记有时候很讨厌,一旦图中有这个戳记,就会传染到其它图中。就是说从有戳记的图中拷贝到没戳记的,没戳记的也会带上。</p> <p>而且这个戳记不太好消除。</p> <p>对于2015-2018,Autodesk公司似乎已经把这个戳记移除掉了,也就是说,用这些版本的CAD打开图,看不到戳记,也不会弹出那个戳记警告框。</p> <p>保存之后,图中不会再有了(这点我没有每个版本验证)。但该死的是到了2019后,这个又出现了,不知道autodesk公司在玩什么。</p> <p>关于去教育版有很多方式,ARX的方式最有效。我这里提供用了ARX源码。以及附带的生成的ARX程序。</p> <p>这个程序的源码 是从网上的 wdzhangsl 引申过来,特此深表感谢!</p> <p>程序的原理是从数据库指针找到戳记的偏移地址,修改此处的值,便达到了消除。</p> <p>因为原代码有些重复和繁琐,特此精简,并且升级到2019。经过测试,程序有效。</p> <p>因为有些CAD版本我是没办法在自己机器安装,就没有一个个CAD版本进行测试其中的偏移地址。</p> <p>如果有网友能测试到我程序中没有的CAD版本的值,请告诉我或者跟帖。多谢!</p> <p>下面是程序的源码和已经编译好二进制文件的压缩包。欢迎各位捉虫子和提出建议。</p> <p>程序的用法是:加载后,程序会自动消除戳记,也可以用手动输入命令QJYB 来消除。</p> <p>如果你把此程序加载到启动组,以后每当打开有教育版的dwg后,程序会自动消除,你需要做的仅仅是保存文件而已。</p> <p>对于LISp版本,更有这两项突出功能:</p> <p>1、消除打开戳记文件的错误警告框。</p> <p>2、全面兼容各种CAD版本。</p> <p>LISP的代码如下:(需要DynamicWrapperX支持)</p> </p> <div class="geshifilter"> <pre class="cadlisp geshifilter-cadlisp" style="font-family:monospace;"><span style="color: #6699CC; font-style: italic;">;|*************************************************************; 软件作者: Highflybird ; 软件用途: 消除CAD教育版戳记 ; 日期地点: 2019.05.12 深圳 ; 程序语言: AutoLISP,Visual LISP ; 版本号: Ver. 1.0.19.0512 ; ===============================================================; ================================================================ 本软件为开源软件: 以下是开源申明: ---------------------------------------------------------------- 本页面的软件遵照 GPL协议开放源代码,您可以自由传播和修改,在遵照 下面的约束条件的前提下:   一. 只要你在本开源软件的每一副本上明显和恰当地出版版权声明,保持 此许可证的声明和没有担保的声明完整无损,并和程序一起给每个其 他的程序接受者一份许可证的副本,你就可用任何媒体复制和发布你 收到的原始程序的源代码。你也可以为转让副本的实际行动收取一定 费用,但必须事先得到的同意。 二. 你可以修改本开源软件的一个或几个副本或程序的任何部分,以此形 成基于程序的作品。只要你同时满足下面的所有条件,你就可以按前 面第一款的要求复制和发布这一经过修改的程序或作品。 1.你必须在修改的文件中附有明确说明:你修改了这一文件及具体的修 改日期。 2.你必须使你发布或出版的作品(它包含程序的全部或一部分,或包含 由程序的全部或部分衍生的作品)允许第三方作为整体按许可证条款 免费使用。 3.如果修改的程序在运行时以交互方式读取命令,你必须使它在开始进 入常规的交互使用方式时打印或显示声明: 包括适当的版权声明和没 有担保的声明(或者你提供担保的声明);用户可以按此许可证条款 重新发布程序的说明;并告诉用户如何看到这一许可证的副本。(例 外的情况: 如果原始程序以交互方式工作,它并不打印这样的声明, 你的基于程序的作品也就不用打印声明。 三. 只要你遵循一、二条款规定,您就可以自由使用并传播本源代码,但 必须原封不动地保留原作者信息。 ================================================================ **************************************************************|;</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> c:QJYB <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/</span> acdb addr DWX flag hMod isOK name pEMR pFlag hPROC Code CADVer OFFSET PID pNEW VMAP<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> dwx <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-create-object</span> <span style="color: #9933CC;">"DynamicWrapperX"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">progn</span> <span style="color: #336699; font-weight: bold;">(</span>DWX:Register DWX<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> acdb <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strcat</span> <span style="color: #9933CC;">"acdb"</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">substr</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">getvar</span> <span style="color: #9933CC;">"acadver"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">1</span> <span style="color: #FF9900;">2</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #9933CC;">".dll"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> hMod <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'GetModuleHandle acdb<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span>Is64Bit<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> Name <span style="color: #9933CC;">"?isEMR@AcDbDatabase@@QEBA_NXZ"</span> pEMR <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'GetProcAddress hMod name<span style="color: #336699; font-weight: bold;">)</span> vMap '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">172</span> . <span style="color: #9933CC;">"180B"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">180</span> . <span style="color: #9933CC;">"800B"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">181</span> . <span style="color: #9933CC;">"880B"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">182</span> . <span style="color: #9933CC;">"900B"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">190</span> . <span style="color: #9933CC;">"A80B"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">191</span> . <span style="color: #9933CC;">"B00B"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">230</span> . <span style="color: #9933CC;">"A00B"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">231</span> . <span style="color: #9933CC;">"A00B"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> Name <span style="color: #9933CC;">"?isEMR@AcDbDatabase@@QBE_NXZ"</span> pEMR <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'GetProcAddress hMod name<span style="color: #336699; font-weight: bold;">)</span> vMap '<span style="color: #336699; font-weight: bold;">(</span><span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">150</span> . <span style="color: #9933CC;">"A406"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">160</span> . <span style="color: #9933CC;">"D406"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">161</span> . <span style="color: #9933CC;">"D406"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">162</span> . <span style="color: #9933CC;">"D406"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">170</span> . <span style="color: #9933CC;">"DC07"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">171</span> . <span style="color: #9933CC;">"2408"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">172</span> . <span style="color: #9933CC;">"3408"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">180</span> . <span style="color: #9933CC;">"6C08"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">181</span> . <span style="color: #9933CC;">"7408"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">182</span> . <span style="color: #9933CC;">"7C08"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">190</span> . <span style="color: #9933CC;">"8408"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">191</span> . <span style="color: #9933CC;">"8408"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #FF9900;">230</span> . <span style="color: #9933CC;">"8408"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> CADVer <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">fix</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">*</span> <span style="color: #FF9900;">10</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">atof</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">substr</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">getvar</span> <span style="color: #9933CC;">"acadver"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #FF9900;">1</span> <span style="color: #FF9900;">4</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> offset <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">cdr</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">assoc</span> CADVer vMap<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> Func <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">read</span> name<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">zerop</span> pEMR<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>你运行的CAD版本可能是2015-2018,它会自动消除教育版!"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">and</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/=</span> <span style="color: #FF9900;">0</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pID <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'GetCurrentProcessId<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/=</span> <span style="color: #FF9900;">0</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> hProc <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'OpenProcess <span style="color: #FF9900;">2035711</span> <span style="color: #FF9900;">0</span> pID<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;2035711 = PROCESS_ALL_ACCESS = 0x1F0FFF;</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">progn</span> <span style="color: #6699CC; font-style: italic;">;(FindOffset DWX acdb name)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span>Is64Bit<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> Code <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strcat</span> <span style="color: #9933CC;">"488B490833C08981"</span> offset <span style="color: #9933CC;">"00003C00C3"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> Code <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strcat</span> <span style="color: #9933CC;">"8B490433C08981"</span> offset <span style="color: #9933CC;">"00003C00C3"</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pFlag <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'MemAlloc <span style="color: #FF9900;">4</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> isOK <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'VirtualProtect pEMR <span style="color: #FF9900;">30</span> <span style="color: #FF9900;">4</span> pFlag<span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;PAGE_READWRITE = 0x4;</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">/=</span> isOK <span style="color: #FF9900;">0</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">setq</span> pNew <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'MemWrite Code pEMR<span style="color: #336699; font-weight: bold;">)</span> flag <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'NumGet pFlag<span style="color: #336699; font-weight: bold;">)</span> isOK <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'VirtualProtect pEMR <span style="color: #FF9900;">30</span> flag pFlag<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'MemFree pFlag<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'CloseHandle hProc<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">if</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">zerop</span> isOK<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>程序运行失败!"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>程序运行成功!"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>你没有注册DynamicWrapperX!或者没有权限!"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;; 功能: 检查CAD是否为64位。 </span> <span style="color: #6699CC; font-style: italic;">;;; 输入: 无。 </span> <span style="color: #6699CC; font-style: italic;">;;; 输出: CAD如果是64位则返回T,否则返回nil。 </span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> Is64Bit <span style="color: #336699; font-weight: bold;">(</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #66cc66; font-weight: bold;">=</span> <span style="color: #FF9900;">27</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">strlen</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">VL-PRINC-TO-STRING</span> <span style="color: #66cc66; font-weight: bold;">+</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #6699CC; font-style: italic;">;;; 功能: 注册一些与内存相关函数 </span> <span style="color: #6699CC; font-style: italic;">;;; 输入: DynamicWrapperX对象。 </span> <span style="color: #6699CC; font-style: italic;">;;; 输出: 无。 </span> <span style="color: #6699CC; font-style: italic;">;;;=============================================================</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">defun</span> DWX:Register <span style="color: #336699; font-weight: bold;">(</span>DWX<span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"KERNEL32"</span> <span style="color: #9933CC;">"LoadLibrary"</span> <span style="color: #9933CC;">"i=s"</span> <span style="color: #9933CC;">"r=p"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"KERNEL32"</span> <span style="color: #9933CC;">"FreeLibrary"</span> <span style="color: #9933CC;">"i=p"</span> <span style="color: #9933CC;">"r=l"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"KERNEL32"</span> <span style="color: #9933CC;">"GetCurrentProcessId"</span> <span style="color: #9933CC;">"r=l"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"KERNEL32"</span> <span style="color: #9933CC;">"OpenProcess"</span> <span style="color: #9933CC;">"i=lll"</span> <span style="color: #9933CC;">"r=p"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"KERNEL32"</span> <span style="color: #9933CC;">"VirtualProtect"</span> <span style="color: #9933CC;">"i=pllp"</span> <span style="color: #9933CC;">"r=l"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"KERNEL32"</span> <span style="color: #9933CC;">"VirtualProtectEx"</span> <span style="color: #9933CC;">"i=hpllp"</span> <span style="color: #9933CC;">"r=l"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"KERNEL32"</span> <span style="color: #9933CC;">"VirtualQueryEx"</span> <span style="color: #9933CC;">"i=hppl"</span> <span style="color: #9933CC;">"r=l"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"KERNEL32"</span> <span style="color: #9933CC;">"ReadProcessMemory"</span> <span style="color: #9933CC;">"i=hpplp"</span> <span style="color: #9933CC;">"r=l"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"KERNEL32"</span> <span style="color: #9933CC;">"WriteProcessMemory"</span> <span style="color: #9933CC;">"i=hpplp"</span> <span style="color: #9933CC;">"r=l"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"KERNEL32"</span> <span style="color: #9933CC;">"GetProcAddress"</span> <span style="color: #9933CC;">"i=hs"</span> <span style="color: #9933CC;">"r=p"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"KERNEL32"</span> <span style="color: #9933CC;">"GetModuleHandle"</span> <span style="color: #9933CC;">"i=s"</span> <span style="color: #9933CC;">"r=h"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"KERNEL32"</span> <span style="color: #9933CC;">"GetLastError"</span> <span style="color: #9933CC;">"r=l"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vlax-invoke</span> DWX 'Register <span style="color: #9933CC;">"KERNEL32"</span> <span style="color: #9933CC;">"CloseHandle"</span> <span style="color: #9933CC;">"i=h"</span> <span style="color: #9933CC;">"r=l"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">)</span>   <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">vl-load-com</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>帮助说明: 程序运行命令是QJYB。注意: 请运行在打开有教育版戳记的图形前!!! "</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>命令运行一次后无需再输入,程序会自动消除教育版戳记了,你只需保存图即可。"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span> <span style="color: #9933CC;">"<span style="color: #000099; font-weight: bold;">\n</span>如果你希望每次都能用,请加载到启动组。"</span><span style="color: #336699; font-weight: bold;">)</span> <span style="color: #336699; font-weight: bold;">(</span><span style="color: #339933;font-weight: bold;">princ</span><span style="color: #336699; font-weight: bold;">)</span></pre></div> <p>ARX的核心代码如下:</p> </p> <div class="geshifilter"> <pre class="cpp geshifilter-cpp" style="font-family:monospace;"><span style="color: #339900;">#include "stdafx.h"</span> <span style="color: #339900;">#include "GetProcess.h"</span> <span style="color: #339900;">#include "GetFunctionAddress.h"</span> <span style="color: #339900;">#include "RemoveEDU.h"</span>   byte OffsetAddress32<span style="color: #008000;">[</span><span style="color: #0000dd;">6</span><span style="color: #008000;">]</span><span style="color: #008000;">[</span><span style="color: #0000dd;">6</span><span style="color: #008000;">]</span><span style="color: #000080;">=</span><span style="color: #008000;">{</span> <span style="color: #008000;">{</span><span style="color: #208080;">0xa4</span>,<span style="color: #208080;">0x06</span>,<span style="color: #208080;">0xa4</span>,<span style="color: #208080;">0x06</span>,<span style="color: #208080;">0xa4</span>,<span style="color: #208080;">0x06</span><span style="color: #008000;">}</span>,<span style="color: #666666;">//R15</span> <span style="color: #008000;">{</span><span style="color: #208080;">0xd4</span>,<span style="color: #208080;">0x06</span>,<span style="color: #208080;">0xd4</span>,<span style="color: #208080;">0x06</span>,<span style="color: #208080;">0xd4</span>,<span style="color: #208080;">0x06</span><span style="color: #008000;">}</span>,<span style="color: #666666;">//R16</span> <span style="color: #008000;">{</span><span style="color: #208080;">0xdc</span>,<span style="color: #208080;">0x07</span>,<span style="color: #208080;">0x24</span>,<span style="color: #208080;">0x08</span>,<span style="color: #208080;">0x34</span>,<span style="color: #208080;">0x08</span><span style="color: #008000;">}</span>,<span style="color: #666666;">//R17</span> <span style="color: #008000;">{</span><span style="color: #208080;">0x6c</span>,<span style="color: #208080;">0x08</span>,<span style="color: #208080;">0x74</span>,<span style="color: #208080;">0x08</span>,<span style="color: #208080;">0x7c</span>,<span style="color: #208080;">0x08</span><span style="color: #008000;">}</span>,<span style="color: #666666;">//R18</span> <span style="color: #008000;">{</span><span style="color: #208080;">0x84</span>,<span style="color: #208080;">0x08</span>,<span style="color: #208080;">0x84</span>,<span style="color: #208080;">0x08</span>,<span style="color: #208080;">0x84</span>,<span style="color: #208080;">0x08</span><span style="color: #008000;">}</span>,<span style="color: #666666;">//R19</span> <span style="color: #008000;">{</span><span style="color: #208080;">0x84</span>,<span style="color: #208080;">0x08</span>,<span style="color: #208080;">0x84</span>,<span style="color: #208080;">0x08</span>,<span style="color: #208080;">0x84</span>,<span style="color: #208080;">0x08</span><span style="color: #008000;">}</span>,<span style="color: #666666;">//R23</span> <span style="color: #008000;">}</span><span style="color: #008080;">;</span> byte OffsetAddress64<span style="color: #008000;">[</span><span style="color: #0000dd;">4</span><span style="color: #008000;">]</span><span style="color: #008000;">[</span><span style="color: #0000dd;">6</span><span style="color: #008000;">]</span><span style="color: #000080;">=</span><span style="color: #008000;">{</span> <span style="color: #008000;">{</span><span style="color: #208080;">0x18</span>,<span style="color: #208080;">0x0b</span>,<span style="color: #208080;">0x18</span>,<span style="color: #208080;">0x0b</span>,<span style="color: #208080;">0x18</span>,<span style="color: #208080;">0x0b</span><span style="color: #008000;">}</span>,<span style="color: #666666;">//R17</span> <span style="color: #008000;">{</span><span style="color: #208080;">0x80</span>,<span style="color: #208080;">0x0b</span>,<span style="color: #208080;">0x88</span>,<span style="color: #208080;">0x0b</span>,<span style="color: #208080;">0x90</span>,<span style="color: #208080;">0x0b</span><span style="color: #008000;">}</span>,<span style="color: #666666;">//R18</span> <span style="color: #008000;">{</span><span style="color: #208080;">0xa8</span>,<span style="color: #208080;">0x0b</span>,<span style="color: #208080;">0xb0</span>,<span style="color: #208080;">0x0b</span>,<span style="color: #208080;">0xb8</span>,<span style="color: #208080;">0x0b</span><span style="color: #008000;">}</span>,<span style="color: #666666;">//R19</span> <span style="color: #008000;">{</span><span style="color: #208080;">0xa0</span>,<span style="color: #208080;">0x0b</span>,<span style="color: #208080;">0xa0</span>,<span style="color: #208080;">0x0b</span>,<span style="color: #208080;">0xa0</span>,<span style="color: #208080;">0x0b</span><span style="color: #008000;">}</span>,<span style="color: #666666;">//R23</span> <span style="color: #008000;">}</span><span style="color: #008080;">;</span>   <span style="color: #0000ff;">int</span> RemoveEducationStamp<span style="color: #008000;">(</span>WNDINFO <span style="color: #000040;">&</span> wi<span style="color: #008000;">)</span> <span style="color: #008000;">{</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">(</span>wi.<span style="color: #007788;">ActiveDoc</span><span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span> <span style="color: #0000ff;">return</span> FALSE<span style="color: #008080;">;</span> <span style="color: #0000ff;">int</span> ret <span style="color: #000080;">=</span> FALSE<span style="color: #008080;">;</span> CAcadUtility uti<span style="color: #000080;">=</span>wi.<span style="color: #007788;">ActiveDoc</span>.<span style="color: #007788;">get_Utility</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #666666;">//获取isEMR函数的RVA地址</span> INT_PTR offsetAddr <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> LPCSTR funcName <span style="color: #000080;">=</span> wi.<span style="color: #007788;">is64bit</span> <span style="color: #008080;">?</span> <span style="color: #FF0000;">"?isEMR@AcDbDatabase@@QEBA_NXZ"</span> <span style="color: #008080;">:</span> <span style="color: #FF0000;">"?isEMR@AcDbDatabase@@QBE_NXZ"</span><span style="color: #008080;">;</span>   HMODULE hDLL <span style="color: #000080;">=</span> LoadLibraryEx<span style="color: #008000;">(</span>wi.<span style="color: #007788;">strAcDbPath</span>,<span style="color: #0000dd;">0</span>,DONT_RESOLVE_DLL_REFERENCES<span style="color: #008000;">)</span><span style="color: #008080;">;</span><span style="color: #666666;">// </span> LPVOID pIsEMR <span style="color: #000080;">=</span> GetProcAddress<span style="color: #008000;">(</span>hDLL,funcName<span style="color: #008000;">)</span><span style="color: #008080;">;</span> FreeLibrary<span style="color: #008000;">(</span>hDLL<span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">(</span>pIsEMR <span style="color: #000080;">==</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span> pIsEMR <span style="color: #000080;">=</span> LoadFuncBase<span style="color: #008000;">(</span>wi.<span style="color: #007788;">strAcDbPath</span>,funcName,hDLL<span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #008000;">}</span>   <span style="color: #0000ff;">if</span> <span style="color: #008000;">(</span>pIsEMR <span style="color: #000080;">==</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span> FUNCTION_ADDRESS funcSet<span style="color: #008080;">;</span> ret <span style="color: #000080;">=</span> getFuncAddr<span style="color: #008000;">(</span>wi.<span style="color: #007788;">strAcDbPath</span>,funcSet<span style="color: #008000;">)</span><span style="color: #008080;">;</span> FUNCTION_ADDRESS<span style="color: #008080;">::</span><span style="color: #007788;">iterator</span> itr <span style="color: #000080;">=</span> funcSet.<span style="color: #007788;">find</span><span style="color: #008000;">(</span>funcName<span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">(</span>itr <span style="color: #000080;">==</span> funcSet.<span style="color: #007788;">end</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span> uti.<span style="color: #007788;">Prompt</span><span style="color: #008000;">(</span>_T<span style="color: #008000;">(</span><span style="color: #FF0000;">"找不到教育版相关函数!可能需要以管理员身份运行此程序,或者CAD版本是2015-2018.<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">return</span> FALSE<span style="color: #008080;">;</span> <span style="color: #008000;">}</span> offsetAddr <span style="color: #000080;">=</span> itr<span style="color: #000040;">-</span><span style="color: #000080;">></span>second<span style="color: #008080;">;</span> pIsEMR <span style="color: #000080;">=</span> LPVOID<span style="color: #008000;">(</span><span style="color: #008000;">(</span>INT_PTR<span style="color: #008000;">)</span>wi.<span style="color: #007788;">hAcDb</span> <span style="color: #000040;">+</span> offsetAddr<span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #666666;">//操纵数据库</span> <span style="color: #008000;">}</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">{</span> offsetAddr <span style="color: #000080;">=</span> <span style="color: #008000;">(</span>INT_PTR<span style="color: #008000;">)</span>pIsEMR <span style="color: #000040;">-</span> <span style="color: #008000;">(</span>INT_PTR<span style="color: #008000;">)</span>hDLL<span style="color: #008080;">;</span> pIsEMR <span style="color: #000080;">=</span> LPVOID<span style="color: #008000;">(</span><span style="color: #008000;">(</span>INT_PTR<span style="color: #008000;">)</span>wi.<span style="color: #007788;">hAcDb</span> <span style="color: #000040;">+</span> offsetAddr<span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #666666;">//操纵数据库 </span> <span style="color: #008000;">}</span>   <span style="color: #666666;">//以写的方式打开CAD进程</span> <span style="color: #666666;">//HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, wi.dwProcessId); //权限要求太高,可能在某些机器上运行不了</span> HANDLE hProcess <span style="color: #000080;">=</span> OpenProcess<span style="color: #008000;">(</span>PROCESS_VM_OPERATION <span style="color: #000040;">|</span> PROCESS_VM_READ <span style="color: #000040;">|</span> PROCESS_QUERY_INFORMATION <span style="color: #000040;">|</span> PROCESS_VM_WRITE, FALSE, wi.<span style="color: #007788;">dwProcessId</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">(</span>hProcess <span style="color: #000080;">==</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span> uti.<span style="color: #007788;">Prompt</span><span style="color: #008000;">(</span>_T<span style="color: #008000;">(</span><span style="color: #FF0000;">"无法打开CAD进程写入!<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">return</span> FALSE<span style="color: #008080;">;</span> <span style="color: #008000;">}</span>   <span style="color: #0000ff;">const</span> DWORD bWritten <span style="color: #000080;">=</span> <span style="color: #0000dd;">128</span><span style="color: #008080;">;</span> byte pEAX <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> SIZE_T dwNumberOfBytes <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>   CString strTemp <span style="color: #000080;">=</span> wi.<span style="color: #007788;">strVersion</span>.<span style="color: #007788;">Mid</span><span style="color: #008000;">(</span><span style="color: #0000dd;">1</span>,<span style="color: #0000dd;">2</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">int</span> nMajorVersion <span style="color: #000080;">=</span> _ttoi<span style="color: #008000;">(</span>strTemp.<span style="color: #007788;">GetBuffer</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">(</span>nMajorVersion<span style="color: #000080;">></span><span style="color: #0000dd;">22</span><span style="color: #008000;">)</span> nMajorVersion<span style="color: #000040;">-</span><span style="color: #000080;">=</span><span style="color: #0000dd;">3</span><span style="color: #008080;">;</span> strTemp <span style="color: #000080;">=</span> wi.<span style="color: #007788;">strVersion</span>.<span style="color: #007788;">Mid</span><span style="color: #008000;">(</span><span style="color: #0000dd;">4</span>,<span style="color: #0000dd;">1</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">int</span> nMinorVersion <span style="color: #000080;">=</span> _ttoi<span style="color: #008000;">(</span>strTemp.<span style="color: #007788;">GetBuffer</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span>   <span style="color: #0000ff;">if</span> <span style="color: #008000;">(</span>wi.<span style="color: #007788;">is64bit</span><span style="color: #008000;">)</span> <span style="color: #008000;">{</span> byte AsmCode<span style="color: #008000;">[</span><span style="color: #0000dd;">15</span><span style="color: #008000;">]</span> <span style="color: #000080;">=</span> <span style="color: #008000;">{</span><span style="color: #208080;">0x48</span>,<span style="color: #208080;">0x8B</span>,<span style="color: #208080;">0x49</span>,<span style="color: #208080;">0x08</span>,<span style="color: #208080;">0x33</span>,<span style="color: #208080;">0xC0</span>,<span style="color: #208080;">0x89</span>,<span style="color: #208080;">0x81</span>,<span style="color: #208080;">0x00</span>,<span style="color: #208080;">0x00</span>,<span style="color: #208080;">0x00</span>,<span style="color: #208080;">0x00</span>,<span style="color: #208080;">0x3C</span>,<span style="color: #208080;">0x00</span>,<span style="color: #208080;">0xC3</span><span style="color: #008000;">}</span><span style="color: #008080;">;</span> nMajorVersion <span style="color: #000080;">=</span> nMajorVersion<span style="color: #000040;">-</span><span style="color: #0000dd;">17</span><span style="color: #008080;">;</span> AsmCode<span style="color: #008000;">[</span><span style="color: #0000dd;">8</span><span style="color: #008000;">]</span><span style="color: #000080;">=</span>OffsetAddress64<span style="color: #008000;">[</span>nMajorVersion<span style="color: #008000;">]</span><span style="color: #008000;">[</span><span style="color: #0000dd;">2</span><span style="color: #000040;">*</span>nMinorVersion<span style="color: #008000;">]</span><span style="color: #008080;">;</span> AsmCode<span style="color: #008000;">[</span><span style="color: #0000dd;">9</span><span style="color: #008000;">]</span><span style="color: #000080;">=</span>OffsetAddress64<span style="color: #008000;">[</span>nMajorVersion<span style="color: #008000;">]</span><span style="color: #008000;">[</span><span style="color: #0000dd;">2</span><span style="color: #000040;">*</span>nMinorVersion<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: #008000;">]</span><span style="color: #008080;">;</span> ret <span style="color: #000080;">=</span> WriteProcessMemory<span style="color: #008000;">(</span>hProcess,pIsEMR,AsmCode,<span style="color: #0000dd;">sizeof</span><span style="color: #008000;">(</span>AsmCode<span style="color: #008000;">)</span>,<span style="color: #000040;">&</span>dwNumberOfBytes<span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #008000;">}</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">{</span> byte AsmCode<span style="color: #008000;">[</span><span style="color: #0000dd;">14</span><span style="color: #008000;">]</span> <span style="color: #000080;">=</span> <span style="color: #008000;">{</span><span style="color: #208080;">0x8B</span>,<span style="color: #208080;">0x49</span>,<span style="color: #208080;">0x04</span>,<span style="color: #208080;">0x33</span>,<span style="color: #208080;">0xC0</span>,<span style="color: #208080;">0x89</span>,<span style="color: #208080;">0x81</span>,<span style="color: #208080;">0x00</span>,<span style="color: #208080;">0x00</span>,<span style="color: #208080;">0x00</span>,<span style="color: #208080;">0x00</span>,<span style="color: #208080;">0x3C</span>,<span style="color: #208080;">0x00</span>,<span style="color: #208080;">0xC3</span><span style="color: #008000;">}</span><span style="color: #008080;">;</span> nMajorVersion <span style="color: #000080;">=</span> nMajorVersion<span style="color: #000040;">-</span><span style="color: #0000dd;">15</span><span style="color: #008080;">;</span> AsmCode<span style="color: #008000;">[</span><span style="color: #0000dd;">7</span><span style="color: #008000;">]</span><span style="color: #000080;">=</span>OffsetAddress32<span style="color: #008000;">[</span>nMajorVersion<span style="color: #008000;">]</span><span style="color: #008000;">[</span><span style="color: #0000dd;">2</span><span style="color: #000040;">*</span>nMinorVersion<span style="color: #008000;">]</span><span style="color: #008080;">;</span> AsmCode<span style="color: #008000;">[</span><span style="color: #0000dd;">8</span><span style="color: #008000;">]</span><span style="color: #000080;">=</span>OffsetAddress32<span style="color: #008000;">[</span>nMajorVersion<span style="color: #008000;">]</span><span style="color: #008000;">[</span><span style="color: #0000dd;">2</span><span style="color: #000040;">*</span>nMinorVersion<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: #008000;">]</span><span style="color: #008080;">;</span> ret <span style="color: #000080;">=</span> WriteProcessMemory<span style="color: #008000;">(</span>hProcess,pIsEMR,AsmCode,<span style="color: #0000dd;">sizeof</span><span style="color: #008000;">(</span>AsmCode<span style="color: #008000;">)</span>,<span style="color: #000040;">&</span>dwNumberOfBytes<span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #008000;">}</span>   <span style="color: #0000ff;">if</span> <span style="color: #008000;">(</span><span style="color: #000040;">!</span>ret<span style="color: #008000;">)</span> <span style="color: #008000;">{</span> uti.<span style="color: #007788;">Prompt</span><span style="color: #008000;">(</span>_T<span style="color: #008000;">(</span><span style="color: #FF0000;">"修改内存模式失败!<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #008000;">}</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">{</span> wi.<span style="color: #007788;">isRemoved</span> <span style="color: #000080;">=</span> <span style="color: #0000ff;">true</span><span style="color: #008080;">;</span> <span style="color: #008000;">}</span>   CloseHandle<span style="color: #008000;">(</span>hProcess<span style="color: #008000;">)</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">return</span> ret<span style="color: #008080;">;</span> <span style="color: #008000;">}</span></pre></div> </div></div></div> </div> <div class="field field-node-field-blog-tags field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-blog-tags field-type-entity-reference field-label-above"><h3 class="field__label">标签</h3><div class="field__items"><div class="field__item field__item--去教育版戳记-arx-lisp"> <span class="field__item-wrapper"><a href="/drupal/taxonomy/term/38" hreflang="zh-hans">去教育版戳记 ARX LISP</a></span> </div></div> </div> <div class="field field-node-field-category field-entity-reference-type-taxonomy-term field-formatter-entity-reference-label field-name-field-category field-type-entity-reference field-label-hidden"><div class="field__items"><div class="field__item field__item--编程"> <span class="field__item-wrapper"><a href="/drupal/programming" hreflang="zh-hans">编程</a></span> </div></div> </div> <section class="field field-node--field-blog-comments field-formatter-comment-default field-name-field-blog-comments field-type-comment field-label-above display-mode-threaded comment-bundle-comment comment-wrapper"> <a name="comments"></a></section> Thu, 21 Jan 2021 14:02:26 +0000 highflybird 133 at https://www.highflybird.com/drupal