Author Topic: Show hatch patterns dialog in BricsCAD  (Read 411 times)

0 Members and 1 Guest are viewing this topic.

dankobananko

  • Mosquito
  • Posts: 8
Show hatch patterns dialog in BricsCAD
« on: February 02, 2024, 02:16:18 PM »
Hello.

I am using this function in autocad to show dialog with hatch patterns.

Code: [Select]
   [DllImport(
        "acad.exe",
        EntryPoint =
          "?acedHatchPalletteDialog@@YA_NPB_W_NAAPA_W@Z",
        CharSet = CharSet.Auto
      )
    ]

    static extern bool acedHatchPalletteDialog(
      string currentPattern,
      bool showcustom,
      out string newpattern
    );

Is there BricsCAD equivalent to this?

owenwengerd

  • Bull Frog
  • Posts: 451
Re: Show hatch patterns dialog in BricsCAD
« Reply #1 on: February 02, 2024, 03:08:34 PM »
For BricsCAD, you'll need to change the module name to e.g. "brx24.dll".

dankobananko

  • Mosquito
  • Posts: 8
Re: Show hatch patterns dialog in BricsCAD
« Reply #2 on: February 02, 2024, 03:40:20 PM »
For BricsCAD, you'll need to change the module name to e.g. "brx24.dll".

Thank you on help, I tried that and getting dialog from first attachment (missing all acad pattern names).

when apply this pattern getting error from second attachment.




It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8582
  • AKA Daniel
Re: Show hatch patterns dialog in BricsCAD
« Reply #3 on: February 02, 2024, 06:26:32 PM »
Just an observation, your using predefined in your code, but your showing the custom tab.
I didn’t see a “Srafura” hatch , maybe this is a translation issue?

dankobananko

  • Mosquito
  • Posts: 8
Re: Show hatch patterns dialog in BricsCAD
« Reply #4 on: February 03, 2024, 01:06:10 AM »
Just an observation, your using predefined in your code, but your showing the custom tab.
I didn’t see a “Srafura” hatch , maybe this is a translation issue?

"Srafura" iz just string variable of hatch pattern name, when user
select it from dialog.

Regarding dialog which is visible, you are right but trying to figure
out how to show identical pattern list in BricsCAD as in AutoCAD.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8582
  • AKA Daniel
Re: Show hatch patterns dialog in BricsCAD
« Reply #5 on: February 03, 2024, 04:43:06 AM »
ok, this works in Python. if you retrieve a hatch from the custom tab, you must use kCustomDefined

Code - Python: [Select]
  1. # import
  2. import PyRx as Rx
  3. import PyGe as Ge
  4. import PyGi as Gi
  5. import PyDb as Db
  6. import PyAp as Ap
  7. import PyEd as Ed
  8. import traceback
  9.  
  10. def PyRxCmd_doit():
  11.     try:
  12.        for pattern in Ed.Core.getPredefinedHatchPatterns():
  13.             print(pattern)
  14.  
  15.     except Exception as err:
  16.         traceback.print_exception(err)
  17.                
  18. def PyRxCmd_doit2():
  19.     try:
  20.         res =  Ed.Core.hatchPalletteDialog("", False)
  21.         pycreate_hatch(res, False)
  22.     except Exception as err:
  23.         traceback.print_exception(err)
  24.        
  25. def PyRxCmd_doit3():
  26.     try:
  27.         res = Ed.Core.hatchPalletteDialog("", True)
  28.         pycreate_hatch(res,True )
  29.     except Exception as err:
  30.         traceback.print_exception(err)
  31.        
  32. def pycreate_hatch(srafura : str, isCustom : bool):
  33.     try:
  34.         db = Db.HostApplicationServices().workingDatabase()
  35.        
  36.         hatch = Db.Hatch()
  37.         hatch.setDatabaseDefaults()
  38.         normal = Ge.Vector3d(0,0,1)
  39.         hatch.setNormal(normal)
  40.         hatch.setElevation(0)
  41.        
  42.         hatch.setAssociative(False)
  43.        
  44.         if isCustom:
  45.             hatch.setPattern(Db.HatchPatternType.kCustomDefined, srafura)
  46.         else:
  47.             hatch.setPattern(Db.HatchPatternType.kPreDefined, srafura)
  48.                        
  49.         hatch.setHatchStyle(Db.HatchStyle.kNormal)
  50.        
  51.         vertexPts = []
  52.         vertexPts.append(Ge.Point2d(2.0, 2.0))
  53.         vertexPts.append(Ge.Point2d(18.0, 2.0))
  54.         vertexPts.append(Ge.Point2d(18.0, 18.0))
  55.         vertexPts.append(Ge.Point2d(2.0, 18.0))
  56.         vertexPts.append(Ge.Point2d(2.0, 2.0))
  57.        
  58.         vertexBulges = []
  59.         for n in range(len(vertexPts)):
  60.             vertexBulges.append(0.0)
  61.            
  62.         hatch.appendLoopBulges(Db.HatchLoopType.kExternal, vertexPts, vertexBulges)
  63.            
  64.         cenPt = Ge.Point2d(10.0, 10.0)
  65.         TWOPI = 2.0 * 3.1415926535897932
  66.         cirArc = Ge.CircArc2d()
  67.         cirArc.setCenter(cenPt)
  68.         cirArc.setRadius(4.0)
  69.         cirArc.setAngles(0.0, TWOPI)
  70.        
  71.         edgePtrs = []
  72.         edgeTypes = []
  73.  
  74.         edgePtrs.append(cirArc)
  75.         edgeTypes.append(Db.HatchEdgeType.kCirArc)
  76.        
  77.         hatch.appendLoopEdges(Db.HatchLoopType.kDefault, edgePtrs, edgeTypes)
  78.         hatch.evaluateHatch()
  79.        
  80.         model = Db.BlockTableRecord(db.modelSpaceId(), Db.OpenMode.kForWrite)
  81.         model.appendAcDbEntity(hatch)      
  82.     except Exception as err:
  83.         traceback.print_exception(err)
  84.  


