欢迎来到天天文库
浏览记录
ID:38260322
大小:1.53 MB
页数:7页
时间:2019-06-07
《solidworks二次开发》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、ParametricDrawingReportName:NO.:ExpectedScore:Introductionofobjecttobedrawn:ThisdesigncontentisthatUsingthesoftwaredevelopmentlanguageVBAtodoaParametricdesignaboutastandardbolt。The2dfigureofTheboltcanbegeneratedautomaticallyinAUTOCADsoftwarewindowbyente
2、ringlengthanddiameterofthebolt。Designideas:Inordertoavoidthedifficultofdefiningvariablesanddrawastraightline,IuseMultistagelinecommandtodrawmostofthethecontourlinebolt,calculatingthecoordinatesofeachturningpoint.asshowninthefigure:Thepointsp1top16arecon
3、nectedwithmultistagelineinturn,andconnectedpt1andpt2,pt3andpt4,pt5andpt7,pt6andpt8,pt9andpt10withline.Figure1Inputthecodeinautocadvbaplugin,asshowninthefigure:ToruntheprogramandtheinputparametersInputthexcoordinateofpt0Inputtheycoordinateofpt0Inputthebo
4、ltdiameterdInputthelengthoftheboltApplicationresults:Sourceprogram:PrivateSubluoshuan()DimCuslineAsAcadLine'定义三种线型DimXislineAsAcadLineDimDhlineAsAcadLineDimpt0(2)AsDouble,dAsVariant,LAsVariant'定义插入点,直径和长度Dimpt1(2)AsDouble'定义不能用多段线一次性画出的直线端点Dimpt2(2)AsDo
5、ubleDimpt3(2)AsDoubleDimpt4(2)AsDoubleDimpt5(2)AsDoubleDimpt6(2)AsDoubleDimpt7(2)AsDoubleDimpt8(2)AsDoubleDimpt9(2)AsDoubleDimpt10(2)AsDoubleDimp(31)AsDouble'定义画多段线的数组DimobjLWPlineAsAcadLWPolyline'定义多段线DimentryAsAcadLineTypeDimfindAsBooleanDimxianx(2)As
6、StringDimiAsIntegerfind=Falsexianx(0)="BORDER"'将需要的三种线型进行赋值,方便进行查找xianx(1)="CENTER"xianx(2)="DASHDOT"Fori=0To2ForEachentryInThisDrawing.Linetypes'经过循环对比,看线型是否存在IfStrComp(entry.Name,xianx(i),1)=0Thenfind=TrueExitForEndIfNextIfNot(find)Then'如果不存在则加载此线型Thi
7、sDrawing.Linetypes.Loadxianx(i),"acadiso.lin"EndIfNextDimobjLayerAsAcadLayerSetobjLayer=ThisDrawing.Layers.Add("粗实线")'添加粗实线线型对应的图层objLayer.Color=7'设置图层颜色为黑色objLayer.Linetype="Continuous"'设置图层线型objLayer.Lineweight=acLnWt030'设置图层线宽为0.25ThisDrawing.ActiveL
8、ayer=objLayer'激活粗实线图层pt0(0)=Val(InputBox("输入pt0的x坐标"))pt0(1)=Val(InputBox("输入pt0的y坐标"))pt0(2)=0d=Val(InputBox("输入d"))L=Val(InputBox("输入长度L"))P(0)=pt0(0):p(1)=pt0(1)'图中P1点坐标(p0,p1)p(2)=p(0):p(3)=p(1)+0.25*d'图中P2点坐标(p2,p3)p(4)=pt0(
此文档下载收益归作者所有