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!

i'm going nuts!!!
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!

i'm going nuts!!!






RE: parameters v. properties
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 SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: parameters v. properties
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?????
RE: parameters v. properties
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 SubRE: parameters v. properties
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
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: parameters v. properties
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
RE: parameters v. properties