vbscript - How to translate a part using CATscript in CATIA? -
i working catscript in catia create macros. trying create catscript translate feature in catia.
when run catscript should select feature should translated , and feature translated.
but getting runtime error type mismatch:'part1.createreferencefromobject'
i not find solution problem. looking forward help.
thanks in advance.
sub catmain() set partdocument1 = catia.activedocument set part1 = partdocument1.part set hybridshapefactory1 = part1.hybridshapefactory set hybridshapedirection1 = hybridshapefactory1.addnewdirectionbycoord(1.000000, 0.000000, 0.000000) set hybridshapetranslate1 = hybridshapefactory1.addnewemptytranslate() set usersel = partdocument1.selection dim type1(0) type1(0) = "hybridshape" '-------------------------------------- 'dim input object input = usersel.selectelement2(type1, "select input.", false) set reference1 = part1.createreferencefromobject(input) hybridshapetranslate1.elemtotranslate = reference1 hybridshapetranslate1.direction = hybridshapedirection1 hybridshapetranslate1.distancevalue = 1.000000 set hybridbody2 = hybridbodies1.item("geometrical set.3") hybridbody2.appendhybridshape hybridshapetranslate1 part1.inworkobject = hybridshapetranslate1 part1.update end sub
your problem trying create reference selection object.
input = usersel.selectelement2(type1, "select input.", false)
this returns type selection. can dig input , actual object select.
try:
dim myreference reference dim myexpectedobject hybridshape 'or use variant set myselectedobject = input.item2(1).value 'this grab first item selection collection set myreference = part1.createreferencefromobject(myselectedobject) 'continue rest of code
also, should clear selection before use user selection habit.
usersel.clear 'call before call selectelement selection function
Comments
Post a Comment