0% found this document useful (0 votes)
149 views2 pages

Line Normal To Surface

This macro places normal line vectors with a length of 25.4 mm on a surface in preselected points from the tree. It requires the active document to be a CATPart with a surface renamed to "Norm Surface" and a geometric set named "vectors" to contain the lines. The macro loops through the selected points, creates a reference to the surface and point, and adds a line between them to the "vectors" body.

Uploaded by

Ka Việt Anh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
149 views2 pages

Line Normal To Surface

This macro places normal line vectors with a length of 25.4 mm on a surface in preselected points from the tree. It requires the active document to be a CATPart with a surface renamed to "Norm Surface" and a geometric set named "vectors" to contain the lines. The macro loops through the selected points, creates a reference to the surface and point, and adds a line between them to the "vectors" body.

Uploaded by

Ka Việt Anh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Language="VBSCRIPT"

Sub CATMain()

CATIA.DisplayFileAlerts = False

Dim Message, Style, Title, Response, MyString


Message = ("This macro will put normal line vectors with a lenght of 25.4 mm on
a SURFACE (not extract or something else, so please use copy-paste special-as
result, same thing for the wanted points were you want the lines) in preselected
points in the TREE, not in working space window" &_
(chr(13)) &_
" - The active document must be a CATPart"&_
(chr(13)) &_
" - You must rename the wanted used surface for the macro
to Norm Surface"&_
(chr(13)) &_
" - You must have a geometrical set named vectors active
and in top of all other geometrical sets - the lines will be created there"&_
(chr(13)) &_
" - If you want something else, change values in macro"&_
""&(chr(13))&_
" Do you want to continue ?")
Style = vbYesNo + vbDefaultButton2 'Define buttons.
Title = "Purpose "
Response = MsgBox(Message, Style, Title)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes"

end if

'/////////////////////////////////////

Dim listOfTypes(1)
listOfTypes(1)="Point"

Dim myDocument
Set myDocument = CATIA.ActiveDocument

Dim mySelection As Selection


Set mySelection = myDocument.Selection

Dim mySelection2 As Selection


Set mySelection2 = myDocument.Selection

Dim number
number = mySelection.Count

'mySelection.EndSelectElement

number = mySelection.Count

Dim selectedElement As SelectedElement


for i=1 to number
Set selectedElement = mySelection.Item(i)
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument

Dim part1 As Part


Set part1 = partDocument1.Part

Dim hybridShapeFactory1 As Factory


Set hybridShapeFactory1 = part1.HybridShapeFactory

Dim parameters1 As Parameters


Set parameters1 = part1.Parameters

Dim hybridShapeSurfaceExplicit1 As Parameter


Set hybridShapeSurfaceExplicit1 = parameters1.Item("Norm Surface")

Dim reference1 As Reference


Set reference1 = part1.CreateReferenceFromObject(hybridShapeSurfaceExplicit1)

Dim parameters2 As Parameters


Set parameters2 = part1.Parameters

Set SelectedElement = mySelection.Item(i)


Set MyPoint = SelectedElement.Value

Dim hybridShapePointExplicit1 As Parameter


Set hybridShapePointExplicit1 = parameters2.Item(MyPoint.name)

Dim reference2 As Reference


Set reference2 = part1.CreateReferenceFromObject(hybridShapePointExplicit1)

Dim hybridShapeLineNormal1 As HybridShapeLineNormal


Set hybridShapeLineNormal1 = hybridShapeFactory1.AddNewLineNormal(reference1,
reference2, 12.700000, -12.700000, False)

Dim hybridBodies1 As HybridBodies


Set hybridBodies1 = part1.HybridBodies

Dim hybridBody1 As HybridBody


Set hybridBody1 = hybridBodies1.Item("vectors")

hybridBody1.AppendHybridShape hybridShapeLineNormal1

part1.InWorkObject = hybridShapeLineNormal1

next

part1.Update

End Sub

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy