Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/13/2025 in all areas

  1. https://www.theswamp.org/index.php?topic=30650.msg378483#msg378483
    4 points
  2. Good stuff, but lacks precision input. I'll look through the information on adapting it though. Lots of good information in that thread.
    1 point
  3. You can use both evaluated expressions and quoted literals in a list, e.g.: (setq ht1 4.25 ht2 4.75 sel (ssget "_X" (list '(0 . "*TEXT") '(-4 . ">=") (cons 40 ht1) '(-4 . "<=") (cons 40 ht2))) ) You might find the following tutorials useful in this regard - https://lee-mac.com/quote.html https://lee-mac.com/ssget.html
    1 point
  4. Reads an Excel value into a field import traceback from pyrx import Rx, Ge, Gi, Db, Ap, Ed import openpyxl as xl # Some notes # - AcFdFieldEvaluatorLoader and AcFdFieldReactor are embedded (BricsCAD does not have the reactors) # - if you follow the normal %<\MyFieldID fcode>%, it should pick up your evaluator # - Fields are like custom objects, name and evalname(FieldID) should be unique if you plan on sharing # - AutoCAD caches the last evaluation, so of the evaluator it not loaded, your data should still show # %<\XLSXField M:\\Dev\\Projects\\PyRxGit\\tests\\media\\testdata.xlsx|Show|A1>% # %<\XLSXField M:\\Dev\\Projects\\PyRxGit\\tests\\media\\testdata.xlsx|Show|B1>% # %<\XLSXField M:\\Dev\\Projects\\PyRxGit\\tests\\media\\testdata.xlsx|strings|A4>% print("added command - addevaluator") print("added command - remevaluator") print("added command - makeField") # you may not need to override all of these, in AutoCAD it's enough just to override # format, or evaluate. # for platforms that do not support begin/endEvaluateFields, use command ended event # or on idle to clear your cache class FieldEvaluator(Db.FieldEvaluator): def __init__(self, name, evalname): Db.FieldEvaluator.__init__(self, name, evalname) self.cache = {} def getValueFromXL(self, field: Db.Field): fcode = field.getFieldCode(Db.FieldCodeFlag.kFieldCode).strip("\\XLSXField") if fcode in self.cache: return str(self.cache[fcode]) path, sheet, cell = fcode.split("|") workbook = xl.load_workbook(filename=path.strip(), read_only=True) worksheet = workbook[sheet] return str(worksheet[cell].value) def format(self, field: Db.Field): print("\nformat") return self.getValueFromXL(field) def compile(self, field: Db.Field, db: Db.Database, result: Db.AcValue): try: print("\ncompile") result.setString(self.getValueFromXL(field)) return Db.FieldEvalStatus.kSuccess except Exception as err: traceback.print_exception(err) return Db.FieldEvalStatus.kOtherError def evaluate( self, field: Db.Field, ctx: int, db: Db.Database, result: Db.AcValue ) -> Db.FieldEvalStatus: try: print("\nevaluate") result.setString(self.getValueFromXL(field)) return Db.FieldEvalStatus.kSuccess except Exception as err: traceback.print_exception(err) return Db.FieldEvalStatus.kOtherError # not in ZRX or BRX def beginEvaluateFields(self, ctx: int, db: Db.Database): try: print("\nbeginEvaluateFields") self.cache.clear() except Exception as err: traceback.print_exception(err) # not in ZRX or BRX def endEvaluateFields(self, ctx: int, db: Db.Database): try: print("\nendEvaluateFields") self.cache.clear() except Exception as err: traceback.print_exception(err) evaluator = FieldEvaluator("XLSX Field", "XLSXField") @Ap.Command() def makeField(): try: db = Db.curDb() fld = Db.Field( "%<\\XLSXField M:\\Dev\\Projects\\PyRxGit\\tests\\media\\testdata.xlsx|strings|A4>%" ) fld.evaluate() mt = Db.MText() db.addToCurrentspace(mt) mt.setField(fld) except Exception as err: print(err) @Ap.Command() def addevaluator(): try: engine: Db.FieldEngine = Db.FieldEngine.getEngine() engine.registerEvaluator(evaluator) except Exception as err: print(err) @Ap.Command() def remevaluator(): try: engine: Db.FieldEngine = Db.FieldEngine.getEngine() engine.unregisterEvaluator(evaluator) except Exception as err: print(err)
    1 point
  5. Try to select the polyline and go to the PROPERTIES window (CTRL+1). Under the GEOMETRY you have the properties of the Vertex1. Click the field where says Vertex1 and you see two arrows pointing to left/right. Press one of them and you can see the other vertexes. Watch the screen and you will see a mark "walking" on your polyline. Sometimes you can see the place where "something is wrong" just watching the order and the position of the vertexes. Also you can use the PEDIT command for this.
    1 point
×
×
  • Create New...