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!

copy a point

Status
Not open for further replies.

mayrou

Electrical
Jan 8, 2014
55
TN
hi!

I want to create a macro that copy a point
named "pt1" from an hybridbody1 to another hybridbody2
when i record a macro of this action:
Code:
Sub CATMain()

Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument


Dim documents1 As Documents
Set documents1 = CATIA.Documents

Dim partDocument1 As Document
Set partDocument1 = documents1.Item("387-181-953-0.CATPart")

Dim part11 As Part
Set part11 = partDocument1.Part

Dim hybridBodies11 As HybridBodies
Set hybridBodies11 = part11.HybridBodies

Dim hybridBody11 As HybridBody
Set hybridBody11 = hybridBodies11.Item("Construction maquette")

Dim hybridShapes11 As HybridShapes
Set hybridShapes11 = hybridBody11.HybridShapes

Dim zeroDimFeatVertexOrWireBoundaryMonoDimFeatVertex1 As Boundary
Set zeroDimFeatVertexOrWireBoundaryMonoDimFeatVertex1 = hybridShapes11.GetItem("pt1")
'selection1.AddzeroDimFeatVertexOrWireBoundaryMonoDimFeatVertex1
the problem here is that it works with selection! that make me upset!!!
help please! thank you

 
Replies continue below

Recommended for you

well copy and paste work with selection.

looking at your script: you Dim your zero[...]Vertex as Boundary and you set a "pt1" to it. I hope "pt1" is a a boundary feature.

Eric N.
indocti discant et ament meminisse periti
 
hi
this macro may be useful for you!
it generate a copy of a point "point1" from an hybridbody1 named "construction" in part1 to the same hybrid body

Code:
Sub CATMain()

Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = productDocument1.Selection

selection1.Clear 

Dim documents1 As Documents
Set documents1 = CATIA.Documents

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

Dim part1 As Part
Set part1 = partDocument1.Part

Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies

Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item("Construction")

Dim hybridShapes1 As HybridShapes
Set hybridShapes1 = hybridBody1.HybridShapes

Dim hybridShapePointCenter1 As HybridShape
Set hybridShapePointCenter1 = hybridShapes1.Item("Point.1")

selection1.Add hybridShapePointCenter1

selection1.Copy 

Dim partDocument2 As Document
Set partDocument2 = documents1.Item("part2.CATPart")

Dim part2 As Part
Set part2 = partDocument2.Part

Dim hybridBodies2 As HybridBodies
Set hybridBodies2 = part2.HybridBodies

Dim hybridBody2 As HybridBody
Set hybridBody2 = hybridBodies2.Item("Set géométrique.1")

selection1.Paste
part2.Update 

End Sub

but i want to place the copy in an hybridbody2 named "set geometrique.1" in part2
thx :)))
 
selection1 was defined on active document (part1) when you do selection1.Paste you actually do part1.Paste !

check the very good [link ]GTWiki on this problem[/url] :

Also the point you copy is a center, don't you think you also need to copy the curve/circle needed for the definition of the point?

Unless you get the XYZ of part1.point1 and create (not copy/paste) a new XYZ point (not center) in part2.

Eric N.
indocti discant et ament meminisse periti
 
I want a special paste as a result!
how can I do that?
if not there will be a problem with the update! the point is deactivated
 
check your online doc about selection... you should find your answer there

Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top