ศูนย์ฝึกอบรมและสอบ AUTODESK

บทความพิเศษ Tip&Trick

เปลี่ยนชื่อ Solid Body พร้อมๆ กันด้วย iLogic

Update : 31 ธ.ค. 2559

เปลี่ยนชื่อ Solid Body พร้อมๆ กันด้วย iLogic

-----------------------------------------------------------------------

'check for custom iProperty and add it if not found

Dim prefix As String = "Prefix"

customPropertySet = ThisDoc.Document.PropertySets.Item _

("Inventor User Defined Properties")

Try

         prop= customPropertySet.Item(prefix)

Catch

      ' Assume error means not found

            customPropertySet.Add("", prefix)

End Try

'write the part number to the Prefix iProperty if it is empty

If iProperties.Value("Custom", "Prefix") = "" Then

iProperties.Value("Custom", "Prefix") = iProperties.Value("Project", "Part Number") & "_"

Else

End If

'check that this active document is a part file  

Dim partDoc As PartDocument

If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then

MessageBox.Show ("กรุณาเปิดไฟล์งาน", " Able Academy ")

End If

'define the active document

partDoc = ThisApplication.ActiveDocument

Dim solid As SurfaceBody

Dim i As Integer

'get input from user

prefix = InputBox("กำหนดชื่อของ Solid Body", "Able Academy", iProperties.Value("Custom", "Prefix"))

'write input back to custom iProperty

iProperties.Value("Custom", "Prefix") = prefix

i = 1

'rename all solid bodies incrementing suffix

For Each solid In partDoc.ComponentDefinition.SurfaceBodies

solid.Name = prefix + Iif(i < 10, "0" + CStr(i), CStr(i))

i = i + 1

Next

----------------------------------

  « กลับหน้าบทความ  
ผลงานลูกค้าของเรา