Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Spline thru isolated points 1

Status
Not open for further replies.

A3DTech

Automotive
Aug 8, 2020
4
Hi everyone, I am new to this forum and i have a small problem which i am not able to solve by my self.
The thing is that when we recived points from our customer they are mostly isolated and thru that points we are making spline so we could sweep the profile.
Every time we need manualy to make point as a coordinate type and we have more then 50 points so it take a lot of time.
I even tried to export points to excel and then to imort them to Catia bit it take a lot of time. So does anyone have any idea how to combine these 2 macros in 1, or someone have some other solution
I've searched the forum and there is nothing similar like this, so i would really appritiate any help
 
Replies continue below

Recommended for you

You can build spline from isolated points just fine.


It's possible to create a spline with macro, but how would one define a proper order of points?
 
Hi thanks for the anwer but, from time to time we beed to changde the coordinates of these points. Making a spline it is not a problem, but converting these points in coordinate type it is a problem
 
To "move" datum point create new point with reference to the datum and use this point in your spline.
 
Is there any macro for that. Because we have more then 30 points to move manualy?
 
I've no idea if there is, it can be written easily.

How do you determine when you need to move a point? Where should new offset point be located?
 
I will try to explane. We have a tube thru the all car and thru that tube we have some fluid that need to be tranfered and path is depend from a body of the car. Very offten we need to change the position of some parts due to customer requirenmants. So then we need to change position of some points to fit the postition of the body on the car
 
Ok, here is a snippet that creates editable versions of all isolated points in a body/geoset:

Code:
Sub CATMain()
  Dim sel: set sel = CATIA.ActiveDocument.Selection
  if "Normal" <> sel.SelectElement(Array("HybridBody", "Body"), "Select geometrical set or body containing isolated points", True) then
    exit sub
  end if

  Dim container: set container = sel.Item(1).Value
  Dim prt: set prt = CATIA.ActiveDocument.Part
  Dim hsf: set hsf = prt.HybridShapeFactory
  Dim sh, coords(2), pointCoord, pointCoordRef
  for each sh in container.HybridShapes
    if TypeName(sh) = "HybridShapePointExplicit" then
      sh.GetCoordinates coords
      set pointCoord = hsf.AddNewPointCoord(coords(0), coords(1), coords(2))
      set pointCoordRef = hsf.AddNewPointCoordWithReference(0, 0, 0, prt.CreateReferenceFromObject(sh))

      pointCoord.Name = sh.Name + "_coords"
      pointCoordRef.Name = sh.Name + "_coords_ref"

      ' append to container
      if TypeName(container) = "Body" then
        container.InsertHybridShape pointCoord
        container.InsertHybridShape pointCoordRef 
      else
        container.AppendHybridShape pointCoord
        container.AppendHybridShape pointCoordRef 
      end if
    end if
  next
End Sub
 
Hi I am having an error in third line

if "Normal" <> sel.SelectElement(Array("HybridBody", "Body"), "Select geometrical set or body containing isolated points", True) then

 
yes but still nothing happen when i select geo set.
please help
here is the code
Sub CATMain()
Dim sel: set sel = CATIA.ActiveDocument.Selection
if "Normal" <> sel.SelectElement2(Array("HybridBody", "Body"), "Select geometrical set or body containing isolated points", True) then
exit sub
end if

Dim container: set container = sel.Item(1).Value
Dim prt: set prt = CATIA.ActiveDocument.Part
Dim hsf: set hsf = prt.HybridShapeFactory
Dim sh, coords(2), pointCoord, pointCoordRef
for each sh in container.HybridShapes
if TypeName(sh) = "HybridShapePointExplicit" then
sh.GetCoordinates coords
set pointCoord = hsf.AddNewPointCoord(coords(0), coords(1), coords(2))
set pointCoordRef = hsf.AddNewPointCoordWithReference(0, 0, 0, prt.CreateReferenceFromObject(sh))

pointCoord.Name = sh.Name + "_coords"
pointCoordRef.Name = sh.Name + "_coords_ref"

' append to container
if TypeName(container) = "Body" then
container.InsertHybridShape pointCoord
container.InsertHybridShape pointCoordRef
else
container.AppendHybridShape pointCoord
container.AppendHybridShape pointCoordRef
end if
end if
next
End Sub
 
Does selected geoset has explicit points inside?
Does it has nested geosets? Can you provide a sample part?
 
in the code, typename is specified to "HybridShapePointExplicit"
whereas your points are of type "HybridShapePointTangent"
so the if-loop is not executed

regards,
LWolf
 
fastest way to make it work is to change the line

If TypeName(sh) = "HybridShapePointExplicit" Then
to
If TypeName(sh) = "HybridShapePointExplicit" Or TypeName(sh) = "HybridShapePointTangent" Then

regards,
LWolf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor