CyberChaos(さいばかおす)

プログラミング言語、トランスパイラ、RPA、ChatGPT、データマイニング、リバースエンジニアリングのための忘備録

CATIA自動化VBS作成サービス

2023-03-21 14:52:19 | CATIA
 
渡り鳥さん(システムエンジニア)のプロフィール | ココナラ

渡り鳥さん(システムエンジニア)のプロフィール | ココナラ

初めまして、渡り鳥と申します。 普段はCATIA、Excelのマクロ開発をしています。 【CATIA】 CATIAの操作は一通りできますがモデリングはあまり得意ではないです。 ワーク...

ココナラ

P.S.
こいつの記事の以下のサンプルコードを実行してみたらエラーとなって実行できなかった。
 
'Const SIZE_VALUE As Double = 100#
Dim SIZE_VALUE 'As Double
SIZE_VALUE = 100
 
Dim appCATIA 'As INFITF.Application
Set appCATIA = GetObject(, "CATIA.Application")
 
Dim docs 'As INFITF.Documents
Set docs = appCATIA.Documents
 
Dim partDocNew 'As MECMOD.PartDocument
Set partDocNew = docs.Add("Part")
 
Dim partNew 'As MECMOD.Part
Set partNew = partDocNew.Part
 
Dim hbWork 'As MECMOD.HybridBody
Set hbWork = partNew.HybridBodies.Add()
 
Dim hsFactory 'As HybridShapeTypeLib.HybridShapeFactory
Set hsFactory = partNew.HybridShapeFactory
 
Dim dX 'As Double
Dim dY 'As Double
Dim dZ 'As Double
Dim hsPt1 'As HybridShapeTypeLib.HybridShapePointCoord
Dim refPt1 'As INFITF.Reference
dX = (SIZE_VALUE / 2)
dY = (SIZE_VALUE / 2)
dZ = 0
Set hsPt1 = hsFactory.AddNewPointCoord(dX, dY, dZ)
Call hbWork.AppendHybridShape(hsPt1)
Call partNew.UpdateObject(hsPt1)
Set refPt1 = partNew.CreateReferenceFromObject(hsPt1)
Dim hsPt2 'As HybridShapeTypeLib.HybridShapePointCoord
Dim refPt2 'As INFITF.Reference
dX = (SIZE_VALUE / 2) * -1
Set hsPt2 = hsFactory.AddNewPointCoord(dX, dY, dZ)
Call hbWork.AppendHybridShape(hsPt2)
Call partNew.UpdateObject(hsPt2)
Set refPt2 = partNew.CreateReferenceFromObject(hsPt2)
Dim hsPt3 'As HybridShapeTypeLib.HybridShapePointCoord
Dim refPt3 'As INFITF.Reference
dY = (SIZE_VALUE / 2) * -1
Set hsPt3 = hsFactory.AddNewPointCoord(dX, dY, dZ)
Call hbWork.AppendHybridShape(hsPt3)
Call partNew.UpdateObject(hsPt3)
Set refPt3 = partNew.CreateReferenceFromObject(hsPt3)
Dim hsPt4 'As HybridShapeTypeLib.HybridShapePointCoord
Dim refPt4 'As INFITF.Reference
dX = (SIZE_VALUE / 2)
Set hsPt4 = hsFactory.AddNewPointCoord(dX, dY, dZ)
Call hbWork.AppendHybridShape(hsPt4)
Call partNew.UpdateObject(hsPt4)
Set refPt4 = partNew.CreateReferenceFromObject(hsPt4)
 
Dim hsLine1 'As HybridShapeTypeLib.HybridShapeLinePtPt
Dim refLine1 'As INFITF.Reference
Set hsLine1 = hsFactory.AddNewLinePtPt(refPt1, refPt2)
Call hbWork.AppendHybridShape(hsLine1)
Call partNew.UpdateObject(hsLine1)
Set refLine1 = partNew.CreateReferenceFromObject(hsLine1)
Dim hsLine2 'As HybridShapeTypeLib.HybridShapeLinePtPt
Dim refLine2 'As INFITF.Reference
Set hsLine2 = hsFactory.AddNewLinePtPt(refPt2, refPt3)
Call hbWork.AppendHybridShape(hsLine2)
Call partNew.UpdateObject(hsLine2)
Set refLine2 = partNew.CreateReferenceFromObject(hsLine2)
Dim hsLine3 'As HybridShapeTypeLib.HybridShapeLinePtPt
Dim refLine3 'As INFITF.Reference
Set hsLine3 = hsFactory.AddNewLinePtPt(refPt3, refPt4)
Call hbWork.AppendHybridShape(hsLine3)
Call partNew.UpdateObject(hsLine3)
Set refLine3 = partNew.CreateReferenceFromObject(hsLine3)
Dim hsLine4 'As HybridShapeTypeLib.HybridShapeLinePtPt
Dim refLine4 'As INFITF.Reference
Set hsLine4 = hsFactory.AddNewLinePtPt(refPt4, refPt1)
Call hbWork.AppendHybridShape(hsLine4)
Call partNew.UpdateObject(hsLine4)
Set refLine4 = partNew.CreateReferenceFromObject(hsLine4)
 
Dim hsFill 'As HybridShapeTypeLib.HybridShapeFill
Set hsFill = hsFactory.AddNewFill()
Call hsFill.AddBound(refLine1)
Call hsFill.AddBound(refLine2)
Call hsFill.AddBound(refLine3)
Call hsFill.AddBound(refLine4)
Call hbWork.AppendHybridShape(hsFill)
Call partNew.UpdateObject(hsFill)
 
ココナラはダメポwww


最新の画像もっと見る

コメントを投稿

ブログ作成者から承認されるまでコメントは反映されません。