select dimension drawing ilogic

select dimension drawing ilogic

h.memis
Contributor Contributor
973 Views
10 Replies
Message 1 of 11

select dimension drawing ilogic

h.memis
Contributor
Contributor

I want to hide the selected value and add text instead. this code changes all values. can you help me ?

 


Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet

' Clear all DrawingDimensions
For Each drawingDimension As DrawingDimension In sheet.DrawingDimensions
DrawingDimension.HideValue = True
If ((DrawingDimension.Text.FormattedText = "<DimensionValue/>") Or
(String.IsNullOrEmpty(DrawingDimension.Text.FormattedText))) Then
DrawingDimension.Text.FormattedText = ""
End If
Next

0 Likes
Accepted solutions (3)
974 Views
10 Replies
Replies (10)
Message 2 of 11

SevInventor
Advocate
Advocate
Accepted solution

Hello h.memis,

 

such a thing?

 

Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet

' Clear all DrawingDimensions
Dim drawingDimension As DrawingDimension=ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingDimensionFilter, "Select a dimension")
DrawingDimension.HideValue = True
If ((DrawingDimension.Text.FormattedText = "<DimensionValue/>") Or
(String.IsNullOrEmpty(DrawingDimension.Text.FormattedText))) Then
DrawingDimension.Text.FormattedText = "example"
End If

 

0 Likes
Message 3 of 11

h.memis
Contributor
Contributor

it was perfect. thank you. Finally, can it be converted to vba?

0 Likes
Message 4 of 11

SevInventor
Advocate
Advocate
Accepted solution

I'm not shure if this works.

No time to test it:

 

Dim doc As DrawingDocument 
Set DrawingDocument = ThisDoc.Document
	
Dim sheet As Sheet
Set sheet = doc.ActiveSheet
' Clear all DrawingDimensions
Dim drawingDimension As DrawingDimension
Set drawingDimension=ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingDimensionFilter, "Select a dimension")
DrawingDimension.HideValue = True
If ((DrawingDimension.Text.FormattedText = "<DimensionValue/>") Or
(String.IsNullOrEmpty(DrawingDimension.Text.FormattedText))) Then
DrawingDimension.Text.FormattedText = "example"
End If
0 Likes
Message 5 of 11

h.memis
Contributor
Contributor

the code is not working 😞 also i can't find the code in run list

 

Ekran görüntüsü 2022-04-27 153609.png

 

Ekran görüntüsü 2022-04-27 153314.png

0 Likes
Message 6 of 11

WCrihfield
Mentor
Mentor

You probably just have to put your code within:

Sub 'name of your macro'

.... your code here...

End Sub

(Also the Sub can not have any 'input' variables, and can not be a Function, for it to be considered a 'macro', just so you are aware.)

 

Edit:  And the term 'ThisDoc.Document' is an iLogic only term, so you will likely have to change that to ThisApplication.ActiveDocument, or something similar.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 11

h.memis
Contributor
Contributor

We are getting closer step by step. but there is still error 😞

 

 

Ekran görüntüsü 2022-04-28 070705.png

0 Likes
Message 8 of 11

WCrihfield
Mentor
Mentor

Remove the "End Sub" line of code that is on about line 3.  You only need one of those at the end to close out the Sub routine.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 9 of 11

h.memis
Contributor
Contributor

i did what you said,sorry there is a mistake in the codes marked in red but I can't find it 😞

 

Ekran görüntüsü 2022-04-28 163202.png

0 Likes
Message 10 of 11

WCrihfield
Mentor
Mentor
Accepted solution

Sorry for all the run around.  I just created a new macro in one of my test drawings, under its DrawingProject, in a module named "OverwriteDrawingDimValue", then named my Sub within using the same name (which will be the macro's name), then typed this code into that Sub, fixed the If...Then statement, then ran it without any troubles.  Apparently VBA doesn't like the String.IsNullOrEmpty method, so I just replaced that with an empty double quote, which is usually good enough anyways.  Also got rid of most of the ( and ) marks in there, because they were not needed.  And since we are using the Pick method here, there was no need to identify a document or sheet, so I got rid of that stuff too.  Here is the resulting VBA macro that seemed to work OK for my test.

 

Sub OverwriteDrawingDimValue()
    Dim oDDim As drawingDimension
    Set oDDim = ThisApplication.CommandManager.Pick(kDrawingDimensionFilter, "Select a dimension.")
    oDDim.HideValue = True
    If (oDDim.Text.FormattedText = "<DimensionValue/>") Or _
        oDDim.Text.FormattedText = "" Then
        oDDim.Text.FormattedText = "example"
    End If
End Sub

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 11 of 11

h.memis
Contributor
Contributor

you are a perfect detail 🙂 thank you

0 Likes