Macro Imp
Macro Imp
Macro Imp
Home
Jun 29
2011
About COE
Communities
News
pdfcrowd.com
Kurt
Schloemp
[Oakland
Community
College]
Hello,
I would like to start out with.. I am very new to VBA (or any VB)
I am looking for a solution to a problem i have.
I am trying to copy polylines from a drawing to a sketch.
the issue im having is after i have copied the polylines i cant seem to figure out how to paste them into my sketch.
here is my copy command.
Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.ActiveDocument
Dim Copytext As Selection
Set Copytext = CATIA.ActiveDocument.Selection
Copytext.Clear
Copytext.Search ("Drafting.geometry,2DPolyline")
Copytext.Copy
so my Question is "how do i go about pasting this into a sketch in a CATpart?"
Thanks Kurt
Little
Cthulhu
[Sikorsky
Aircraft]
Hi.
Basically, you paste anything from a buffer using Paste method. But in order for this action to make sense you need to specify not only
WHAT to paste, but also WHERE. So, where's target sketch located?
pdfcrowd.com
Kurt
Schloemp
[Oakland
Community
College]
simple right.. lol, I have it working all the way up to the copy then makes the sketch.. but when it paste in to the sketch it doesnt work.
Jeff Roark
[Johnson
Controls]
Little
Cthulhu
[Sikorsky
Aircraft]
Okay, I've remembered I've done this exact task before. And most likely it was even done on this forum.
pdfcrowd.com
Aircraft]
Create a new part document. Then create a sketch in it's main body (PartBody) and name it "MySketch". Finally, launch script below:
Sub CATMain()
' increase Selection perfomance
CATIA.HSOSynchronized = False
CATIA.RefreshDisplay = False
CATIA.DisplayFileAlerts = False
' get active Part document
Dim PrtDoc As PartDocument
Set PrtDoc = CATIA.ActiveDocument
' create new drawing document
Dim DrwDoc As DrawingDocument
Set DrwDoc = CATIA.Documents.Add("Drawing")
' create a text "My Text" in it
Dim DrwText As DrawingText
Set DrwText = DrwDoc.Sheets.Item(1).Views.Item(1).Texts.Add("My Text", 0, 0)
' save document as .ig2 file
DrwDoc.ExportData "C:\tmp\drawing1.ig2", "ig2"
DrwDoc.Close
' open .ig2 document
Dim Ig2Doc As Document
Set Ig2Doc = CATIA.Documents.Open("C:\tmp\drawing1.ig2")
' get selection object of .ig2 document
Dim Ig2Selection As Selection
' Set Ig2Selection = Ig2Doc.Selection Doesn't work
Set Ig2Selection = CATIA.ActiveDocument.Selection
pdfcrowd.com
pdfcrowd.com
End Sub
Please note, that not all letters are transformed in polylines when exported to .ig2. In my sample text ("My Text") converted "x" letter is
formed by two lines, not single polyline.
Kurt
Schloemp
[Oakland
Community
College]
Little
Cthulhu
[Sikorsky
Aircraft]
pdfcrowd.com
Kurt
Schloemp
[Oakland
Community
thanks, that works.. and i learned something. (which is what really counts.)
College]
pdfcrowd.com
pdfcrowd.com