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!

parameters v. properties

Status
Not open for further replies.

jewely

Automotive
Dec 12, 2012
11
US
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!!! [cat2][cat2]
 
Replies continue below

Recommended for you

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:
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

 
well not quite.

here is the form with the diameter as the second element/value. i want to read it in to my code and put it into a variable.

how do i do it? what is the correct syntax to ask for it?
do i use 'analyze' or get tiem or what?????


 
 http://files.engineering.com/getfile.aspx?folder=8a6ab80a-0c4b-4e45-a2a4-803f784cf15f&file=branch_definition.jpg
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
 
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 ...
 
 http://files.engineering.com/getfile.aspx?folder=c54a92ac-dd3d-48e1-941e-735e4de4f7f9&file=diameter_results.jpg
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
 
fredo, how do i access bundle parameters?
 
Just for curiosity.... the name of the body where you have placed the sketches is "Partbody".. right??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top