Path of the file without the first folder

Path of the file without the first folder

eladm
Collaborator Collaborator
1,461 Views
27 Replies
Message 1 of 28

Path of the file without the first folder

eladm
Collaborator
Collaborator

Hello

 

Can I get help to get a ilogic rule of the file path without the first folder

C:\Work\AAAAA\BBBB

I want to get AAAA\BBBB

to write it in a drawing , to new template and also to old drawings

regards

 

0 Likes
1,462 Views
27 Replies
Replies (27)
Message 21 of 28

TechInventor20
Advocate
Advocate

I think that is possible but that is loads of work for just a position of something that nobody would ever change.

0 Likes
Message 22 of 28

eladm
Collaborator
Collaborator

Can you write this text to iproperties like in the beginning ?

0 Likes
Message 23 of 28

TechInventor20
Advocate
Advocate

 

Dim oApp = ThisApplication
Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDrawingDoc.ActiveSheet

For Each oSheet In oDrawingDoc.Sheets 
For Each oGeneralNote In oSheet.DrawingNotes.GeneralNotes 
oGeneralNote.Delete 
Next 
Next

For Each oSheet In oDrawingDoc.Sheets
	oViews = oSheet.DrawingViews
	Dim oView As DrawingView
	For Each oView In oViews
		Dim oModelDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
		Dim oFullFilePath As String = oModelDoc.FullFileName
		'MsgBox(oModelDoc.FullFileName)
		Dim Input As String = oFullFilePath
		Dim folders = Input.Split("\").Skip(5)
		Dim newPath = String.Join("\", folders)
		'MsgBox(newPath)
		
    	' Set a reference to the TransientGeometry on active sheet.
    	Dim oTG As TransientGeometry
    	oTG = oApp.TransientGeometry
		
		oBorder = oSheet.Border
		
		Dim oNewPosition As Point2d
		oPlaceX = oBorder.RangeBox.MinPoint.X + 0.1
		oPlaceY = oBorder.RangeBox.MinPoint.Y + 0.25
        'Set reference to the new required position taken and create new 2d point
        oNewPosition = oTG.CreatePoint2d(oPlaceX,oPlaceY)
		
'		oSheet.DrawingNotes.GeneralNotes.AddFitted(ThisApplication.TransientGeometry.CreatePoint2d(DrawingView.position.x - DrawingView.width / 2, DrawingView.position.y - DrawingView.height / 2 - 1), newPath)
'		oSheet.DrawingNotes.GeneralNotes.AddFitted(oNewPosition,newPath)
		iProperties.Value("Custom", "05-Opmerking") = newPath
	Next
Next
0 Likes
Message 24 of 28

eladm
Collaborator
Collaborator

nothing happened 

0 Likes
Message 25 of 28

TechInventor20
Advocate
Advocate

The part in green is a iproperty, you just have to change it to the property you wan't

0 Likes
Message 26 of 28

eladm
Collaborator
Collaborator

the ipro. is OK - the name not important

eladm_0-1661862231479.png

 

I also tried to other field

but it empty

0 Likes
Message 27 of 28

TechInventor20
Advocate
Advocate

I don't know what is wrong or how to implement it in the way you wan't it. I think that it is impossible to get it in the title blocks.

0 Likes
Message 28 of 28

Michael.Navara
Advisor
Advisor

If you want to have this information inside the title block, you have following possibilities.

  1. You can create TextBox as "prompt entry" and set its value. It is possible to do it programmatically. See this and this.
  2. You can create text box in title block definition referenced to drawing iProperty, but in this case you have the same value on all sheets.
  3. You can create text box in title block definition referenced to model iProperty, in this case you can have different values on each sheet. It depends on the first model on the sheet. And you need to update this iProperty in the model (not in drawing).

 

You can't use fixed text, because in this case you need to modify the title block definition. And this definition is the same for all sheets (usually for all drawing documents). Create new title block definition for each sheet is not good idea.

0 Likes