MicroGDS @ \ Ɠ.

VBA ɂ u 擾 v T v @

Excel VBA g āA MicroGDS ̐} ʂ e L X g ǂclear J X ^ } C Y T v Љ.
{ y [ W ́A Micro GDS V10 ł ̓ e ŋ L ڂ Ă B

MicroGDS V11 A.NET API C ^ [ t F [ X

p r

\ d l ̕ ȂǁA } ʂɕ ׂĕ` Ă. g ɓ] L ׂ B

VBA ɂ u 擾 v T v c [

g

  1. MicroGDS Ńe L X g ǂ peptide ソ ʂ \ A v ~ e B u I [ h (F9) ŁA e L X g I ͂ B
  2. Excel Ń} N N B I e L X g V ȃV [ g ɓ] L ͂ B
    e L X g E ɕ ꍇ A V [.
    i ̃T v v O ł́A ̈ʒu ̏ ͍s Ă ̂ B j

T v
  1. Excel ŁA c [ ^ } N ^Visual Basic Editor I
  2. N G f B ^ ŁA } ^ W W [ s
  3. \ [ X ͂ i R s
  4. K v ɉ ă W [ ̖ ̂ ύX
\ [ X
  1. e ̒ ` Cadlink.txt ] L B
    i.txt ̒ ` ̂ŁA ׂĂ ł Ȃ
  2. MicroGDS Ƃ̒ʐM J n
  3. v ~ e B u I B
  4. I Ă v ~ e B u ̐ 𒲂ׂ B I Ă. v ~ e B u Ȃ ꍇ ́A ʐM ~.
  5. I Ă v ~ e B u ̃ X g 擾 ͂ B ???.??? ̃v. ~ e B ́ A A I u W F N g A v e B u 3 ? ? ̃ N œ 肳 ͂ B ͒ʏ.CadPriTriple. ̔z ɑI Ă v ~ e B u ׂẴ N. B Ȃ A O ɑI 𐔂Ŕz ̑ 傫 Ē.` Ă
  6. v ~ e B u Ƀ [ v
  7. X g ɋL ^ Ă Suburbs N ŁA ̃v ~ e B u u J g v ɂ ͂ B J g Ƃ́A ꂩ v O ň Ώۂł Ƃ. \
  8. v e B u ̃ ^ C v i ‥ j B ^ C v u e L X g v ̏ ꍇ ̂ processed s ~ B u ɂ ́A ⃉ X ^ [.
  9. e L X g v e B u ̏
    ł ́A. ɋL Ă ̂ B
  10. Excel. [ g s
    v O I X g p A [ v ăv ~. e B u ̏ 擾 ꍇ A ʂ̒l.͐} B ̂ A ʒu ɂ. 錋 ʂ K v Ƃ. s K v B ́A Excel ̃ \ בւ s Ă ͂ B

T v \ [ X

Option Explicit

' * Module:      Cadlink/Cadlnk60
' * Version:     10.0

' conversation constants
Global Const MGDS_CCS_REFCOUNT = 1
Global Const MGDS_CCS_ANY = 0   ' cad conversation - which session (number or "any")

' Constants used for identifying the current selection mode
Global Const SELMODE_PRIM = 2   ' primitive select mode

' ****************************************
' Cadlink CadVector Data Type Definition
' ****************************************

Type CadVector
    x As Double              ' x component
    y As Double              ' y component
    z As Double              ' z component
End Type

' ******************************************
' Cadlink CadPriTriple Data Type Definition
' ******************************************

Type CadPriTriple
    llink As Long            ' layer link number
    vlink As Long            ' version link number
    plink As Long            ' primitive link number
End Type

' ************************************
' Cadlink CadAxes data type definition - used to transform between axis frames.
' ************************************

Type CadAxes
    origin As CadVector      ' axes hook position
    xAxis As CadVector       ' axes x direction
    yAxis As CadVector       ' axes y direction
    zAxis As CadVector       ' axes z direction
    axesScale As Double      ' axes scale
    handedness As Long       ' handedness
End Type

' ****************************************
' Cadlink Function declarations
' ****************************************
Declare Function CadConvStartEx Lib "cadlnk60.dll" (ByVal sessionId As Long, _
    ByVal refCount As Long, ByVal timeout As Long) As Long
Declare Function CadConvStop Lib "cadlnk60.dll" () As Long
Declare Function CadGetSelectMode Lib "cadlnk60.dll" () As Long
Declare Function CadGetNumSelPrim Lib "cadlnk60.dll" () As Long
Declare Function CadCurPrimitive Lib "cadlnk60.dll" (ByVal llink As Long, _
    ByVal olink As Long, ByVal plink As Long) As Long
Declare Function CadGetCurPriFormattedText Lib "cadlnk60.dll" (priText As String, _
    ByVal options As String) As Long
Declare Function CadGetCurPriTextAxes Lib "cadlnk60.dll" (axes As CadAxes, _
    yfactor As Double) As Long
Declare Function CadGetCurPriType Lib "cadlnk60.dll" (priType As String) As Long
Declare Function CadGetPriSelections Lib "cadlnk60.dll" (ByVal nPrims As Long, _
    primArray As CadPriTriple) As Long

Public Sub gettext()
    Dim rv As Long
    Dim numsel As Long
    Dim n As Long
    Dim prilist() As CadPriTriple
    Dim ptype As String
    Dim selmode As Long
    Dim ptext As String
    Dim paxes As CadAxes
    Dim yfactor As Double
    Dim newsheet As Worksheet
    Dim isnewsheet As Long  ' �V�[�g����������̃t���O�A�����l0
    Dim linecount As Long   ' �s�J�E���g�̕ϐ��A�����l0

    isnewsheet = 0
    linecount = 0

    ' MicroGDS�Ƃ̒ʐM���J�n
    rv = CadConvStartEx(MGDS_CCS_ANY, MGDS_CCS_REFCOUNT, 2000)
    
    ' �v���~�e�B�u�I�����[�h�̃`�F�b�N
    selmode = CadGetSelectMode()
    If selmode <> SELMODE_PRIM Then
        ' MicroGDS�Ƃ̒ʐM���I��
        rv = CadConvStop()
        Exit Sub
    End If

    ' �I�𐔂̃`�F�b�N
    numsel = CadGetNumSelPrim()
    If numsel <= 0 Then
        ' MicroGDS�Ƃ̒ʐM���I��
        rv = CadConvStop()
        Exit Sub
    End If
    
    ' �I�𒆂̃v���~�e�B�u�̃����N�ԍ����擾
    ReDim prilist(numsel)
    rv = CadGetPriSelections(numsel, prilist(0))

    ' �v���~�e�B�u���Ƀ��[�v
    For n = 0 To numsel - 1
        ' �v���~�e�B�u���J�����g�ɂ���
        With prilist(n)
            rv = CadCurPrimitive(.llink, .vlink, .plink)
        End With
        
        ' �e�L�X�g�v���~�e�B�u�̏ꍇ
        rv = CadGetCurPriType(ptype)
        If ptype = "TEXT" Then
            ' �f�[�^�ƈʒu���擾
            rv = CadGetCurPriFormattedText(ptext, "EXPANDED=YES, MARKUP=NO")
            rv = CadGetCurPriTextAxes(paxes, yfactor)
            
            If isnewsheet = 0 Then
                ' �V�[�g������Ă��Ȃ���΍쐬
                Set newsheet = Worksheets.Add()
                isnewsheet = 1
            End If
            
            ' �s�J�E���g�̍s�ɁA�e�L�X�g���_�̂����W�l�ƃe�L�X�g���e�Ƃ��L��
            newsheet.Cells(linecount + 1, 1) = paxes.origin.y
            newsheet.Cells(linecount + 1, 2) = ptext
            linecount = linecount + 1
        End If
    Next n
    
    ' �s�J�E���g��0�łȂ��ꍇ
    If linecount > 0 Then
        ' Y�̒l�Ń\�[�g���s�Ȃ��B
        newsheet.Range("A1:B" & linecount).Sort key1:=Range("A1"), order1:=xlDescending
        
        ' Y�̃J����������
        newsheet.Range("A:A").Delete
    End If
    
    ' MicroGDS�Ƃ̒ʐM���I��
    rv = CadConvStop()

End Sub