Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

怎么回事?图纸上的代码出错了,谁能告诉我该怎么做?

38620079
Contributor

怎么回事?图纸上的代码出错了,谁能告诉我该怎么做?

38620079
Contributor
Contributor

Sub Main() Dim oDrawingDoc As DrawingDocument = ThisApplication.ActiveDocument Dim baseScale As Double = oDrawingDoc.ActiveSheet.DrawingViews.Item(1).Scale For Each oView As DrawingView In oDrawingDoc.ActiveSheet.DrawingViews oView.Scale = baseScale Next End Sub

0 Likes
Reply
Accepted solutions (2)
326 Views
4 Replies
Replies (4)

38620079
Contributor
Contributor

What's going on? The code is running wrong in the drawing, who can tell me what to do?

0 Likes

FINET_Laurent
Advisor
Advisor
Accepted solution

Hi,

 

Make sure the view you are chaning the scale is a main view and not an projected view, section views, etc. since those views scale are linked to the main ones : 

Sub Main() 
	Dim oDrawingDoc As DrawingDocument = ThisApplication.ActiveDocument 
	Dim baseScale As Double = oDrawingDoc.ActiveSheet.DrawingViews.Item(1).Scale
	
	For Each oView As DrawingView In oDrawingDoc.ActiveSheet.DrawingViews 
		If oView.Type <> DrawingViewTypeEnum.kStandardDrawingViewType Then Continue For			
		oView.Scale = baseScale
		
	Next 
End Sub

 

Kind regards,

FINET L.

 

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

vpeuvion
Advocate
Advocate
Accepted solution

Hi, you can try this:

Sub Main()
	Dim oDrawingDoc As DrawingDocument = ThisApplication.ActiveDocument 
	Dim baseScale As Double = oDrawingDoc.ActiveSheet.DrawingViews.Item(1).Scale
	For Each oView As DrawingView In oDrawingDoc.ActiveSheet.DrawingViews 
		If oView.ViewType = 10501 Then oView.Scale = baseScale 
	Next 
End Sub

 Vincent.

0 Likes

38620079
Contributor
Contributor
噢!I see 谢谢
0 Likes