+3

Option to load CAD file based on user input

Chris Rogers 5 jaar geleden in Metrology Software / PC-DMIS bijgewerkt door neil kay 4 jaar geleden 9

Add the ability for users to code in an import CAD file based on variables.  IE:

What part are you running?  -2

if c1.input == "-2"

import, igs, "c:\models\ 123-2.igs"

end_if

something to that effect, for when there are a family of parts with minor changes in the part and you want to write a single program to run all parts in the family, but want the correct CAD file to show, as to not confuse the operator when the incorrect part is showing on the screen.



Think that that functionality is already in there.  It's not as easy as your example though.  


Haven't tried it out but you "should' be able to import and merge both parts, transform them to the same origin and orientation.   Then use CAD assembly to turn off the unwanted model and then use view sets display the model under software control.

Like I said, I haven't tried it out but in a 'sane' world this should work.

I have tried what you suggested in the past, but it did not work, what seems to happen is that the program always shows the last called viewset. Example:


C1 =COMMENT/INPUT,NO,FULL SCREEN=NO,
        What part are you running, -1 or -2
            IF/C1.INPUT=="-1"
RECALL/VIEWSET,VIEWSET1
            END_IF/
ELSE_IF/C1.INPUT=="-2"
RECALL/VIEWSET,VIEWSET2
            END_ELSEIF/
it will always show viewset2 no matter what selection is used.
I have even tried case statements in the past with the same effect.

I cannot say it does not work in the latest version of PC-DMIS, but I do not retry my code in every new release.


You may be correct and there is already a way, I have just not found it yet.







Could the viewset name be a variable?

 C1 =COMMENT/INPUT,NO,FULL SCREEN=NO,
What part are you running, -1 or -2
IF/C1.INPUT=="-1"
my_View=VIEWSET1
END_IF/
ELSE_IF/C1.INPUT=="-2"
my_view=VIEWSET2
END_ELSEIF/

Recall/Viewset, my_view

Don't know if this would work but might be worth a try.

From the Help Menu:

When your cursor is on or under the RECALL/VIEWSET, command in the Edit window, PC-DMIS displays the created viewset in the Graphic Display window. If you mark and execute this command, PC-DMIS displays the saved view in the Graphic Display window during measurement routine execution as well.


There are already tools to create Cad Views and Cad Groups. These Views or Groups have Id's for each view or group created. Hexagon should add the ability to recall the Cad Views and Cad Groups by there Id name. This will replace the example methods shown below.

You can do this with Basic Script. This example shows how the cad views will change per request from the operator.

PC-DMIS Routine:

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

STARTUP =ALIGNMENT/START,RECALL:USE_PART_SETUP,LIST=YES
ALIGNMENT/END
MODE/MANUAL
FORMAT/TEXT,OPTIONS, ,HEADINGS,SYMBOLS, ;NOM,TOL,MEAS,DEV,OUTTOL, ,
LOADPROBE/3BY20_T1_3BY10_5E_5W_20E_TP20MF_100E
TIP/T1A0B0, SHANKIJK=0, 0, 1, ANGLE=0
HEXBLOCK_SURFACE =VIEWSET/
HEXMI_DEMOBLOCK =VIEWSET/
C1 =COMMENT/INPUT,NO,FULL SCREEN=NO,
Enter 1 for Viewset1
Enter 2 for Viewset2
IF/C1.INPUT==1
CS1 =SCRIPT/FILENAME= C:\USERS\PUBLIC\DOCUMENTS\HEXAGON\PC-DMIS EXPORT DIRECTORY\PC-DMIS OFFLINE\VIEWSET1.BAS
FUNCTION/Main,SHOW=YES,,
STARTSCRIPT/
ENDSCRIPT/
END_IF/
ELSE/
CS2 =SCRIPT/FILENAME= C:\USERS\PUBLIC\DOCUMENTS\HEXAGON\PC-DMIS EXPORT DIRECTORY\PC-DMIS OFFLINE\VIEWSET2.BAS
FUNCTION/Main,SHOW=YES,,
STARTSCRIPT/
ENDSCRIPT/
END_ELSE/
RECALL/VIEWSET,HEXBLOCK_SURFACE

