iCAx开思工具箱

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 25329|回复: 6
打印 上一主题 下一主题

【讨论】SolidEdge二次开发的高山请进!

[复制链接]
跳转到指定楼层
楼主
发表于 2004-4-28 08:54:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
怎么能在孔的上面添加螺纹。很苦恼~
下面的就是不行,错在那了?请指教
Private Sub Form_Load()
Dim objApp As SolidEdgeFramework.Application
Dim objDoc As SolidEdgePart.PartDocument
Dim objModel As SolidEdgePart.Model
Dim objProfArr(1 To 2) As SolidEdgePart.Profile
Dim objHoleProf As SolidEdgePart.Profile
Dim objHol As SolidEdgePart.Hole
Dim objHolData As SolidEdgePart.HoleData
  
Dim objThread As SolidEdgePart.Thread
Dim objHolData1 As SolidEdgePart.HoleData
Dim objEdgs As Object
Dim objFaces As Object
  
Dim objLines As SolidEdgeFrameworkSupport.Lines2d
Dim objRelns As SolidEdgeFrameworkSupport.Relations2d
Dim objApplication As SolidEdgeFramework.Application
Dim objRefPln As SolidEdgePart.RefPlane
Dim lngStatus As Long
' Report errors
Const PI = 3.14159265358979
' Create/get the application with specific settings
On Error Resume Next
Set objApp = GetObject(, "SolidEdge.Application")
'If Err Then
'Err.Clear
'Set objApp = CreateObject("SolidEdge.Application")
Set objDoc = objApp.Documents.Add("SolidEdge.PartDocument")
objApp.Visible = True
'Else
Set objDoc = objApp.ActiveDocument
'End If
'Draw the Base Profile
Set objProfArr(1) = objDoc.ProfileSets.Add.Profiles.Add(pRefPlaneDisp:= _
objDoc.RefPlanes(3))
Set objLines = objProfArr(1).Lines2d
Call objLines.AddBy2Points(X1:=0, Y1:=0, X2:=0.08, Y2:=0)
Call objLines.AddBy2Points(X1:=0.08, Y1:=0, X2:=0.08, Y2:=0.06)
Call objLines.AddBy2Points(X1:=0.08, Y1:=0.06, X2:=0.064, Y2:=0.06)
Call objLines.AddBy2Points(X1:=0.064, Y1:=0.06, X2:=0.064, Y2:=0.02)
Call objLines.AddBy2Points(X1:=0.064, Y1:=0.02, X2:=0.048, Y2:=0.02)
Call objLines.AddBy2Points(X1:=0.048, Y1:=0.02, X2:=0.048, Y2:=0.06)
Call objLines.AddBy2Points(X1:=0.048, Y1:=0.06, X2:=0.032, Y2:=0.06)
Call objLines.AddBy2Points(X1:=0.032, Y1:=0.06, X2:=0.032, Y2:=0.02)
Call objLines.AddBy2Points(X1:=0.032, Y1:=0.02, X2:=0.016, Y2:=0.02)
Call objLines.AddBy2Points(X1:=0.016, Y1:=0.02, X2:=0.016, Y2:=0.06)
Call objLines.AddBy2Points(X1:=0.016, Y1:=0.06, X2:=0, Y2:=0.06)
Call objLines.AddBy2Points(X1:=0, Y1:=0.06, X2:=0, Y2:=0)
' Define Relations among the Line objects to make the Profile closed
Set objRelns = objProfArr(1).Relations2d
Call objRelns.AddKeypoint(Object1:=objLines(1), Index1:=igLineEnd, Object2:=objLines(2), Index2:=igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines(2), Index1:=igLineEnd, Object2:=objLines(3), Index2:=igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines(3), Index1:=igLineEnd, Object2:=objLines(4), Index2:=igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines(4), Index1:=igLineEnd, Object2:=objLines(5), Index2:=igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines(5), Index1:=igLineEnd, Object2:=objLines(6), Index2:=igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines(6), Index1:=igLineEnd, Object2:=objLines(7), Index2:=igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines(7), Index1:=igLineEnd, Object2:=objLines(8), Index2:=igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines(8), Index1:=igLineEnd, Object2:=objLines(9), Index2:=igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines(9), Index1:=igLineEnd, Object2:=objLines(10), Index2:=igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines(10), Index1:=igLineEnd, Object2:=objLines(11), Index2:=igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines(11), Index1:=igLineEnd, Object2:=objLines(12), Index2:=igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines(12), Index1:=igLineEnd, Object2:=objLines(1), Index2:=igLineStart)
' Check for the Profile Validity
lngStatus = objProfArr(1).End(ValidationCriteria:=igProfileClosed)
If lngStatus <> 0 Then
MsgBox ("rofile not closed")
End If
'Create the Base Extruded Protrusion Feature
Set objModel = objDoc.Models.AddFiniteExtrudedProtrusion(NumberOfProfiles:=1, _
profileArray:=objProfArr, Profileplaneside:= _
igRight, ExtrusionDistance:=0.05)
objProfArr(1).Visible = False
' Check the status of Base Feature
If objModel.ExtrudedProtrusions(1).Status <> igFeatureOK Then
MsgBox ("Error in the Creation of Base Protrusion Feature object")
End If
' Create a Holes2d Profile for the Hole object
Set objRefPln = objDoc.RefPlanes.AddParallelByDistance(ParentPlane:=objDoc.RefPlanes(2), _
Distance:=0.01, NormalSide:=igRight)
Set objHoleProf = objDoc.ProfileSets.Add.Profiles.Add(pRefPlaneDisp:=objRefPln)
Call objHoleProf.Holes2d.Add(xCenter:=-0.025, yCenter:=0.04)
' Check for the Profile Validity
lngStatus = objHoleProf.End(ValidationCriteria:=igProfileClosed)
If lngStatus <> 0 Then
MsgBox ("rofile not closed")
End If
' Create the HoleData object
Set objHolData = objDoc.HoleDataCollection.Add(HoleType:=igRegularHole, _
HoleDiameter:=0.0085)
  
'(HoleType:=igCounterboreHole, _
HoleDiameter:=0.005, CounterboreDiameter:=0.007, _
CounterboreDepth:=0.0075)
' Create a Hole object
Set objHol = objModel.Holes.AddFinite(Profile:=objHoleProf, Profileplaneside:= _
igRight, FiniteDepth:=0.05, Data:=objHolData)
objHoleProf.Visible = False
If objHol.Status <> igFeatureOK Then
MsgBox ("AddFinite method with Profileplaneside set to Right failed")
End If
' Get the Application Property of Hole
'Set objApplication = objHol.Application
Set objEdgs = objHol.Edges(EdgeType:=igQueryAll)
Set objFaces = objHol.Faces(FaceType:=igQueryRoundable)
  
Set objHolData1 = objDoc.HoleDataCollection.Add(HoleType:=igRegularThread, _
HoleDiameter:=0.01, ThreadDepth:=0.01)
'Set objModel = objDoc.Models(1)
'Get the Threads Object for the Model
Set objThread = objModel.Threads.Add(HoleData:=objHol, numberofcylinders:=1, _
cylinderarray:=objFaces, cylinderendarray:=objEdgs)
  
' USER DISPLAY
' Release objects
Set objApp = Nothing
Set objDoc = Nothing
Set objHoleProf = Nothing
Set objProfArr(1) = Nothing
Set objModel = Nothing
Set objHol = Nothing
Set objHolData = Nothing
Set objRelns = Nothing
Set objLines = Nothing
Set objApplication = Nothing
Set objRefPln = Nothing
End Sub
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 支持支持
沙发
发表于 2004-5-2 16:00:43 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
板凳
发表于 2004-5-13 19:16:38 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
地板
发表于 2004-5-17 17:05:19 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
5
 楼主| 发表于 2004-5-24 08:46:20 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
6
发表于 2004-6-17 16:35:45 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
7
发表于 2007-5-9 10:30:38 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手板模型制作,在线3D打印服务

QQ|小黑屋|手机版|开思工具箱 CAD工具箱_CAM工具箱  

GMT+8, 2024-12-23 08:35 , Processed in 0.020013 second(s), 7 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

快速回复 返回顶部 返回列表