×
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

Need help in scripting for selection of Points in specific Geo Set

Need help in scripting for selection of Points in specific Geo Set

Need help in scripting for selection of Points in specific Geo Set

(OP)
How to selects the Elements (points) which is in Particular Geometric Set

selection1.Search "Name=Point'.'*,all"
'selection1.Search "type=CATGmoSearch.Point,all"

The above 2 option i tried but it gives selection of all points available in the active sheet. I jus want point selected from a specific geometric set

Does anyone have solution for this

Thanks
Barath :)

RE: Need help in scripting for selection of Points in specific Geo Set

(OP)
Hi
I tried that; but tht is not working.Any other solution can u provide

Thanks
Barath

RE: Need help in scripting for selection of Points in specific Geo Set

Hi,

What Nick wanted to say is that you need first to do a selection (the GS) and then search inside that selection....

CODE --> CATScript

Sub CATMain()

Dim oPartDoc As Part
On Error Resume Next
Set oPartDoc = CATIA.ActiveDocument.Part  
  
If Err.Number <> 0 Then                 
Message = MsgBox("Sorry, This script works with a CATPart as Active document", vbCritical, "Error")
Exit Sub
End If

    ' What do you want to select - in this case a Geometrical Set
    Dim EnableSelectionFor(0)
    EnableSelectionFor(0) = "HybridBody"

    ' Reset the Selection
    Set sSEL = CATIA.ActiveDocument.Selection
    sSEL.Clear

 ' Define Selection
	MsgBox "Please Select the Geometrical Set where you have the POINTS"
    UserSelection = sSEL.SelectElement2(EnableSelectionFor, "Please select another Geometrical Set", False)
  
    ' Evaluation if the selection is correct or not
    If UserSelection <> "Normal" Then
        MsgBox "Error with the selection"
        Exit Sub
Else

Set ohybridbody = sSEL.Item(1).Value
    End If
Set partDocument1 = CATIA.ActiveDocument
Dim selection1 As Selection
Set selection1 = partDocument1.Selection

selection1.Search "CATPrtSearch.Point,sel"

End Sub 

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: Need help in scripting for selection of Points in specific Geo Set

(OP)
Thanks Fernando and Ntweison.

I didn notice that "*.Sel' in that code

This code worked :D.. Actually i dont wanna select the geometric set manually and do it. Rather i know the name of the geometric set. I want both the selection to be done automatically.. Any suggestions


Thanks
Barath :)

RE: Need help in scripting for selection of Points in specific Geo Set

Use
If you know the GS name and sure about the presence of it(only once) (If more then the this method will return first accessed one i think... try it out)

CATIA.ActiveDocument.Part.FindObjectByName(GSName)

Selection.Add Part.FindObjectByName(GSName)
Selection.Search "Name=Point'.'*,sel"

Loop through all the points selected.

Regards,
Maddy

The willingness to share knowledge does not make one charitable; it makes one self-reliant to know more.
Modified - Courtesy of Robert Brault

RE: Need help in scripting for selection of Points in specific Geo Set

(OP)
Hi Maddy

I tried tht; it doesnt work. Actually i have some points int the geometric set named " Geometric Set_Points". i want to extract the coordinates of these points and save it in text or excel. so i wanna select the GS automatically and its points.. so after that some loop to get coordinate for each point in the set

thanks
Barath

RE: Need help in scripting for selection of Points in specific Geo Set


Then try this..

Set oGS = Part.FindObjectByName("Geometric Set_Points")
' MsgBox oGS.Name & " Total Items : " & oGS.HybridShapes.Count ' For confirmation that you got it right.

For Each oPoint in oGS.HybridShapes
If TypeName(oPoint) = "HybridPointTangent" Then
' get the coordinates here using measure option
End If
Next

use the following filter option to get only 3D points out of all the contents of GS.
' HybridPointTangent = Point on curve option
HybridShapePointExplicit = isolated point
HybridShapePointCoord
HybridShapePointOnPlane
HybridShapePointOnSurface
HybridShapePointCenter
HybridShapePointTangent or ' HybridPointTangent i suppose
HybridShapePointBetween

Try with hybridshape and hybridpoint and see the result.. i cant recall completely.

Regards,
Maddy

