几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CMM二次开发 » PC-DMIS二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2007-11-26, 10:44 AM   #1
huangyhg
超级版主
 
huangyhg的头像
 
注册日期: 04-03
帖子: 18592
精华: 36
现金: 249466 标准币
资产: 1080358888 标准币
huangyhg 向着好的方向发展
默认 【转帖】How to access the hits that comprise a feature?

I've tried the following basic code (generated by the OldBasic converter).

Sub main

Dim i, j, k As Integer ' working vars
Dim tpoint As Object
Set tpoint = CreateObject("PCDLRN.PointData")

Dim AutoApp As Object
Set AutoApp = CreateObject("PCDLRN.Application")
Dim AutoPart As Object
Set AutoPart = AutoApp.ActivePartProgram
Dim AutoOldBasicObj As Object
Set AutoOldBasicObj = AutoPart.OldBasic
i = AutoOldBasicObj.StartGetFeatPoint("CIR1",PCD_MEAS, PCD__BALLCENTER)
For j = 1 To i
msgbox i & " - " & j
AutoOldBasicObj.GetFeatPoint( tpoint, j)
msgbox "Got past the GetFeatPoint call"
Next j
End Sub

The circle ("C1") has four points, which the call to AutoOldBasicObj.StartGetFeatPoint returns correctly.

However, the call to AutoOldBasicObj.GetFeatPoint( tpoint, j) has two problems:

1. It won't run if I attempt to assign the result of this funtion to an integer (e.g. k = AutoOldBasicObj.GetFeatPoint( tpoint, j) ) I get a type mismatch error, which indicates that the function is not returning an integer as indicated in the manual.

2. Once executed, the program blows up without an error, and ceases to run. That is, I'll never get to the second MSGBOX call.

Is there another way to get at the basic hit data for this circle? I can find non-OldBasic objects that let me get at the dimensions of it, but not the individual hits themselves. This is more than a little exasperating...

此帖于 2007-11-26 10:48 AM 被 huangyhg 编辑.
huangyhg离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
旧 2007-11-26, 10:51 AM   #2
huangyhg
超级版主
 
huangyhg的头像
 
注册日期: 04-03
帖子: 18592
精华: 36
现金: 249466 标准币
资产: 1080358888 标准币
huangyhg 向着好的方向发展
默认 回复: 【转帖】How to access the hits that comprise a feature?

FWIW: I struggled through the (lack of) documentation and came up with the following PC-DMIS program/VB program that takes numerous circles up and down a cylinder, accesses the individual points that comprise the hits, turns them into diameters, and then writes them into a comma-delimited file that can be read directly into XL.

Obvious improvements might be to insert directly into spreadsheet, or have a spreadsheet open the program and run it using a more true automation.

Note to Wilcox: Better documentation, including samples of how each feature is used, would be very welcome. Also, it seems that some things don't work as I would have expected. For instance, I couldn't dim an array of PointData, nor set the individual components of an array. Hence I had to use arrays of doubles to hold the X and Y components of a PointData object, rather than being able to iterate through the array and use the points themselves.

This is a very powerful tool that would be much more useful with some solid examples of coding that could be used as building blocks.


**** BEGIN PC-DMIS program

PART NAME : DB07RN602AID
REV NUMBER :
SER NUMBER :
STATS COUNT : 1

STARTUP =ALIGNMENT/START,RECALL:,LIST=YES
ALIGNMENT/END
MODE/MANUAL
FORMAT/TEXT,OPTIONS, ,HEADINGS,SYMBOLS, ;NOM,MEAS,MAXMIN,TOL,DEV,OUTTOL,
LOADPROBE/14MMSPHERE
TIP/T1A0B0, SHANKIJK=0, 0, 1, ANGLE=0
*** MANUAL ALILGNMENT CODE DELETED FOR SPACE REASONS
MODE/DCC
C1 =COMMENT/INPUT,NO,'Enter the part id'
ASSIGN/PARTID = C1.INPUT
ASSIGN/THISFILENAME = TEST
CS1 =SCRIPT/FILENAME= C:\CMM PROGRAMS\FTE\DB07RN602A\DB07RN602AID.BAS
FUNCTION/CreateFIle,SHOW=YES,,
STARTSCRIPT/
ENDSCRIPT/
PLN2 =FEAT/PLANE,CARTESIAN,TRIANGLE
THEO/<-11.502,-81.816,-56.43>,<-0.000006,0.0000043,1>
ACTL/<-11.51,-81.81,-56.433>,<0.0000158,0.0000003,1>
MEAS/PLANE,4
HIT/BASIC,NORMAL,<-111.621,-72.624,-56.431>,<-0.000006,0.0000043,1>,<-111.62,-72.655,-56.432>,USE THEO = YES
HIT/BASIC,NORMAL,<68.916,-73.045,-56.43>,<-0.000006,0.0000043,1>,<68.909,-73.075,-56.435>,USE THEO = YES
HIT/BASIC,NORMAL,<68.874,-90.692,-56.43>,<-0.000006,0.0000043,1>,<68.868,-90.667,-56.435>,USE THEO = YES
HIT/BASIC,NORMAL,<-72.176,-90.902,-56.43>,<-0.000006,0.0000043,1>,<-72.197,-90.843,-56.432>,USE THEO = YES
ENDMEAS/
LIN2 =FEAT/LINE,CARTESIAN,UNBOUNDED
THEO/<-99.494,-108.564,-44.495>,<1,-0.0002276,0>
ACTL/<-99.504,-106.343,-44.502>,<1,-0.000116,0>
MEAS/LINE,2,WORKPLANE
HIT/BASIC,NORMAL,<-99.509,-108.564,-44.498>,<0.0002276,1,0>,<-99.504,-106.343,-44.505>,USE THEO = YES
HIT/BASIC,NORMAL,<8.198,-108.588,-44.492>,<0.0002276,1,0>,<8.191,-106.355,-44.499>,USE THEO = YES
ENDMEAS/
MOVE/POINT,NORMAL,<15.455,-94.29,26.403>
MOVE/POINT,NORMAL,<-1.486,-7.835,26.402>
CYL2 =FEAT/CYLINDER,CARTESIAN,IN,LEAST_SQR
THEO/<0.017,-0.024,-20.975>,<-0.0012422,-0.0022099,0.9999968>,46.953,28.303
ACTL/<0.002,-0.023,-20.983>,<-0.0007906,-0.0007831,0.9999994>,47.002,28.299
MEAS/CYLINDER,8
HIT/BASIC,NORMAL,<1.563,23.465,-35.088>,<-0.0929248,-0.9956704,-0.0023157>,<1.225,23.501,-35.113>,USE THEO = YES
HIT/BASIC,NORMAL,<23.502,-1.04,-35.086>,<-0.9979557,0.0639001,-0.0010984>,<23.534,-0.766,-35.111>,USE THEO = YES
HIT/BASIC,NORMAL,<-1.103,-23.405,-35.086>,<-0.0091691,0.9999555,0.0021984>,<-1.714,-23.496,-35.112>,USE THEO = YES
HIT/BASIC,NORMAL,<-23.239,2.771,-35.089>,<0.9858169,-0.1678224,0.0008537>,<-23.41,2.259,-35.11>,USE THEO = YES
HIT/BASIC,NORMAL,<-23.166,2.772,-6.863>,<0.984989,-0.1726149,0.0008421>,<-23.354,2.231,-6.852>,USE THEO = YES
HIT/BASIC,NORMAL,<-0.382,23.359,-6.861>,<0.0574012,-0.9983489,-0.0021349>,<0.086,23.439,-6.842>,USE THEO = YES
HIT/BASIC,NORMAL,<23.411,0.045,-6.859>,<-0.9999835,-0.0056001,-0.0012545>,<23.446,0.017,-6.841>,USE THEO = YES
HIT/BASIC,NORMAL,<0.381,-23.504,-6.859>,<-0.0226806,0.9997404,0.0021811>,<0.263,-23.502,-6.851>,USE THEO = YES
MOVE/POINT,NORMAL,<0.354,-1.401,-6.86>
MOVE/POINT,NORMAL,<0.353,-1.401,12.903>
ENDMEAS/
PNT2 =FEAT/POINT,CARTESIAN
THEO/<0.382,-25.346,0.043>,<0,0,1>
ACTL/<0.334,-25.327,-0.009>,<0,0,1>
MEAS/POINT,1
HIT/BASIC,NORMAL,<0.382,-25.346,0.043>,<0,0,1>,<0.334,-25.327,-0.009>,USE THEO = YES
ENDMEAS/
A2 =ALIGNMENT/START,RECALL:A1,LIST=YES
ALIGNMENT/LEVEL,ZPLUS,PLN2
ALIGNMENT/ROTATE,XPLUS,TO,LIN2,ABOUT,ZPLUS
ALIGNMENT/TRANS,ZAXIS,PNT2
ALIGNMENT/TRANS,XAXIS,CYL2
ALIGNMENT/TRANS,YAXIS,CYL2
ALIGNMENT/END
V1 =LOOP/START, ID = YES, NUMBER = 18, START = 1, SKIP = ,
OFFSET: XAXIS = 0, YAXIS = 0, ZAXIS = -2, ANGLE = 0
CIR1 =FEAT/CIRCLE,CARTESIAN,IN,LEAST_SQR
THEO/<-0.073,0.046,-2>,<0.0000156,0.0000042,1>,47.048
ACTL/<-18.646,21.262,-2.15>,<0.0000151,0.0000067,1>,45.167
MEAS/CIRCLE,72,WORKPLANE
*** 72 HITs deleted here for space purposes

,USE THEO = YES
ENDMEAS/
CS2 =SCRIPT/FILENAME= C:\CMM PROGRAMS\FTE\DB07RN602A\DB07RN602AID.BAS
FUNCTION/CIRC1,SHOW=YES,,
STARTSCRIPT/
ENDSCRIPT/
LOOP/END
MOVE/POINT,NORMAL,<-0.05,-1.157,-14.756>
MOVE/POINT,NORMAL,<-0.053,-1.162,59.884>

*** END PC_DMIS PROGRAM

** BEGIN BASIC PROGRAM
Function dist_2d(x1, x2 As Double, y1, y2 As Double)
dist_2d = sqr((x1 - x2)^2 +(y1 - y2)^2)
End Function

Sub CreateFile
Dim st As String
Dim AutoApp As Object
Set AutoApp = CreateObject("PCDLRN.Application")
Dim AutoPart As Object
Set AutoPart = AutoApp.ActivePartProgram

' Get the ID To construct a unique file Name
Dim var As Object
Set var = AutoPart.GetVariableValue("PARTID")
thisfilename = "C:\CMM Programs\FTE\DB07RN602A\DB07RN602AID" & var.StringValue
thisfilename = thisfilename & "-" & format(now,"dd-mm-yy-hh-nn") & ".txt"
'assign it To internal variable For Next time
Dim filename As Object
Set filename = AutoPart.GetVariableValue("THISFILENAME")
filename.stringvalue = thisfilename
Autopart.SetVariableValue "THISFILENAME" ,filename

On Error Resume Next
kill thisfilename
On Error GoTo 0
Open thisfilename For Output As #1
End Sub

Sub Circ1

Dim i, j, k As Integer ' working vars
Dim xarray(72) As Double ' WILL HOLD THE POINTS For Each MEASUREMENT
Dim yarray(72) As Double ' WILL HOLD THE POINTS For Each MEASUREMENT
Dim tpoint As Object
Set tpoint = CreateObject("PCDLRN.PointData")
Dim st As String

Dim AutoApp As Object
Set AutoApp = CreateObject("PCDLRN.Application")
Dim AutoPart As Object
Set AutoPart = AutoApp.ActivePartProgram
Dim cmds As Commands
Set cmds = AutoPart.Commands
Dim cmd As Command
Set cmd = cmds.Item("CIR1")
'Dim var As Object
Set var = AutoPart.GetVariableValue("THISFILENAME")
thisfilename = var.StringValue

Dim fcmd As Object
Set fcmd =cmd.FeatureCommand ' Get the feature command property
'msgbox fcmd.id & " - " & fcmd.numhits
For i = 1 To fcmd.numhits
Set tpoint = fcmd.GetHit(i,FHITDATA_CENTROID,FDATA_MEAS,FDATA_P ART,"",PLANE_TOP)
xarray(i) = tpoint.x
yarray(i) = tpoint.y
Next i
Open thisfilename For Append As #1
st = "Depth: " & format(tpoint.z,"###.0000") & ", " ' always the same
k = fcmd.numhits / 2 '' divide number of hits by 2 For diameters
For i = 1 To k
st = st & format(dist_2d(xarray(i), xarray(i+k), yarray(i), yarray(i+k)),"##.0000") & ", "
Next
st = left(st,len(st) - 2) ' strip off the last comma,space
Print #1, st
End Sub

&*** END BASIC PROGRAM
huangyhg离线中   回复时引用此帖
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
OpenGL 选择与反馈 huangyhg OpenGL图形显示 0 2007-01-02 07:10 PM


所有的时间均为北京时间。 现在的时间是 01:00 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多