Macro to add leader for selected points in a dwg sheet
Macro to add leader for selected points in a dwg sheet
(OP)
Hi Friends,
Let me know if we can do that.
Also if i have leader text in an excel sheet, how it can be used.
thnks
vikt
Let me know if we can do that.
Also if i have leader text in an excel sheet, how it can be used.
thnks
vikt





RE: Macro to add leader for selected points in a dwg sheet
Search in my CATIA portable Script Center for Note insertion CATScript, you can adapt the code written there.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Macro to add leader for selected points in a dwg sheet
I tried the script, but it will add a leader to existing text in a view and place the leader arrow at the coordinates given by you.
I used following code
Dim leader1 As DrawingLeader
Set leader1 = View1.Texts.Item(2).Leaders.Add(83.36, -7.33)
My requirement is different.
I have a front view with a 3D point(Generated point) in it.
Now i need a macro to add a leader whose arrow will point at 3D point( which also means, leader will be associated to that 3D point).
Now anchor point for the text that we will add to the leader, can be anywhere on the drawing sheet.
What i understood after trying is, we need an object to access generated items in a view to do dat and then we can add a leader to it.
Not sure how anchor point of the text will be done.
Let me know your comments.
Thanks
vikt
RE: Macro to add leader for selected points in a dwg sheet
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Macro to add leader for selected points in a dwg sheet
no it didn't help, can we try anything else.
Let me know if you need any other input.
Regards,
vikt
RE: Macro to add leader for selected points in a dwg sheet
I used following script to access the generated items.
selection1.Search ("Drafting.'Generated Item'")
It only highlighted all the generated items for the selection( FrontView was selected)
But still i am not able to add leader to the generatedpoint.
Regards,
vikt
RE: Macro to add leader for selected points in a dwg sheet
'Ask user to select a Insertion Location
Set Selection1 = DrawDoc1.Selection
ReDim objSelFilterType1(0)
objSelFilterType1(0) = "AnyObject"
sStatus1 = Selection1.IndicateOrSelectElement2D("Select Leader Head Point", objSelFilterType1, _
False, False, False, objSelected1, PointLocation1)
AnyObject can be also a point, so, if you select your point it will create a leader pointing to your selected point with a text attached to this leader.
Then you can create a positional link of this leader to the selected point.
You can modify the code as you wish, including a loop if you need for more points. I cannot see for the time being other solution to get what you want.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Macro to add leader for selected points in a dwg sheet
Can we do it other way ? like put a text and then add leader, to the generated item point.
I tried this below code. But when it comes to adding leader it should take the generated point.
Below code will also select all the generated points in selected view.
Please have a look and let me know the options.
Regards,
vikt
Sub CATMain()
Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.ActiveDocument
Dim selection1 As Selection
Set selection1 = CATIA.ActiveDocument.Selection
selection1.Search "Drafting.'Generated Item'.Symbol=Cross,all"
Dim view1 As DrawingView
Set view1 = drawingDocument1.Sheets.Item(1).Views.Item(3)
Dim texts1 As DrawingTexts
Set texts1 = view1.Texts
Dim text1 As DrawingText
Set text1 = texts1.Add("Vik", 5, 5)
Dim leader1 As DrawingLeader
Set leader1 = text1.Leaders.Add(***?***)
End Sub
RE: Macro to add leader for selected points in a dwg sheet
I believe you can find a CATScript which will give you the coordinates in drawing in my CATIA Portable Script Center.
Now you have to think, is it really efficient to do such a laborious work in programming to make this task more or less automatically ?
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Macro to add leader for selected points in a dwg sheet
yeah it would be really helpful if you can help me with a code for getting x,y coordinates of a generated point.
I tried finding it in your script center, but couldn't find it.
Also how to add leader to those points.
Regards,
vik
RE: Macro to add leader for selected points in a dwg sheet
CODE --> CATScript
' ============================================================== ' Purpose: Code to create a text file in CATReport folder and write CATDrawing points coordinates inside , all from active view ' Usage: 1 - A CATDrawing document must be active ' 2 - Run macro ' Author: modifed by ferdo, originator unknown (Disclaimer: You use this code at your own risk) ' =============================================================== Sub CATMain() Dim documents1 'As Documents Dim drawDocument1 'As DrawingDocument Dim DrawSheets1 'As DrawingSheets Dim DrawSheet1 'As DrawingSheet Dim GeoEle 'As GeometricElements Dim ele 'As Point2D On Error Resume Next ' Code to create and write in a file ' The resulting file its not so fine, I don't have time to make it look better.... Dim sPath As String Dim sTime As String Dim sName As String Dim sFile As String documentname = CATIA.ActiveDocument.Name position = InStr(documentname,".CATDrawing") position = position -1 documentname = Left(documentname,position) sPath = "c:\Temp\" '~ sPath = CATIA.Application.SystemService.Environ("CATReport") sName = "\XYDrawing_" & documentname & ".TXT" sFile = sPath & sName Set oFileOut = CATIA.FileSystem.CreateFile(sFile,TRUE) Dim oStream As TextStream Set oStream = oFileOut.OpenAsTextStream("ForWriting") ' Code for Points Set documents1 = CATIA.Documents Set drawDocument1 = CATIA.ActiveDocument Set DrawSheets1 = drawDocument1.Sheets Set DrawSheet1 = DrawSheets1.ActiveSheet Set DrawViews = DrawSheet1.Views Set DrawView1 = DrawViews.ActiveView Set GeoEle = DrawView1.GeometricElements For i = 1 To GeoEle.Count Set ele = GeoEle.Item(i) Dim coord(1) if ele.GeometricType = 2 then ' GeometricElement 2 = CatGeotypePoint2D ele.GetCoordinates coord ' change value in inch if you want, just delete ' (the comment sign) coord(0) = coord(0)'/25.4 coord(1)=coord(1)'/25.4 end if Set Point(i) = GeoEle.Item(i).Value oStream.Write (ele.Name&" :"&coord(0)&" , "&coord(1)) Next oStream.close MsgBox "Check the file : " & sFile, vbInformation ' information about where is the file End SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Macro to add leader for selected points in a dwg sheet
RE: Macro to add leader for selected points in a dwg sheet
RE: Macro to add leader for selected points in a dwg sheet
Above method use geometric element property of a view, which will recognize duplicate points coordinates ( created from 3d points)
There is one more limitation for the above method, we are placing leader and text based on coordinates, so if point is modified in 3d, leader in dwg will not update.