The willingness to share knowledge does not make one charitable; it makes one self-reliant to know more.
Modified - Courtesy of Robert Brault

RE: Need help in scripting for selection of Points in specific Geo Set

(OP)
HI
i have extracted the poit coordinate by selectiong the Geometric set and the poitns in it automatically..but now the problem is. i want to extract the coordiante of the point with respect to local axis system.. Any suggestion to define local axis system, so tht i can get the coordinate of the point wrt that..
This is the code for which i need to add local axis system...Any suggestions

Sub CATMain()

Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set objNetwork = CreateObject("Wscript.Network")
Set hb1=CATIA.ActiveDocument.Part.InWorkObject
Set hsf=CATIA.ActiveDocument.Part.HybridShapeFactory
Set prt=CATIA.ActiveDocument.Part
Set sel=CATIA.ActiveDocument.Selection
Set SPAWorkBench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")
Set planeZX = CATIA.ActiveDocument.Part.OriginElements.PlaneZX


If Err.Number <> 0 Then
Message = MsgBox("Sorry, This script works with a CATPart as Active document", vbCritical, "Error")
Exit Sub
End If

' Reset the Selection
Set sSEL = CATIA.ActiveDocument.Selection
sSEL.Clear


set FileSys = CATIA.FileSystem

Dim FileObj
Set FileObj = FileSys.CreateFile("D:\pointsout.txt", True)

set TextStr = FileObj.OpenAsTextStream("ForWriting")



Dim selection1
Set selection1 = partDocument1.Selection
Selection1.Add Part1.FindObjectByName("Geometric_Set_Points")
Selection1.Search "CATPrtSearch.Point,sel"

Dim Coord(2)
For i = 1 To Selection1.Count
Dim CurrWorkbench
Set CurrWorkbench = partDocument1.GetWorkbench("SPAWorkbench")
Dim Measure
Set Measure = CurrWorkbench.GetMeasurable(Selection1.Item(i).reference)
Msgbox Measure.Name
Measure. GetPoint Coord
Msgbox Coord(0) & ", " & Coord(1) & ", " & Coord(2)
TextStr.Write(Coord(0) & ", " & Coord(1) & ", " & Coord(2) & vbCrLf)


Next

part1.Update
End Sub

RE: Need help in scripting for selection of Points in specific Geo Set

Use

Get the coordinates of Axis system using GetOrigin iAxisSystemXYZ
Get the vectors of the Axis system using GetVectors you will get X,Y (like 1,0,0 & 0,1,0)
and do a crossproduct to get normal vector i.e Z (0,0,1)

Multiply Sign of X with iAxisSystemXYZ(0) Coord of Axis system
Multiply Sign of Y with iAxisSystemXYZ(1) Coord of Axis system
Multiply Sign of Z with iAxisSystemXYZ(2) Coord of Axis system

Add This resultant values of X,Y,Z to Point coordinates to get the coordinate w.r.t axis system.
Pt(0) + iAxisSystemXYZ(0)*Sgn(x)
Pt(1) + iAxisSystemXYZ(1)*Sgn(y)
Pt(2) + iAxisSystemXYZ(2)*Sgn(z)

Regards,
Maddy

The willingness to share knowledge does not make one charitable; it makes one self-reliant to know more.
Modified - Courtesy of Robert Brault

RE: Need help in scripting for selection of Points in specific Geo Set


Get the coordinates of Axis system using GetOrigin iAxisSystemXYZ
Get the vectors of the Axis system using GetVectors you will get X,Y (like 1,0,0 & 0,1,0)
and do a crossproduct to get normal vector i.e Z (0,0,1)

Multiply Sign of X with iAxisSystemXYZ(0) Coord of Axis system
Multiply Sign of Y with iAxisSystemXYZ(1) Coord of Axis system
Multiply Sign of Z with iAxisSystemXYZ(2) Coord of Axis system

Add This resultant values of X,Y,Z to Point coordinates to get the coordinate w.r.t axis system.
Pt(0) + iAxisSystemXYZ(0)*Sgn(x)
Pt(1) + iAxisSystemXYZ(1)*Sgn(y)
Pt(2) + iAxisSystemXYZ(2)*Sgn(z)

Regards,
Maddy

The willingness to share knowledge does not make one charitable; it makes one self-reliant to know more.
Modified - Courtesy of Robert Brault

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