Sei sulla pagina 1di 4

HomeForumsEngineeringComputerProgramsEngineeringProgramsDASSAULT:CATIAproductsForum

[MacroCATIA]changecutviewtext
thread560362128

Read
NewPosts

Hi,

I'mcurrentlyworkingwithCATIAV5,andiwanttouseMacros(VBA),butihavesomeproblems!

Myquestionis:howtochangethetextofacutview?(seethepicture)

http://www.hostingpics.net/viewer.php?id=65419615c...

itriedtouse:myView.Texts.item(1)toaccesstothis"text"butithinkthatCATIAdontconsideritastext...

Thanksforyourhelp,

Somethingtostart...

CODE>

SubChange_NameID()

DimoDrawingAsDrawingDocument
SetoDrawing=CATIA.ActiveDocument

DimoSheetsAsDrawingSheets
SetoSheets=oDrawing.Sheets

DimoSheetAsDrawingSheet
SetoSheet=oSheets.Item(1)

DimoViewAsDrawingView
SetoView=oSheet.Views.Item(4)'PutTheSectionviewitemnumber
oView.Activate

oView.SetViewName"Sectionview","B",""

EndSub

HiAlexLozoya,

thanksforyouranswer,butineedtochangethevalueoftextwhichindicatesthesourceofcutview(youcanseethepicture...)

cansomeonehelpmetoresolvrethisproblem?

WhatAlexwroteiscorrect,whatyoumarkedinthepictureislinkedwithwhatAlexwroteinthecode.BychangingtheViewNameitwillchangealsotheletterwhichyoumarkedup.

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

CODE>

oView.SetViewName"","B",""'<justchangetheletter"B"withtheletterofyourchoice..

thanksforyouranswerferdo...
butifidoublecliconthistexticanchangeitwithoutaffectingthecutviewname...andiwanttodothatwithamacro...ihopethatyouunderstandwhatimean...

AlexLozoya:iwanttochangethevalueofthistextwithoutchangingthenameofthecutview...manuallyit'spossible...butwithmacroidontknowhow...

Hi,