Basic Script for Viewset1:

Dim DmisApp As Object
Dim DmisPart As Object
Dim DmisCommands As Object
Dim DmisCommand As Object

Sub Part1
Set DmisApp = CreateObject("PCDLRN.Application")
Set DmisPart = DmisApp.ActivePartProgram
Set DmisCommands = DmisPart.Commands
CommandCount = DmisCommands.Count
Set DmisCommand = DmisCommands.Item(CommandCount)
DmisCommands.InsertionPointAfter DmisCommand

For Each DmisCommand In DmisCommands
If DmisCommand.Type = RECALL_VIEWSET Then
'Set DmisCommand = DmisCommands.Add(RECALL_VIEWSET, True)
DmisCommand.Marked = True
' Set Reference Id = HEXBLOCK_SURFACE
retval = DmisCommand.PutText ("HEXBLOCK_SURFACE", REF_ID, 0)
End If
Next DmisCommand

End Sub

Sub Main

Part1

DmisPart.RefreshPart
End Sub

Basic script for Viewset2:

Dim DmisApp As Object
Dim DmisPart As Object
Dim DmisCommands As Object
Dim DmisCommand As Object

Sub Part1
Set DmisApp = CreateObject("PCDLRN.Application")
Set DmisPart = DmisApp.ActivePartProgram
Set DmisCommands = DmisPart.Commands
CommandCount = DmisCommands.Count
Set DmisCommand = DmisCommands.Item(CommandCount)
DmisCommands.InsertionPointAfter DmisCommand

For Each DmisCommand In DmisCommands
If DmisCommand.Type = RECALL_VIEWSET Then
'Set DmisCommand = DmisCommands.Add(RECALL_VIEWSET, True)
DmisCommand.Marked = True
' Set Reference Id = HEXMI_DEMOBLOCK
retval = DmisCommand.PutText ("HEXMI_DEMOBLOCK", REF_ID, 0)
End If
Next DmisCommand

End Sub

Sub Main

Part1

DmisPart.RefreshPart
End Sub

Here is another example without scripts:

PC-DMIS Routine:

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

STARTUP =ALIGNMENT/START,RECALL:USE_PART_SETUP,LIST=YES
ALIGNMENT/END
MODE/MANUAL
FORMAT/TEXT,OPTIONS, ,HEADINGS,SYMBOLS, ;NOM,TOL,MEAS,DEV,OUTTOL, ,
LOADPROBE/3BY20_T1_3BY10_5E_5W_20E_TP20MF_100E
TIP/T1A0B0, SHANKIJK=0, 0, 1, ANGLE=0
HEXBLOCK_SURFACE =VIEWSET/
ASSIGN/VIEWSET_V1=GETCOMMAND(50,"UP",1)
HEXMI_DEMOBLOCK =VIEWSET/
ASSIGN/VIEWSET_V2=GETCOMMAND(50,"UP",1)
C1 =COMMENT/INPUT,NO,FULL SCREEN=NO,
Enter 1 for Viewset1
Enter 2 for Viewset2
IF/C1.INPUT==1
ASSIGN/V1=GETTEXT(2,1,VIEWSET_V1)
END_IF/
ELSE/
ASSIGN/V1=GETTEXT(2,1,VIEWSET_V2)
END_ELSE/
RECALL/VIEWSET,V1

Dave, I tried the PC-DMIS example you provided and it works, Thanks. I have to admit I have never used the gettext or getcommand expressions before. I have also never done any basic scripting in my CMM programs either.  I would have been nice to not have to go to this high of a level of programming to accomplish this.

thanks again.



No problem. Glad it work.

I agree, you should have too.