icon

Support Forum

[Frage] How to create dimension lines in VS? [Gelöst]


The problem:
I want to create native dimension lines. Because VS does not have that node, I made one myself using ExecPythonScript. The problem I get is that it only creates elevation dimensions and I can't force it to create linear dimension.

"
import NemAll_Python_BaseElements as be
import NemAll_Python_BasisElements as bse
import NemAll_Python_Geometry as g
def function_to_execute(a):
dp=bse.DimensionProperties()
p1=g.Point3D(0,0,0)
p2=g.Point3D(0,200,0)
lista=g.Point3DList(p1)
lista.append(p2)
v1=g.Vector2D(0,100)
v2=g.Vector2D(0,100)
cota=bse.DimensionLineElement(lista,v1,v2,dp)

return cota
"
If I try to to force it to be linear dimension as seen in Dimensioning.py by setting:
dim_prop = AllplanBasisElements.DimensionProperties(self.document, bse.Dimensioning.eDimensionLine)

I also tried:
"
dpbase=bse.DimensionProperties()
dp=bse.DimensionProperties(dpbase,bse.Dimensioning.eDimensionLine)

"
to get rid of the self.document part in case that gave the error.

Does anyone have an idea? I want to use native dimensions, not lines and text (I already did the lines and text one,it is not very friendly).

Lösung anzeigen Lösung verbergen

There is an example

C:\ProgramData\Nemetschek\Allplan\2024\Etc\PythonPartsExampleScripts\BasisExamples\Dimensioning.py

where you can see the right usage.

Search after "DimensionLine" with Notepad++ in ETC gives a lot of other matches, e.g.
C:\ProgramData\Nemetschek\Allplan\2025\Etc\PythonPartsScripts\PP_dev\DimensionLines.py

Anhänge (2)

Typ: image/png
30-mal heruntergeladen
Größe: 150,58 KiB
Typ: image/png
33-mal heruntergeladen
Größe: 58,77 KiB

There is an example

C:\ProgramData\Nemetschek\Allplan\2024\Etc\PythonPartsExampleScripts\BasisExamples\Dimensioning.py

where you can see the right usage.

Search after "DimensionLine" with Notepad++ in ETC gives a lot of other matches, e.g.
C:\ProgramData\Nemetschek\Allplan\2025\Etc\PythonPartsScripts\PP_dev\DimensionLines.py

Anhänge (2)

Typ: image/png
30-mal heruntergeladen
Größe: 150,58 KiB
Typ: image/png
33-mal heruntergeladen
Größe: 58,77 KiB

As all things in programing, now it works. I don't know what exactly I was doing wrong, so I leave the correct code here in case someone else needs it. From here you can do it with your inputs as you require.

import NemAll_Python_BaseElements as be
import NemAll_Python_BasisElements as bse

import NemAll_Python_Geometry as g
def function_to_execute(a):
dp=bse.DimensionProperties(self.document, bse.Dimensioning.eDimensionLine)
p1=g.Point3D(0,0,0)
p2=g.Point3D(0,200,0)
lista=g.Point3DList(p1)

lista.append(p2)
v1=g.Vector2D(0,100)
v2=g.Vector2D(0,100)
cota=bse.DimensionLineElement(lista,v1,v2,dp)

return cota