Replies: 24 comments 18 replies
-
Hi, Did I make a mistake? |
Beta Was this translation helpful? Give feedback.
-
Really great samples! |
Beta Was this translation helpful? Give feedback.
-
Whenever I find the time I wish to add pending examples from the SDK (hobbyist endeavour of an occasional scripter). It's a pleasure to learn from your coding and answer culture. The open issues (GeoCoordinateSystem, Labeling System, SDK documentation) hopefully will be resolved in order not to become frustrating dead-ends... and maybe one day your project becomes an opensource foundation with CAD producers and other private entities securing future development the like to the benefit of end users. |
Beta Was this translation helpful? Give feedback.
-
I have trouble with TIN merge. case 0 works, bute case 1 doesn't. Ought I to initialize the surface somehow? Help appreciated. match ssResult[1]:
case 0:
try:
fSurface.merge(sSurface)
print("\nMerged second to first surface")
except:
print("\nMerging surfaces failed")
case 1:
try:
nSurface = Cv.CvDbTinSurface()
nSurface.merge(fSurface.merge(sSurface))
db.addToModelspace(nSurface)
print("\nCreating new surface from first and second")
except: |
Beta Was this translation helpful? Give feedback.
-
The BRX API has both a static merge, and an instance merge which confused python From: // merge another surface into this surface entity
bool merge(const BrxCvDbTinSurface* theOther);
// merge 2 surfaces and create new surface
static BrxCvDbTinSurface* merge(const BrxCvDbTinSurface* theOne, const BrxCvDbTinSurface* theOther); To: bool merge(const PyBrxCvDbTinSurface& theOther);
static PyBrxCvDbTinSurface mergeSurfaces(const PyBrxCvDbTinSurface& theOne, const PyBrxCvDbTinSurface& theOther); |
Beta Was this translation helpful? Give feedback.
-
ouch, I must have missed that! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hi, can you post a sample drawing, or add a drawing to \unitTests\testmedia
but I'd like to create a test |
Beta Was this translation helpful? Give feedback.
-
it's actually a bit difficult, I hope this sample will intrastate the steps import traceback
from pyrx_imp import Rx, Ge, Gi, Db, Ap, Ed, Cv
def getIds(vAlignment):
try:
ids = []
elementId = vAlignment.firstElementId()
while elementId != 0:
element = vAlignment.elementAtId(elementId)
if elementId != 0:
ids.append(elementId)
elementId = element.nextId()
return ids
except Exception as err:
traceback.print_exception(err)
def PyRxCmd_doit():
try:
#select the view, wee need this to transform
vsel = Ed.Editor.entSel("\nSelect Alignment: ", Cv.CvDbVAlignmentView.desc())
if vsel[0] != Ed.PromptStatus.eOk:
print("Oops {}: ".format(vsel[0]))
vAlignmentView = Cv.CvDbVAlignmentView(vsel[1], Db.OpenMode.kForRead)
# select the vAlignment
esel = Ed.Editor.entSel("\nSelect Alignment: ", Cv.CvDbVAlignment.desc())
if esel[0] != Ed.PromptStatus.eOk:
print("Oops {}: ".format(esel[0]))
vAlignment = Cv.CvDbVAlignment(esel[1], Db.OpenMode.kForRead)
for id in getIds(vAlignment):
element = vAlignment.elementAtId(id)
print(element.type())
if element.type() != Cv.VAlignmentElementType.eParabola:
continue
parabola: Cv.CvDbVAlignmentParabola = Cv.CvDbVAlignmentParabola.cast(element)
#get the end pointd for this section
sp2d = parabola.startPoint()
ep2d = parabola.endPoint()
#calc the mid param and use getPointAtDist
sp = vAlignment.getParamAtPoint(Ge.Point3d(sp2d.x,sp2d.y,0.0))
ep = vAlignment.getParamAtPoint(Ge.Point3d(ep2d.x,ep2d.y,0.0))
mp = (ep - sp)
mid = vAlignment.getPointAtDist(mp)
# transform the point from to WCS
mid.x = vAlignmentView.toWCSX(mid.x)
mid.y = vAlignmentView.toWCSY(mid.y)
Ed.Core.grDrawCircle(mid,1.0,24,1)
except Exception as err:
traceback.print_exception(err) |
Beta Was this translation helpful? Give feedback.
-
Thanks for your answer. Below will be useful for the midpoint.
Drawing works for me using the vAlignmentView as a reference
I do it like this if prevElement: #We have a previous element, then draw
self.blkref4.setPosition(Ge.Point3d(arc.startPoint().x+aview.origin().x, arc.startPoint().y+aview.origin().y-aview.baseElevation(), 0)) Remaining question is how one would find the local minimum/maximum within the arc segment. In your case it would be somewhere here. One could iterate for the max vertical distance to a horizontal line, but I am looking for a smoother way to determine the sag/crest. |
Beta Was this translation helpful? Give feedback.
-
I tried to call getAcGeCurve as it has more useful functions but it’s not implemented by BricsCAD
BricsCAD is also missing a bunch of geometry classes I.e. AcGeBoundBlock2d |
Beta Was this translation helpful? Give feedback.
-
Could also not make it work like this: arc: Cv.CvDbVAlignmentArc = Cv.CvDbVAlignmentArc.cast(element)
cv = Db.Curve.cast(arc).getAcGeCurve() Posted SR175846. Hm |
Beta Was this translation helpful? Give feedback.
-
This helper function seems to deliver a usable result close to the absolute vertical max of the parabola. Similarly for vertical min. def getVMaxPoint(valign,spt,ept):
try:
no = 100
coords = []
sdist = valign.getDistAtPoint(Ge.Point3d(spt.x,spt.y,0))
edist = valign.getDistAtPoint(Ge.Point3d(ept.x,ept.y,0))
dist = sdist
while dist < edist:
pt = valign.getPointAtDist(dist)
coords.append([pt.x, pt.y])
dist += (edist-sdist)/no
x, ymax = max(coords, key=lambda x: (x[1]))
return Ge.Point3d(x,ymax,0)
except Exception as err:
traceback.print_exception(err) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Also, you may have to add the closing point |
Beta Was this translation helpful? Give feedback.
-
Advancing slightly. How would one read the current annotation scale? |
Beta Was this translation helpful? Give feedback.
-
I run into trouble with |
Beta Was this translation helpful? Give feedback.
-
How would I write a text label with position and size? An example using |
Beta Was this translation helpful? Give feedback.
-
GrText won’t work for this. There’s another way to draw temporary graphics using Gi.TransientManager import traceback
from pyrx_imp import Rx, Ge, Db, Ap, Ed, Gi
vpids = []
markers = []
def clear():
tm = Gi.TransientManager.current()
for marker in markers:
tm.eraseTransient(marker,vpids)
vpids.clear()
markers.clear()
try:
Ed.Core.vportTableRecords2Vports()
except:
pass
def PyRxCmd_clearit():
clear()
def PyRxCmd_doit():
try:
clear()
#what viewport
vpids.append(Ed.Core.getVar("CVPORT"))
line = Db.Line(Ge.Point3d(0,0,0),Ge.Point3d(100,100,0))
line.setDatabaseDefaults()
line.setColorIndex(1)
mt = Db.MText()
mt.setDatabaseDefaults()
mt.setContents("Hello World: ")
mt.setDirection(Ge.Point3d(100,100,0)-Ge.Point3d(0,0,0) )
mt.setLocation(line.midPoint())
markers.append(line)
markers.append(mt)
tm = Gi.TransientManager.current()
for marker in markers:
tm.addTransient(marker,Gi.TransientDrawingMode.kAcGiDirectShortTerm,128,vpids)
try:
Ed.Core.vportTableRecords2Vports()
except:
pass
except Exception as err:
traceback.print_exception(err) |
Beta Was this translation helpful? Give feedback.
-
The TransientManager probably causes a redraw, you may have to do GrDraw after. |
Beta Was this translation helpful? Give feedback.
-
I am happy with the current solution which is using grouping only. |
Beta Was this translation helpful? Give feedback.
-
ok, will study the example. |
Beta Was this translation helpful? Give feedback.
-
Have assemblied a command CVGetDemTin.py. How would one use crossingsElevation in order not to allow crossings? |
Beta Was this translation helpful? Give feedback.
-
I am trying to place orthogonal lines (or lateron sections) for a defined halignment + station. In my youthful ignorance I had thought to be able to cast a curve from an element containing the station and then identify somehow the normal to that. Unfortunately I got directly stuck in the beginning. Ideas welcome |
Beta Was this translation helpful? Give feedback.
-
thx for everything. when creating volume surfaces I manage for
1#
initialize(class PyBrxCvDbVolumeSurface {lvalue}, class PyBrxCvDbTinSurface, double, enum BrxCvDbVolumeSurface::EVolumeSurfaceType, class PyDbObjectId, double)
=>
vSurface.initialize(pSurface, cSurface, [])
2#
initialize(class PyBrxCvDbVolumeSurface {lvalue}, class PyBrxCvDbTinSurface, double, enum BrxCvDbVolumeSurface::EVolumeSurfaceType, class boost::python::list)
=>
vSurface.initialize(pSurface, elev, [])
=> not working=>
vSurface.initialize(pSurface, elev, Cv.VolumeSurfaceType.eTinVolumeToElevation, [])
=> tata! working!Beta Was this translation helpful? Give feedback.
All reactions