I have created below codes to create auto annotation using "Retrieve Model Annotation"
but this code is not showing any error but this is working for "i" first value if i=1 it will work for first view ,if it is 2 it will work for second alone but my code has to do it for all the views in active sheet.
Dim oDDoc As DrawingDocument = ThisDrawing.Document Dim oSheet As Sheet = oDDoc.ActiveSheet Dim i As Integer For i = 1 To oSheet.DrawingViews.Count Dim oView As DrawingView = oSheet.DrawingViews.Item(i) oDDoc.SelectSet.Select(oView) ThisApplication.CommandManager.ControlDefinitions.Item("DrawingRetrieveDimsCmd").Execute() ThisApplication.CommandManager.ControlDefinitions.Item("AppContextual_OKCmd").Execute() 'Threading.Thread.CurrentThread.sleep(100) Next i
Give this a try instead. It's much simpler than simulating selecting the view object, then executing two commands while it is selected. One thing to keep in mind though, is that when you create model annotations, you create them on 'annotation planes'. Most drawing views are looking at the model from a specific angle, so the view will only be able to retrieve the model annotations that are on the annotation plane that aligns with that view of the model, so likely won't be able to retrieve every model annotation in every view.
Here's the iLogic rule code you can try:
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oSSet As SelectSet = oDDoc.SelectSet
oSSet.Clear
For Each oView As DrawingView In oSheet.DrawingViews
Try
oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oView)
Catch
MsgBox("Failed to retrieve model dimensions/annotations from view: " & oView.Name,,"")
End Try
Next
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
If you want and have time, I would appreciate your Vote(s) for My IDEAS :light_bulb:or you can Explore My CONTRIBUTIONS
Wesley Crihfield
(Not an Autodesk Employee)
Thanks for your reply,
I have created Annotation in proper planes and locked in view representations.
As you may aware that "Retrieve Model Annotation" from 3D Annotation is not having API support that is the reason i am using command manager.
your code is pulling all the dimensions associated with models.
but i have already allocated the which dimensions need to visible in which view rep.
please find the attached images , i hope may get some additional idea
@mdinesh wrote:I have created below codes to create auto annotation using "Retrieve Model Annotation"
but this code is not showing any error but this is working for "i" first value if i=1 it will work for first view ,if it is 2 it will work for second alone but my code has to do it for all the views in active sheet.
Dim oDDoc As DrawingDocument = ThisDrawing.Document Dim oSheet As Sheet = oDDoc.ActiveSheet Dim i As Integer For i = 1 To oSheet.DrawingViews.Count Dim oView As DrawingView = oSheet.DrawingViews.Item(i) oDDoc.SelectSet.Select(oView) ThisApplication.CommandManager.ControlDefinitions.Item("DrawingRetrieveDimsCmd").Execute() ThisApplication.CommandManager.ControlDefinitions.Item("AppContextual_OKCmd").Execute() 'Threading.Thread.CurrentThread.sleep(100) Next i
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim i As Integer
For i = 1 To oSheet.DrawingViews.Count
Dim oView As DrawingView = oSheet.DrawingViews.Item(i)
oDDoc.SelectSet.Clear
oDDoc.SelectSet.Select(oView)
ThisApplication.CommandManager.ControlDefinitions.Item("DrawingRetrieveDimsCmd").Execute()
ThisApplication.CommandManager.ControlDefinitions.Item("AppContextual_OKCmd").Execute()
'Threading.Thread.CurrentThread.sleep(100)
Next i
The GeneralDimensions.Retrieve method was also pulling in other 3D annotations for me, besides just dimensions, but if you only want certain specific ones shown in each view, you would have to build an ObjectCollection of the ones you wanted specifically for each view, practically eliminating the convenience of the loop, which doesn't sound like it would be a very good solution in your case. If you have everything set up in view representations, then maybe you just need code that checks the view's name or camera orientation, then changes the view representation of the view to the appropriate one, without having to go through the 'retrieve model annotations' tool. Does that sound like it would work for you? Can you do it manually, just by setting the view representations, without using the retrieve tool?
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.