×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Macro for positioned sketch

Macro for positioned sketch

Macro for positioned sketch

(OP)
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 --> CATScript

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 



Thanks

RE: Macro for positioned sketch

try to record a macro and you'll see how it's done

RE: Macro for positioned sketch

(OP)
I started by recording a Macro and then updated it based on requirements.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources