DomKum
Automotive
- Nov 27, 2005
- 23
Hi Experts
May I request for help to correct this issue.
Trying to create a sphere with exiting points. Requirement is to create a sphere with parameter. I followed your youtube video but not able to fix the problem.
Not able to create formula to connect to radius of sphere.
Language=”VBSCRIPT”
‘ * * * * * * * * * * * * *
‘This MACRO is to create a parametric sphere with diameter as input
‘points in GS
‘ * * * * * * * * * * * * * – – – – – – – – – – – * * * * * * *
Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set parameters1 = part1.Parameters
Set hybridBodies1 = part1.HybridBodies
‘Set hybridShapes1 = hybridBody1.HybridShapes
Set axisSystems1 = part1.AxisSystems
msgbox (“Select the geometrical set with I/P points for creating Sphere”)
Dim oSelection ‘as Selection
Dim InputObjectType(0)
Set oSelection = CATIA.ActiveDocument.Selection
oSelection.Clear
InputObjectType(0) = “HybridBody”
Status = oSelection.SelectElement2(InputObjectType, “Select Geometrical set.”, True)
Set hybridBody1 = hybridBodies1.Add()
Set hybridBody1 = CATIA.ActiveDocument.Part.InWorkObject
Set parameters1 = part1.Parameters
Dim length1 ‘As Dimension
Set length1 = parameters1.CreateDimension(“”, “LENGTH”, 0.000000)
length1.Rename “SPDia”
length1.Value = 25.000000
‘Spheredia=Inputbox(“Enter Diameter of sphere to be created”)
Dim iCount
Dim i ‘As Integer
oSelection.Search “CATGmoSearch.Point,sel”
iCount = oSelection.Count
For i = 1 to iCount
Set hybridShapePointOnSurface1 = oSelection.Item(i).Value
Dim reference1 ‘As reference
Set reference1 = part1.CreateReferenceFromObject(hybridShapePointOnSurface1)
Set hybridShapeFactory1 = part1.HybridShapeFactory
Dim relations1 ‘As Relations
Set relations1 = part1.Relations
Dim formula1 ‘As Formula
Set formula1 = relations1.CreateFormula(“Formula.2”, “”, length1, SPDia)
formula1.Rename “Formula.2”
Set hybridShapeSphere1 = hybridShapeFactory1.AddNewSphere(reference1, Nothing, SPDia, -45.000000, 45.000000, 0.000000, 180.000000)
hybridShapeSphere1.Limitation = 1
hybridBody1.AppendHybridShape hybridShapeSphere1
part1.InWorkObject = hybridShapeSphere1
hybridShapeSphere1.name = “Shpere for-” & oSelection.Item(i).Value.name
‘part1.Update
NEXT
part1.Update
msgbox (“Total number of sphere created -” & iCount)
End Sub
May I request for help to correct this issue.
Trying to create a sphere with exiting points. Requirement is to create a sphere with parameter. I followed your youtube video but not able to fix the problem.
Not able to create formula to connect to radius of sphere.
Language=”VBSCRIPT”
‘ * * * * * * * * * * * * *
‘This MACRO is to create a parametric sphere with diameter as input
‘points in GS
‘ * * * * * * * * * * * * * – – – – – – – – – – – * * * * * * *
Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set parameters1 = part1.Parameters
Set hybridBodies1 = part1.HybridBodies
‘Set hybridShapes1 = hybridBody1.HybridShapes
Set axisSystems1 = part1.AxisSystems
msgbox (“Select the geometrical set with I/P points for creating Sphere”)
Dim oSelection ‘as Selection
Dim InputObjectType(0)
Set oSelection = CATIA.ActiveDocument.Selection
oSelection.Clear
InputObjectType(0) = “HybridBody”
Status = oSelection.SelectElement2(InputObjectType, “Select Geometrical set.”, True)
Set hybridBody1 = hybridBodies1.Add()
Set hybridBody1 = CATIA.ActiveDocument.Part.InWorkObject
Set parameters1 = part1.Parameters
Dim length1 ‘As Dimension
Set length1 = parameters1.CreateDimension(“”, “LENGTH”, 0.000000)
length1.Rename “SPDia”
length1.Value = 25.000000
‘Spheredia=Inputbox(“Enter Diameter of sphere to be created”)
Dim iCount
Dim i ‘As Integer
oSelection.Search “CATGmoSearch.Point,sel”
iCount = oSelection.Count
For i = 1 to iCount
Set hybridShapePointOnSurface1 = oSelection.Item(i).Value
Dim reference1 ‘As reference
Set reference1 = part1.CreateReferenceFromObject(hybridShapePointOnSurface1)
Set hybridShapeFactory1 = part1.HybridShapeFactory
Dim relations1 ‘As Relations
Set relations1 = part1.Relations
Dim formula1 ‘As Formula
Set formula1 = relations1.CreateFormula(“Formula.2”, “”, length1, SPDia)
formula1.Rename “Formula.2”
Set hybridShapeSphere1 = hybridShapeFactory1.AddNewSphere(reference1, Nothing, SPDia, -45.000000, 45.000000, 0.000000, 180.000000)
hybridShapeSphere1.Limitation = 1
hybridBody1.AppendHybridShape hybridShapeSphere1
part1.InWorkObject = hybridShapeSphere1
hybridShapeSphere1.name = “Shpere for-” & oSelection.Item(i).Value.name
‘part1.Update
NEXT
part1.Update
msgbox (“Total number of sphere created -” & iCount)
End Sub