×
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

parameters v. properties

parameters v. properties

parameters v. properties

(OP)
i need help with parameters and properties.

i need to access the diameter of a wire bundle. i can see it on the bundle definition form, no problem there.
now how do i pull it into my VB code? what is the syntax to ask for it?

i know it's part of a sketch but is it a parameter or a property??

i have:
oSelc.Search ("name = circle.1, all")
x2 = oSelc.Item(i).Value.Parent.Parent.Name ---- tells me i am in a sketch.
so how do i ask x2 what it's diameter is??????
right now x2 is just a string, but that's ok.
what do i augment 'oSelc.Item(i).Value.Parent.Parent.Name' with to ask for it's diameter????

is it a parameter or a property?
i need to use it to crunch some other values that i have imported into my code. the crunching is a no brainer.
my issue is that i can't get it into my code into a variable!

banghead
i'm going nuts!!! cat2cat2

RE: parameters v. properties

Hi,

This will get the radius value of a circle (in sketch or an edge in 3D). It will give you some ideas...but I know for bundles is a different story, so, a sample file would be good to have it to test on it.

CODE --> CATScript

Dim Language As String
Language="VBSCRIPT"

Sub CATMain()
Dim  colDocum        As Documents        
Dim  DocActivo       As Document          
Dim  part1           AS Part              
    
Dim  sStatus             As String       
Dim  mySelection         As Selection         
Dim InputObjectType(0)
InputObjectType(0) = "AnyObject"    
Dim refBorde              As Reference  

Set DocActivo = CATIA.ActiveDocument
Set part1 = DocActivo.Part
Set mySelection = DocActivo.Selection

MsgBox "Select a circle "
Status = mySelection.SelectElement2(InputObjectType, "Select a circle or hit ESCAPE: ", True)
   If (sStatus = "Cancel") Then
	Exit Sub
   End If

Set refBorde = mySelection.Item(1).Value
Dim TheSPAWorkbench As Workbench
Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")
Dim TheMeasurable As Measurable
Set TheMeasurable = TheSPAWorkbench.GetMeasurable(refBorde)

myRadius = TheMeasurable.Radius

MsgBox TheMeasurable.Name & " (meaning Radius) = " & myRadius
mySelection.Clear

End Sub 

Regards
Fernando

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

RE: parameters v. properties

CODE -->

Sub Get_Diameter()

Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument

Dim oPart As Part
Set oPart = partDocument1.Part

Dim oBody As Body
Set oBody = oPart.Bodies.Item("PartBody")

Dim selection1 As Selection
Set selection1 = partDocument1.Selection
selection1.Clear
selection1.Search ("name = circle.1, all")

x2 = selection1.Item(1).Value.Parent.Parent.Name
Dim oSketch As Sketch
Set oSketch = oBody.Sketches.Item(x2)

Dim geometricElements1 As GeometricElements
Set geometricElements1 = oSketch.GeometricElements

Set joe = geometricElements1.GetItem("Circle.1")

Diameter = (joe.Radius / 25.4) * 2

End Sub 

RE: parameters v. properties

(OP)
i hope i did not confuse you ... i'm NOT trying to change the diameter. i just want to read it.
i tried this per your code ... i added some msgboxes to help

Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
Dim oPart As Part
Set oPart = partDocument1.Part
Dim oBody As Body
Set oBody = oPart.Bodies.Item("PartBody")
Dim selection1 As Selection
Set selection1 = partDocument1.Selection
Dim oSketch As Sketch
Set oSketch = oBody.Sketches.Item(x2)
Dim geometricElements1 As GeometricElements
Set geometricElements1 = oSketch.GeometricElements

selection1.Clear
selection1.Search ("name = circle.1, all")
sCount = selection1.Count

For i = 1 To sCount
x2 = selection1.Item(i).Value.Parent.Parent.Name
Set joe = geometricElements1.GetItem("Circle.1")
joeR = joe.Radius
joeD = (joe.Radius) * 2
msg = "selection1 x2 = " & x2
msg = msg & vbNewLine & "radius = " & joeR
msg = msg & vbNewLine & "diameter = " & joeD
Buttons = vbOKCancel + vbDefaultButton1
Title = "diameter found ..."
x = MsgBox(msg, Buttons, Title)
If x = vbCancel Then
oSel.Clear
Exit Sub
End If
Next

it failed. see attachment ...

RE: parameters v. properties

i do not have the license for Electrical Workbench..

I think that the code may work because the circle its on the sketch.

But i did not know that is different.. sorry

RE: parameters v. properties

(OP)
fredo, how do i access bundle parameters?

RE: parameters v. properties

Just for curiosity.... the name of the body where you have placed the sketches is "Partbody".. right??

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