Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro for positioned sketch

Status
Not open for further replies.

aron1

Automotive
Apr 30, 2015
3
US
Hello,

I started writing macro for positioned sketch. I started by creating a plane but I am still stuck on it. Can somebody help me with this? I have pasted my code below


Code:
Language="VBSCRIPT"

Sub CATMain()

Dim ProdDoc As Document
Set ProdDoc = CATIA.ActiveDocument

Dim product1 As Product
Set product1 = ProdDoc.Product

Dim products1 As Products
Set products1 = product1.Products

Dim product2 As Product
Set product2 = products1.AddNewComponent("Part", "NewPart1")

Dim documents1 As Documents
Set documents1 = CATIA.Documents

Dim partDocument1 As Document
Set partDocument1 = documents1.Item("NewPart1.CATPart")

Dim NewPart1 As Part
Set NewPart1 = partDocument1.Part

Dim hybridShapeFactory1 As Factory
Set hybridShapeFactory1 = NewPart1.HybridShapeFactory

Dim parameters1 As Parameters
Set parameters1 = NewPart1.Parameters

Dim oSel As Selection
Set oSel = prodDoc.Selection

Dim point_ref 
Dim line_ref 
Dim Point As Reference 
Dim Line As Reference 

 Dim iot1(0)
  iot1(0) = "Vertex"
  Dim iot2(0)
   iot2(0)="TriDimFeatEdge"
 
  Status = oSel.SelectElement2(iot1, "Select a line", False)
  
  msgbox oSel.Item(1).Type
  
  set point_ref = oSel.Item(1).Value
  
  oSel.Clear
  
  Status = oSel.SelectElement2(iot2, "Select a line", False)
  
  msgbox oSel.Item(1).Type
  
  set line_ref = oSel.Item(1).Value
  
  oSel.Clear
  
  Dim hybridShapePlaneNormal1 As HybridShapePlaneNormal
  Set hybridShapePlaneNormal1 = hybridShapeFactory1.AddNewPlaneNormal(line_ref, point_ref)

  Dim bodies1 As Bodies
  Set bodies1 = NewPart1.Bodies

  Dim body1 As Body
  Set body1 = bodies1.Item("PartBody")

  body1.InsertHybridShape hybridShapePlaneNormal1       '{Error}

  NewPart1.InWorkObject = hybridShapePlaneNormal1
  NewPart1.Update 

End Sub

Untitled_oy7aoe.png


Thanks
 
Replies continue below

Recommended for you

I started by recording a Macro and then updated it based on requirements.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top