It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8582
  • AKA Daniel
Re: Show hatch patterns dialog in BricsCAD
« Reply #6 on: February 03, 2024, 04:45:16 AM »
bool  acedGetPredefinedPattens(AcStringArray& patterns); is missing in BRX
might be handy to have

dankobananko

  • Mosquito
  • Posts: 8
Re: Show hatch patterns dialog in BricsCAD
« Reply #7 on: February 03, 2024, 01:12:41 PM »
Tomorrow I will test it, but I am sure it works well.

Thank you for your help...I appretiate it..

dankobananko

  • Mosquito
  • Posts: 8
Re: Show hatch patterns dialog in BricsCAD
« Reply #8 on: February 04, 2024, 06:07:39 AM »
Still couldn't run this dialog with predefined patterns with .net, this is screenshot from BricsCAD application.

This function return just custom patterns which I don't need.

[DllImport("brx24.dll", EntryPoint = "?acedHatchPalletteDialog@@YA_NPEB_W_NAEAPEA_W@Z", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)]
« Last Edit: February 04, 2024, 06:12:56 AM by dankobananko »

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8582
  • AKA Daniel
Re: Show hatch patterns dialog in BricsCAD
« Reply #9 on: February 04, 2024, 06:53:22 AM »
you called ?acedHatchPalletteDialog@@YA_NPEB_W_NAEAPEA_W@Z with false?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8582
  • AKA Daniel
Re: Show hatch patterns dialog in BricsCAD
« Reply #10 on: February 04, 2024, 07:03:19 AM »
my python wrapper is

Code - C++: [Select]
  1. extern bool acedHatchPalletteDialog(const wchar_t*, bool, wchar_t*&);
  2.  
  3. std::string EdCore::hatchPalletteDialog(const std::string& pattern, bool showCustom)
  4. {
  5.     RxAutoOutStr outstr;
  6.     acedHatchPalletteDialog(utf8_to_wstr(pattern).c_str(), showCustom , outstr.buf);
  7.     return outstr.str();
  8. }
  9.  

Code - Python: [Select]
  1. def PyRxCmd_doit2():
  2.     try:
  3.         res =  Ed.Core.hatchPalletteDialog("", False)
  4.     except Exception as err:
  5.         traceback.print_exception(err)
  6.  

dankobananko

  • Mosquito
  • Posts: 8
Re: Show hatch patterns dialog in BricsCAD
« Reply #11 on: February 04, 2024, 07:03:44 AM »
That was problem, was true, after change to false everything is fine.

Thank you very much.....