Technicallyspeaking,thattextandnameoftheviewshouldbeconnected(youknow,papercansupportanything...).Ifyouwillmodifyonlythetextitwillbelinkedtowhat(supposeyouwanttochan
view(BBifexisting)?Orissomethingbitmorespecific?

Still,ifyouwanttodoitinmacro,yourmarkupisatext,youcantelltousertoselectthetextandinmacro,inselection,youcanreplaceoldtextwithnewone.
Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

iftheuserselectthis"text"...catiadontconsideritastext...soyoucan'tchangeit...thisistheproblem...

idontbelievethatwecan'tmakethissimpletaskwithCATIAVBA...it'ssad...

Hi,

Firstselectthetextlikeinyourmarkup,thenrunthisCATScript

CODE>CATScript

Language="VBSCRIPT"

SubCATMain()

DimmyString'AsDouble
myString="ENTERTEXT"
myString=InputBox("Pleaseenterthetext",myString,"Whateveryouwant")

SetdrawingDocument1=CATIA.ActiveDocument
Setselection1=drawingDocument1.Selection

selection1.Item(1).Value.Text=myString

EndSub

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

ThanksFernando,yourcodeworkperfectly...

Icanchangethistextwiththismethod,butmyobjectifistodothatwithouttheinterventionoftheuser...idontknowwhycatiadontconsideritastext,soicanaccesstoitwithtextscollection...

anyonecanhelpme?

Ifiusethiscodewithmydrawing(http://www.hostingpics.net/viewer.php?id=65419615c...):

CODE>

SubCATMain()
SetdrawingDocument1=CATIA.ActiveDocument
SetdrawingSheets1=drawingDocument1.Sheets
SetdrawingSheet1=drawingSheets1.Item(1)
SetdrawingViews1=drawingSheet1.Views
SetdrawingView1=drawingViews1.Item(3)
SetdrawingComponents1=drawingView1.Texts
MsgBoxdrawingComponents1.Count
EndSub

whytheresultis0?it'sconfusing

CATIA

Hi,

Thatisnotacomponent(unlessyouareinsertingonefromacatalog...),that'swhyyouhave0(atleastinyourscreenshotwecannotseeifisacomponent/dittoorsomethingelse).

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

icreatedthis"text"bycreatingacutview...wecan'tknowthetypeofthisobject?

Hi,

Youhavetwopicturesattached,bothofthemisshowingsamething,thatletterAisatext.FirstpictureausedamacrotodeterminewhatistheselectedelementandsecondisbysearchinginCATI
Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

http://files.engineering.com/getfile.aspx?folder=a4dab759220c4ce59502b7

Andthesecondpicture...

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

http://files.engineering.com/getfile.aspx?folder=5a0ecd45af5a48df9b22a0

it'sastrangeproblem...formeinthiscasetextsCollection.countreturn0!

ifit'sadrawingtext...whywecan'tfounditintextscollection?

Hi,

Isawyourquestiononstackoverflow,...ifyouwantananswer,youhavetoexplainveryclearthewholescenario,putyourcodehere(asmuchasyoucan,tounderstandwhatyouwanttodo)ando

Anyway,definitelythatletterAisadrawingtext,asisshowninsecondattachmentpicture,thequerywassearchadraftingtextstring(letterA).Ifyouwanttochangewithoutuserintervention,you
codebyyou(eventuallyusingsearchfunction).

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

drawingView1=drawingViews1.Item(3).value?

EricN.
indoctidiscantetamentmeminisseperiti

hiferdo,

myquestionisclear...ifitisadrawingtext,whycan'tfinditinthetextscollection?thisismycode:
CODE>

SubCATMain()
SetdrawingDocument1=CATIA.ActiveDocument
SetdrawingSheets1=drawingDocument1.Sheets
SetdrawingSheet1=drawingSheets1.Item(1)
SetdrawingViews1=drawingSheet1.Views
SetdrawingView1=drawingViews1.Item(3)
SetdrawingTexts1=drawingView1.Texts
MsgBoxdrawingComponents1.Count
EndSub

thatreturn0,sothetextscollectionisempty...ifit'sadrawingtext,thecollectionshouldn'tbeempty,ishouldfinditinthiscollection.

thankyou!

Didyousearchedinv5automationfilewhatitmeansdrawingComponents?

Bellowisacodewhichissearchingtextsinallyourdrawing,seewhatyoucanget.

CODE>CATScript

Language="VBSCRIPT"

SubCATMain()

DimdrawingDocument1AsDocument
SetdrawingDocument1=CATIA.ActiveDocument

Dimselection1AsSelection
Setselection1=drawingDocument1.Selection

selection1.Search"CATDrwSearch.DrwText,all"
Fori=1toselection1.Count
MsgBoxselection1.Item(i).Value.Text
Next

EndSub

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

collection.item(x).valuewillreturntheobjectinthecollection

EricN.
indoctidiscantetamentmeminisseperiti

thankyouferdo,ididntseeyouranswer...it'sasmartsolution,but:
selection1.Search"CATDrwSearch.DrwText,all"

willsearchinallthedrawingdocumentsoitwillconsumlotofmemory...canisearchjustintheactiveview?howcanidothat?

Ofcourseyoucan,justaskusertoselectaview,makeitactiveincode,thenusesamecodebutinsteadofusing

selection1.Search"CATDrwSearch.DrwText,all"
youcanuse
selection1.Search"CATDrwSearch.DrwText,sel"

oryoucanusethenameoftheview(ifisaconstant)thenusesametechnique.Theideaistomakefirsttheselection...

Hereissomethingwhichyoucanusealso.

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

thankyouagainferdo,itworks!

MarkThreadfor
EmailNotification..

Home>Forums>EngineeringComputerPrograms>EngineeringPrograms>DASSAULT:CATIAproductsForum

IndeedJobs|Advertise

Copyright19982016ENGINEERING.com,Inc.Allrightsreserved.
Unauthorizedreproductionorlinkingforbiddenwithoutexpressedwrittenpermission.RegistrationonoruseofthissiteconstitutesacceptanceofourPrivacyPolicy.

Potrebbero piacerti anche