Forum Replies Created
Do you mean use parameters to measure distance between two objects? Is so, check out this article: http://www.scripting4v5.com/additional-articles/how-to-measure-distance-between-two-points-catia-macro/
Hi. These codes might give you an idea of how to do it:
call CATIA.SystemService.ExecuteBackGroundProcessus(“WScript.exe c:\CATScripts\read_user_environment.vbs”)
‘how to call one catscript from another
ScPath = “D:\tmp”
MsgBox “Save Operation will be executed on the active document!”
CATIA.SystemService.ExecuteScript scpath, catScriptLibraryTypeDirectory, “Save.CATScript”, “CATMain”, EmptyPar
Hi. Are you trying to search for just the CATParts or search just within CATparts?
Selection1.Search “CATPrtSearch.Surface, All”
Hi Niklas. The first step is to choose a point or multiple points – how do you want to accomplish that? By user selection before the macro is started, by user selection while the macro is running, or automatically with macro searching for points by name or type?
Hi Cimonc. You should be able to automate your process. I would begin by working through each of the steps you listed individually then combine it all together. For #1, see the unlock drawing view macro on my downloads page: http://www.scripting4v5.com/downloads/
Let me know if you get stuck! Good luck.
Hi. This measurement macro will show you how to deal with parameters: http://www.scripting4v5.com/additional-articles/how-to-measure-distance-between-two-points-catia-macro/
If you’re trying to do something specific and are having a problem please let me know.March 15, 2015 at 12:22 am in reply to: Macro for closing a document automatically on License error #1569
Hi. Can you explain more? Have you tried writing any code yourself? What license error? Closing a document is easy.
Hi. Do you have to use Send Keys? I’ve found they are quite unreliable.
Hi Alex! Thanks for joining the forum. Glad to see you’re working in automotive industry.
Hi there. So while in CATIA, if you press alt+f8 the macro window comes up but if you press alt+f11 you get the above posted error message?
So you’ve tried this exact code and nothing happens:123oExcel.Cells(1,1) = "UPDATE"oExcel.Cells(1,3).Formula="NOW()"oExcel.Cells(1,3).NumberFormate="m/d/yyy"
If you use the code above, do you get the text in cell A1 but nothing in cell C1?
Hi Antonello, to get started see the following macro to loop through all dimension texts:123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172Sub CATMain()' Access through document's structureDim DrwDoc As DrawingDocumentSet DrwDoc = CATIA.ActiveDocumentDim colSheets As DrawingSheetsSet colSheets = DrwDoc.SheetsDim ActSheet As DrawingSheetSet ActSheet = colSheets.ActiveSheetDim colViews As DrawingViewsSet colViews = ActSheet.ViewsDim ActView As DrawingViewSet ActView = colViews.ActiveViewDim curDrwDim As DrawingDimensionDim DrwDimCount As IntegerDrwDimCount = ActView.Dimensions.CountDim i As Integer'loop through all dimensionsFor i = 1 To DrwDimCount' retrieve dimensionSet curDrwDim = ActView.Dimensions.Item(i)' set circle frame around dimension textcurDrwDim.ValueFrame = catFraCircleNext 'iEnd Sub
Just added a new article about this topic here: http://www.scripting4v5.com/additional-articles/how-to-measure-distance-between-two-points-catia-macro/
Yes, you can modify to code to measure between a point and a plane.Edit this line:
Set formula1 = relations1.CreateFormula(“Formula.2”, “”, length1, “distance(‘Geometrical Set.1\MyEndPt1′ ,’Geometrical Set.1\MyEndPt2’) “)
HI. Sorry for the confusion, I will have to clean up that section of the book in the next version.Please see the code below. The attached picture also shows how it should look. Try it and let me know.12345678910111213141516171819202122232425262728293031323334353637'this macro creates a parameter and relation to measure the distance between two pointsLanguage="VBSCRIPT"Sub CATMain()'active document is a single part fileDim partDocument1 As DocumentSet partDocument1 = CATIA.ActiveDocumentDim part1 As PartSet part1 = partDocument1.PartDim parameters1 As ParametersSet parameters1 = part1.Parameters'create a new length type parameter, set its value to 0 for nowDim length1 As DimensionSet length1 = parameters1.CreateDimension("", "LENGTH", 0.000000)'if you want to rename the parameterlength1.Rename "MeasureDistance"'create a new formula to link to the parameterDim relations1 As RelationsSet relations1 = part1.Relations'make sure points are labeled MyEndPt1 and MyEndPt2 respectivelyDim formula1 As FormulaSet formula1 = relations1.CreateFormula("Formula.2", "", length1, "distance(<code>Geometrical Set.1\MyEndPt1</code> ,<code>Geometrical Set.1\MyEndPt2</code> ) ")'rename the formulaformula1.Rename "Distance"'display the distance the endpoints are apart in a messageboxMsgbox "The endpoints are " & length1.ValueAsString & " apart."End Sub