Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add part and change name

Status
Not open for further replies.

elmundo777

Automotive
Jun 23, 2020
93
BY
Hello everyone. Interested in creating a Part of the document and changing its name (c #, WinFrorms project, the name is taken from the textbox).

If you write a macro in CATIA, then the code looks like this:

Sub CATMain ()
Code:
Dim documents1 As Documents
Set documents1 = CATIA.Documents

Dim partDocument1 As Document
Set partDocument1 = documents1.Add ("Part")

Dim product1 As CATBaseDispatch
Set product1 = partDocument1.GetItem ("Part1")

product1.PartNumber = "agggegeggegweeh"
End Sub


If you use it in C #, it doesn't see PartNumber method:

product1.PartNumber = "agggegeggegweeh"

C # code:

Code:
var documents1 = CATIA.Documents;

  var partDocument1 = documents1.Add ("Part");

  var product1 = partDocument1.GetItem ("Part1");

product1.[b]PartNumber[/b] = "agggegeggegweeh";

errrr_s1u7p3.png

 
Replies continue below

Recommended for you

var doc = documents1.Add("Part") as MECMOD.PartDocument;
doc.Product.set_PartNumber("aggeggafdrtg");
 
Little Cthulhu said:
var doc = documents1.Add("Part") as MECMOD.PartDocument;
doc.Product.set_PartNumber("aggeggafdrtg");
This code works perfectly! Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top