Formating lines in a CATIA drawing from a macro in Excel
Formating lines in a CATIA drawing from a macro in Excel
(OP)
I am creating a macro in Excel that takes x and y data from a worksheet and then brings them into a CATIA drawing and draws lines. I can get it to draw the lines just fine, but I am having trouble formatting the lines. The problem seems to be with the ".Selection" part. I get the error "Object doesn't support this property or method". Is there another way to format lines without .Selection? I don't know if it makes a difference, but I am doing this in V6.
Sub CATMain()
Dim CATIA As Object
Set CATIA = GetObject(, "CATIA.Application" )
Set DrwDocument = CATIA.ActiveDocument
Set DrwSheets = DrwDocument.Sheets
Set DrwSheet = DrwSheets.ActiveSheet
Set DrwView = DrwSheet.Views.ActiveView
Set Fact = DrwView.Factory2D
Dim Line1 As Object
Set Line1 = Fact.CreateLine(0, 0, Range("A1").Value, Range("B1").Value)
Line1.Name = "Line1"
CATIA.ActiveDocument.Selection.VisProperties.SetRealWidth 3,1
End Sub
Sub CATMain()
Dim CATIA As Object
Set CATIA = GetObject(, "CATIA.Application" )
Set DrwDocument = CATIA.ActiveDocument
Set DrwSheets = DrwDocument.Sheets
Set DrwSheet = DrwSheets.ActiveSheet
Set DrwView = DrwSheet.Views.ActiveView
Set Fact = DrwView.Factory2D
Dim Line1 As Object
Set Line1 = Fact.CreateLine(0, 0, Range("A1").Value, Range("B1").Value)
Line1.Name = "Line1"
CATIA.ActiveDocument.Selection.VisProperties.SetRealWidth 3,1
End Sub





RE: Formating lines in a CATIA drawing from a macro in Excel
Yes, is making the difference. I believe instead of ActiveDocument you have to use ActiveEditor. Did you checked the DSYAutomation.chm file ?
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Formating lines in a CATIA drawing from a macro in Excel
Thanks!