hexagon logo

Getting the original name of items in a set

A little snippet to extract the actual name of feature number X in a set...

Call:

ARG1 = string, the name of the set containing the features
ARG2 = integer, the number of the feature you want to know the name of
ARG3 = string, the name of the variable that should get the result

SCN1       =FEAT/SET,CARTESIAN
            THEO/<157.311,48.099,-3.143>,<0,0,1>
            ACTL/<157.311,48.099,-3.143>,<0,0,1>
            CONSTR/SET,BASIC,PNT2,PNT3,PNT4,PNT5,PNT6,PNT7,PNT8,,

            ASSIGN/V1="empty string"

CS1        =SCRIPT/FILENAME= F:\PUBLIC\DOCUMENTS\PC-DMIS\BASIC\SETNAMES.BAS
            FUNCTION/Main,SHOW=YES,ARG1="SCN1",ARG2=3,ARG3="V1",,
            STARTSCRIPT/
            ENDSCRIPT/

            COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
            V1


Script:



Option Explicit


Sub Main(Scan1ID As String, FeatNo As Integer, ResultVarName As String)


Dim app As Object

Dim part As Object

Dim cmds As Object

Dim cmd1 As Object

Dim Scan1Hits As Object

Dim ResultVar As Object

Dim FeatName As String


Set app = CreateObject("PCDLRN.Application")

Set part = app.ActivePartProgram

Set cmds = part.Commands

Set cmd1 = cmds.Item(Scan1ID)

Set Scan1Hits = cmd1.FeatureCommand


FeatName= Scan1Hits.GetInputID(FeatNo)


Set ResultVar = part.GetVariableValue(ResultVarName)

ResultVar.StringValue = FeatName

part.SetVariableValue ResultVarName, ResultVar


End Sub


[/CODE]


Result:

V1 will have the value "PNT4" (which is the third feature in the set)
Parents Reply Children
No Data