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!

Error on creating reference 2

rookiezzz

Structural
Jul 27, 2022
22
Hello all,

Here is my code:

Dim hybridShapeLineNormal1 As HybridShapeLineNormal
Set hybridShapeLineNormal1 = hybridShapeFactory1.AddNewLineNormal(reference3, reference1, -5.000000, 5.000000, False)
Set reference4 = Catia.activedocument.part.CreateReferenceFromGeometry(hybridShapeLineNormal1)
Set TheMeasurable = TheSPAWorkbench.GetMeasurable(reference1)
MinimumDistance = TheMeasurable.GetMinimumDistance(reference4) - error occur on this line, I think sth wrong on reference4

Could anybody guide how to create a reference on the object existed in background? I don't want this line appear in my model, it wastes time.
 
Replies continue below

Recommended for you

hybridShapeLineNormal1.Compute
Hello, Thanks for your reply. It works.

Could you help on further issue.
When I project a curve on single surface, there could be multi-result under SolutionType = 1.
I want to loop through all single curve in this hybridShapeProject1.But I failed.
If i update this geo to my model then select it, it works. Please kindly guide me how to select the geo in background. Thanks !!!

Here is the code:

Set hybridShapeProject1 = hybridShapeFactory1.AddNewProject(referencerotate, referencesurfaceclosest)
hybridShapeProject1.SolutionType = 1
hybridShapeProject1.Normal = True
hybridShapeProject1.SmoothingType = 0
hybridShapeProject1.ExtrapolationMode = 0
hybridShapeProject1.compute
set referencetest = Catia.activedocument.part.CreateReferenceFromGeometry(hybridShapeProject1)
Set oSel9 = oDoc.Selection
oSel9.clear
oSel9.add(hybridShapeProject1) ' can't select it and its reference
oSel9.Search ("Topology.CGMEdge,sel")
msgbox(oSel9.count) ' it reports 0
 
you need to add/create the actual project-feature (inside a geo-set i.e a hybridbody)
yourhybridBody.AppendHybridShape hybridShapeProject1
yourpart.UpdateObject hybridShapeProject1
yourhybridbody and yourpart are defined prior in your code
 
you need to add/create the actual project-feature (inside a geo-set i.e a hybridbody)
yourhybridBody.AppendHybridShape hybridShapeProject1
yourpart.UpdateObject hybridShapeProject1
yourhybridbody and yourpart are defined prior in your code
Thanks for your reply LWolf!

So I can't access to the edge from what I created in background in any method?
That's terrible, I have tried to update its model in 3D. It takes too much time..
I rotate and project a line in 360 degrees, means 360 projection lines will be added into my model...
 
What is your initial task?
Thanks for reply

I try to describe it as detailed as I can since it is weekend,and I will get on laptop next monday

My task is to return the min width of surface ,and this width need to through a specific point on this surface.

Then I try to project a line through this point in each degree to get the min width.It works perfectly if there is no hole on the surface. If the projection line cross the hole,the part which contains the point shall be return
 

Attachments

  • mmexport1731077177778.jpg
    mmexport1731077177778.jpg
    479.3 KB · Views: 4
Use AddNewLinePtDirOnSupport instead of projection. This way your line ends at first boundary edge, including hole's one.
 
Use AddNewLinePtDirOnSupport instead of projection. This way your line ends at first boundary edge, including hole's one.
Thank you so much Cthulhu,I will take a try next week. I have checked the API doc. It shall work. Have a nice weekend.
 
Use AddNewLinePtDirOnSupport instead of projection. This way your line ends at first boundary edge, including hole's one.
Hello Cthulhu, thanks for your help always.

Have you ever tried to find the closest surface and edge from a body against a specific point?
I loop through and measure the distance, is that possible to project the point to body and idenify the projection result belongs to which surface?

Here is my current code.

Set oSel = oDoc.Selection
oSel.add(body1)
oSel.Search "Topology.face,sel"
x =20000
for i = 1 to oSel.count
Set referenceSurface = oSel.item(i).value
Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")
Set TheMeasurable = TheSPAWorkbench.GetMeasurable(referencepoint)
MinimumDistance = TheMeasurable.GetMinimumDistance(referencesurface)
if MinimumDistance < x then
x = MinimumDistance
Set referencesurfaceclosest = oSel.item(i).value
end if
next
 
Last edited:
Start a new thread and specify what do you mean by "surface of a body". A face?
 

Part and Inventory Search

Sponsor