Вы находитесь на странице: 1из 4

21/01/2017

RetrievesketchdimensionofpartdocumentinsideassemblyManufacturingDevBlog

ManufacturingDevBlog
(http://adndevblog.typepad.com/manufacturing/)

TheresourceforsoftwaredevelopersworkingwithDesign,LifecycleandSimulationtechnologiesfromAutodesk.

03/10/2016

Retrievesketchdimensionofpartdocumentinsideassembly
ByAdamNagy(http://adndevblog.typepad.com/manufacturing/adamnagy.html)
Thereisalreadyasimilarpost(http://adndevblog.typepad.com/manufacturing/2015/08/retrievesketchdimensionofpartdocumentinsidederivedassembly.html)relatedto
DerivedAssemblies.Thedifferencethereisthatinthatcaseyoucouldnotgetaproxyforasketchentitybecausethereisnodirectconnectionbetweentheproxyinsidethederived
documentandthenativeobjectintheoriginaldocument:
http://adndevblog.typepad.com/manufacturing/2014/11/getedgeinderivedpartthatdrivesworkpoint.html(http://adndevblog.typepad.com/manufacturing/2014/11/getedgein
derivedpartthatdrivesworkpoint.html)
Incaseofanormalassemblyweneedtogettheproxy(http://adndevblog.typepad.com/manufacturing/2013/07/occurrencescontextsdefinitionsproxies.html)forthesketchdimension
entitythatresidesinsidethepartdocument.Wecanthenusethattoretrievewhatweneed.

(http://adndevblog.typepad.com/.a/6a0167607c2431970b01bb08c671ad970dpopup)
SubRetrieveDimension()

DimoDwgAsDrawingDocument
SetoDwg=ThisApplication.ActiveDocument

DimoSheetAsSheet
SetoSheet=oDwg.ActiveSheet

DimoViewAsDrawingView
SetoView=oSheet.DrawingViews.Item(2)

DimoAsmDocAsAssemblyDocument
SetoAsmDoc=oView.ReferencedDocumentDescriptor.ReferencedDocument

DimoRefOccAsComponentOccurrence
SetoRefOcc=oAsmDoc.ComponentDefinition.Occurrences.Item(1)

DimoPartDocAsPartDocument
SetoPartDoc=oRefOcc.Definition.Document

DimoPartCompDefAsPartComponentDefinition
SetoPartCompDef=oPartDoc.ComponentDefinition

DimoDCAsDimensionConstraint
SetoDC=oPartCompDef.Sketches(1).DimensionConstraints(1)

DimoDCproxyAsObject
CalloRefOcc.CreateGeometryProxy(oDC,oDCproxy)

DimoObjCollAsObjectCollection
SetoObjColl=ThisApplication.TransientObjects.CreateObjectCollection()

CalloObjColl.Add(oDCproxy)

CalloSheet.DrawingDimensions.GeneralDimensions.Retrieve(oView,oObjColl)

EndSub

http://adndevblog.typepad.com/manufacturing/2016/03/retrievesketchdimensionofpartdocumentinsideassembly.html

1/4

21/01/2017

RetrievesketchdimensionofpartdocumentinsideassemblyManufacturingDevBlog

(http://adndevblog.typepad.com/.a/6a0167607c2431970b01b8d1ac275d970cpopup)
Note:ifforsomereasonretrievingaspecificdimensionisnotworkingthenyoucouldworkarounditbyretrievingallthedimensionsanddeletingtheonesyoudon'tneed:
DimoDimsAsGeneralDimensionsEnumerator
SetoDims=oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oView)

DimoAsObject
ForEachoInoDims
IfNoto.RetrievedFromIsoDCproxyThen
Callo.Delete
EndIf
Next
Postedat04:44AMinAdamNagy(http://adndevblog.typepad.com/manufacturing/adamnagy/),Inventor(http://adndevblog.typepad.com/manufacturing/inventor/)|Permalink
(http://adndevblog.typepad.com/manufacturing/2016/03/retrievesketchdimensionofpartdocumentinsideassembly.html)
(http://twitter.com/share?url=http%3A%2F%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F03%2Fretrievesketchdimensionofpartdocumentinside
assembly.html&text=Retrieve%20sketch%20dimen...)

(https://plus.google.com/share?url=http://adndevblog.typepad.com/manufacturing/2016/03/retrievesketchdimensionof

partdocumentinsideassembly.html)

(http://www.facebook.com/sharer.php?u=http%3A%2F%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F03%2Fretrieve
sketchdimensionofpartdocumentinsideassembly.html)

Comments
polsaid...

I'mhavingsomeissuesinthisline:
DimoDCAsDimensionConstraint
oDC=oPartCompDef.Sketches(1).DimensionConstraints(1)
Anyidea?I'mjusttryingtoretrievenameddimensions...
Ihavemanagedtoretrievethemallandtheneraseunwanted,butithasnouseformesincetheremightbealotofdimensions,takingahugetimetorecoverthemandthenerase.
Reply
12/28/2016at06:46AM(http://adndevblog.typepad.com/manufacturing/2016/03/retrievesketchdimensionofpartdocumentinsideassembly.html#comment
6a0167607c2431970b01b8d24b2fba970c)
AdamNagy(http://profile.typepad.com/1236098880s16462)said...

Whatexacterrorareyougettingonthatline?YoushouldtryitfromVBAandthendebugintothecodeandinvestigatethevariousobjects.Maybeinthatspecificsketchyoudon'thave
dimensionconstraints?
ThebestthingwouldbetopostthisquestionontheInventorCustomisationforum.That'smuchbetterforthisthanthecommentssectionoftheblog:)
Reply
12/29/2016at01:58AM(http://adndevblog.typepad.com/manufacturing/2016/03/retrievesketchdimensionofpartdocumentinsideassembly.html#comment
6a0167607c2431970b01bb09649a05970d)
polsaidinreplytoAdamNagy(http://profile.typepad.com/1236098880s16462)...

Okthanksforyourfastanswerandapologizeforpostingmyquestionhere,I'lldothesameontheforum.
Iactuallydon'tknowhowtoconvertthecodetoVBAandwhere/howtodebugit,asIstartedlearningthisstuffacoupleofmonthsago.I'llgiveitalook.
Acordingtothesketchdimensionconstraints,IbelieveIhavesomesketchesdimensionconstrainedinthepartfile...soasfarasIknowthatshouldn'tbetheproblem.
Again..thanksforyourtimeandeffort.
Keepupthegoodwork!

Reply
12/29/2016at02:14AM(http://adndevblog.typepad.com/manufacturing/2016/03/retrievesketchdimensionofpartdocumentinsideassembly.html#comment
6a0167607c2431970b01b7c8c1ac56970b)
Commentbeloworsigninwith Typepad(http://www.typepad.com/sitelogin?uri=http%3A%2F%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F03%2Fretrievesketch
dimensionofpartdocumentinside
assembly.html&fp=e474be1528c24441e739f1e2cfa0474e&view_uri=http%3A%2F%2Fprofile.typepad.com%2F&via=blogside&post_uri=http://adndevblog.typepad.com/manufacturing/2016/0
sketchdimensionofpartdocumentinsideassembly.html) Facebook(http://www.typepad.com/sitelogin?
uri=http%3A%2F%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F03%2Fretrievesketchdimensionofpartdocumentinside
assembly.html&fp=e474be1528c24441e739f1e2cfa0474e&view_uri=http%3A%2F%2Fprofile.typepad.com%2F&via=blogside&service=facebook&post_uri=http://adndevblog.typepad.com/man
sketchdimensionofpartdocumentinsideassembly.html) Twitter(http://www.typepad.com/sitelogin?
uri=http%3A%2F%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F03%2Fretrievesketchdimensionofpartdocumentinside

http://adndevblog.typepad.com/manufacturing/2016/03/retrievesketchdimensionofpartdocumentinsideassembly.html

2/4

21/01/2017

RetrievesketchdimensionofpartdocumentinsideassemblyManufacturingDevBlog

assembly.html&fp=e474be1528c24441e739f1e2cfa0474e&view_uri=http%3A%2F%2Fprofile.typepad.com%2F&via=blogside&service=twitter&post_uri=http://adndevblog.typepad.com/manuf
sketchdimensionofpartdocumentinsideassembly.html) Google+(http://www.typepad.com/sitelogin?
uri=http%3A%2F%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F03%2Fretrievesketchdimensionofpartdocumentinside
assembly.html&fp=e474be1528c24441e739f1e2cfa0474e&view_uri=http%3A%2F%2Fprofile.typepad.com%2F&via=blogside&service=gplus&post_uri=http://adndevblog.typepad.com/manufa
sketchdimensionofpartdocumentinsideassembly.html)andmore...(http://www.typepad.com/sitelogin?
uri=http%3A%2F%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F03%2Fretrievesketchdimensionofpartdocumentinside
assembly.html&fp=e474be1528c24441e739f1e2cfa0474e&view_uri=http%3A%2F%2Fprofile.typepad.com%2F&via=blogside&service=openid&post_uri=http://adndevblog.typepad.com/manu
sketchdimensionofpartdocumentinsideassembly.html)

(URLsautomaticallylinked.)

Emailaddressisnotdisplayedwithcomment.

Name
EmailAddress
WebSiteURL
Post Preview

(http://www.typepad.com/)
ManufacturingDevBlog(http://adndevblog.typepad.com/manufacturing/)

http://adndevblog.typepad.com/manufacturing/2016/03/retrievesketchdimensionofpartdocumentinsideassembly.html

3/4

21/01/2017

RetrievesketchdimensionofpartdocumentinsideassemblyManufacturingDevBlog

http://adndevblog.typepad.com/manufacturing/2016/03/retrievesketchdimensionofpartdocumentinsideassembly.html

4/4