[ADD] Kreiseldrehrichtungsanzeige hinzugefügt; [CHANGE] Insert des Kreisel mit Ausrichtung wird jetzt über die vom Benutzer gezeichnete Eingabelinie erreichnet; [FIX] Fehlende config Datei für die Positionierung der Stückliste hinzugefügt
This commit is contained in:
+152
-67
@@ -314,6 +314,77 @@
|
||||
)
|
||||
|
||||
|
||||
;; --- Drehrichtungspfeil (data/ils/Drehrichtungspfeil.dwg) ---
|
||||
;; Die DWG ist fuer einen Kreisel Nord -> Sued (AN oben, SP unten, also
|
||||
;; Einfuegewinkel 270) und Drehrichtung im Uhrzeigersinn gezeichnet.
|
||||
;; Im Block liegt der Kreisel entlang +X (Winkel 0); die Drehung des
|
||||
;; Kreisels kommt ueber den Einfuegewinkel des KREISEL_n-Blocks automatisch
|
||||
;; dazu. Der Pfeil wird daher im Block um 0 - 270 = 90 Grad gedreht.
|
||||
(setq *kreisel-pfeil-block* "Drehrichtungspfeil")
|
||||
(setq *kreisel-pfeil-winkel* (ssg-cfg-or "kreisel" "pfeil_winkel" 90.0))
|
||||
|
||||
;; X-Skalierung des Pfeils: UZS -> 1, GUZ -> -1 (Spiegelung an der eigenen
|
||||
;; Y-Achse, die Pfeilspitze zeigt dann in die Gegenrichtung).
|
||||
(defun kreisel-pfeil-xskal (drehrichtung)
|
||||
(if (equal drehrichtung "GUZ") -1.0 1.0)
|
||||
)
|
||||
|
||||
;; Reiner Kern: Einfuegeparameter beider Pfeile im Block-KS des Kreisels.
|
||||
;; Rueckgabe: ((punkt winkel xskal) (punkt winkel xskal)) - AN8, dann SP8
|
||||
;; (SP8 um 180 Grad gedreht).
|
||||
(defun kreisel-pfeil-params (radius abstand drehrichtung / xs)
|
||||
(setq xs (kreisel-pfeil-xskal drehrichtung))
|
||||
(list (list (list radius 0.0 0.0) *kreisel-pfeil-winkel* xs)
|
||||
(list (list (+ radius abstand) 0.0 0.0)
|
||||
(rem (+ *kreisel-pfeil-winkel* 180.0) 360.0) xs))
|
||||
)
|
||||
|
||||
;; Reiner Kern fuers Eckrad: ein Pfeil auf der Radmitte (Block-Ursprung),
|
||||
;; ausgerichtet wie der AN8-Pfeil eines Kreisels gleicher Drehung.
|
||||
(defun eckrad-pfeil-params (drehrichtung)
|
||||
(list (list (list 0.0 0.0 0.0) *kreisel-pfeil-winkel*
|
||||
(kreisel-pfeil-xskal drehrichtung)))
|
||||
)
|
||||
|
||||
;; Einen Pfeil einfuegen. Ab dem zweiten Mal per Blockname, damit INSERT
|
||||
;; nicht nach dem Neudefinieren der bestehenden Definition fragt.
|
||||
(defun kreisel-pfeil-einfuegen (pt winkel xs)
|
||||
(command "_.INSERT"
|
||||
(if (tblsearch "BLOCK" *kreisel-pfeil-block*)
|
||||
*kreisel-pfeil-block*
|
||||
(strcat *block-path* *kreisel-pfeil-block* ".dwg"))
|
||||
pt xs 1.0 winkel)
|
||||
)
|
||||
|
||||
;; Alle Pfeile einer Parameterliste ((punkt winkel xskal) ...) einfuegen
|
||||
;; (beim Aufbau der Blockdefinition). Fehlt die DWG, wird ohne Pfeil gebaut.
|
||||
(defun kreisel-pfeile-einfuegen (params)
|
||||
(if (findfile (strcat *block-path* *kreisel-pfeil-block* ".dwg"))
|
||||
(foreach p params
|
||||
(kreisel-pfeil-einfuegen (car p) (cadr p) (caddr p))
|
||||
)
|
||||
(princ (ssg-textf "kreisel-warn-pfeil-fehlt" (list *kreisel-pfeil-block*)))
|
||||
)
|
||||
)
|
||||
|
||||
;; Spiegelung der Pfeile in einer BESTEHENDEN Blockdefinition KREISEL_n_...
|
||||
;; nachziehen (Edit/Redraw mit geaenderter DREHRICHTUNG - der Blockname
|
||||
;; enthaelt die Drehrichtung nicht, die Definition wird wiederverwendet).
|
||||
;; Wirkt wie kreisel-label-aktualisieren auf alle Referenzen der Definition.
|
||||
(defun kreisel-pfeil-aktualisieren (bname drehrichtung / e ed xs)
|
||||
(setq xs (kreisel-pfeil-xskal drehrichtung))
|
||||
(setq e (tblobjname "BLOCK" bname))
|
||||
(while (setq e (entnext e))
|
||||
(setq ed (entget e))
|
||||
(if (and (= (cdr (assoc 0 ed)) "INSERT")
|
||||
(= (strcase (cdr (assoc 2 ed))) (strcase *kreisel-pfeil-block*))
|
||||
(not (equal (cdr (assoc 41 ed)) xs 1e-9)))
|
||||
(entmod (subst (cons 41 xs) (assoc 41 ed) ed))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
;; Attribut-Funktionen: ssg-attrib-read, ssg-attrib-merge,
|
||||
;; ssg-attrib-defaults, ssg-attrib-make-defs aus ssg_core.lsp
|
||||
|
||||
@@ -439,6 +510,11 @@
|
||||
;; SP8 Kreis (Spannstation) bei (radius+abstand, 0) - Dim-Suffix im Dateinamen
|
||||
(command "_.INSERT" (strcat *block-path* "SP8_" *ki-dxfm-dim* ".dwg") (list (+ radius abstand) 0.0 0.0) 1 1 0)
|
||||
|
||||
;; Drehrichtungspfeile auf AN8- und SP8-Mitte (SP8 um 180 Grad gedreht,
|
||||
;; GUZ gespiegelt). Fehlt die DWG, wird der Kreisel ohne Pfeil gebaut.
|
||||
(kreisel-pfeile-einfuegen
|
||||
(kreisel-pfeil-params radius abstand (cdr (assoc "DREHRICHTUNG" attribs))))
|
||||
|
||||
;; Tangenten-Layer: bevorzugt aus cfg/layer.cfg (Baugruppe
|
||||
;; "kreisel_tangente"), sonst der bisherige Hartwert S_LP.
|
||||
(if (null (ssg-layer-anlegen "kreisel_tangente" T))
|
||||
@@ -506,6 +582,8 @@
|
||||
(kreisel-label-aktualisieren bname
|
||||
(kreisel-label-text kreisel-nummer (cdr (assoc "Bezeichnung" attribs))
|
||||
(if is-pin "PIN" "STANDARD") abstand))
|
||||
;; ebenso die Spiegelung der Drehrichtungspfeile
|
||||
(kreisel-pfeil-aktualisieren bname (cdr (assoc "DREHRICHTUNG" attribs)))
|
||||
)
|
||||
)
|
||||
|
||||
@@ -561,87 +639,89 @@
|
||||
;; KreiselInsert: Manuell Position + Parameter
|
||||
;; --------------------------------------------
|
||||
|
||||
;; Reiner Kern: Abstand und Rotation aus Basispunkt und gezeigtem Punkt der
|
||||
;; Abstands-Abfrage (Gummiband-Linie, 2D in der XY-Ebene).
|
||||
;; Ohne Punkt (Enter) -> Vorgabe-Abstand, Rotation 0.
|
||||
;; Rueckgabe: (abstand rotation-in-grad), Rotation in [0, 360)
|
||||
(defun kreisel-insert-richtung (pt p2 vorgabe / a)
|
||||
(if (and p2 (> (distance (list (car pt) (cadr pt)) (list (car p2) (cadr p2))) 1e-6))
|
||||
(progn
|
||||
(setq a (* (/ 180.0 pi) (angle (list (car pt) (cadr pt)) (list (car p2) (cadr p2)))))
|
||||
(list (distance (list (car pt) (cadr pt)) (list (car p2) (cadr p2)))
|
||||
(if (>= a 359.9999999) 0.0 a))
|
||||
)
|
||||
(list vorgabe 0.0)
|
||||
)
|
||||
)
|
||||
|
||||
;; --------------------------------------------
|
||||
;; KreiselInsert: Manuell Position + Parameter
|
||||
;; Abfrage: 1. Basispunkt (AN-Seite), 2. Abstand als Gummiband-Linie - die
|
||||
;; Richtung der Linie ist zugleich die Rotation (Wert tippen = direkte
|
||||
;; Distanzeingabe in Zeigerichtung), 3. Hoehe (Vorgabe aus angeklicktem
|
||||
;; Block bzw. Z des Basispunkts), 4. Kreiselart.
|
||||
;; --------------------------------------------
|
||||
(defun c:KreiselInsert ( / pt abstand typ rotation rotStr hoehe
|
||||
(defun c:KreiselInsert ( / pt p2 erg abstand typ rotation hoehe hoehe-vorgabe
|
||||
selectedEnt blockAttribs oldOsmode)
|
||||
(ssg-start (ssg-text "kreisel-start-insert") '(("OSMODE") ("CECOLOR")))
|
||||
|
||||
|
||||
;; Temporär Osnap für Blockerkennung setzen
|
||||
(setq oldOsmode (getvar "OSMODE"))
|
||||
(setvar "OSMODE" (logior oldOsmode 512)) ;; 512 = INS (Block-Einfügepunkt)
|
||||
|
||||
;; 1. Einfuegepunkt
|
||||
|
||||
;; 1. Basispunkt (AN-Seite)
|
||||
(setq pt (getpoint (ssg-text "kreisel-prompt-basispunkt")))
|
||||
(if (null pt)
|
||||
(progn
|
||||
(setvar "OSMODE" oldOsmode)
|
||||
(ssg-end)
|
||||
(princ (ssg-text "kreisel-abbruch-befehl"))
|
||||
(princ)
|
||||
(return)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
;; Osnap zurücksetzen auf den ursprünglichen Wert
|
||||
(setvar "OSMODE" oldOsmode)
|
||||
|
||||
;; 2. Prüfen ob ein Block getroffen wurde
|
||||
(setq selectedEnt (nentselp pt))
|
||||
|
||||
;; --- HÖHE BESTIMMEN ---
|
||||
(cond
|
||||
;; Fall 1: Auf einem Kreisel-Block geklickt
|
||||
((and selectedEnt
|
||||
(setq selectedEnt (car selectedEnt))
|
||||
(setq blockAttribs (ssg-attrib-read selectedEnt))
|
||||
(assoc "HOEHE" blockAttribs))
|
||||
(setq hoehe (atof (cdr (assoc "HOEHE" blockAttribs))))
|
||||
(princ (ssg-textf "kreisel-hoehe-von-bestehendem" (list (rtos hoehe 2 0))))
|
||||
)
|
||||
;; Fall 2: Punkt hat Z-Koordinate > 0
|
||||
((and (> (length pt) 2) (> (caddr pt) 0))
|
||||
(setq hoehe (caddr pt))
|
||||
(princ (ssg-textf "kreisel-hoehe-aus-3dpunkt" (list (rtos hoehe 2 0))))
|
||||
)
|
||||
;; Fall 3: Sonst separat abfragen
|
||||
(t
|
||||
(setq hoehe (getreal (ssg-textf "kreisel-prompt-hoehe-z" (list (rtos *kreisel-default-hoehe* 2 0)))))
|
||||
(if (null hoehe) (setq hoehe *kreisel-default-hoehe*))
|
||||
|
||||
(if (null pt)
|
||||
(princ (ssg-text "kreisel-abbruch-befehl"))
|
||||
(progn
|
||||
;; Hoehen-Vorgabe: angeklickter Block mit HOEHE, sonst Z des Punkts,
|
||||
;; sonst Default (abgefragt wird erst nach dem Abstand)
|
||||
(setq selectedEnt (nentselp pt))
|
||||
(setq hoehe-vorgabe
|
||||
(cond
|
||||
((and selectedEnt
|
||||
(setq selectedEnt (car selectedEnt))
|
||||
(setq blockAttribs (ssg-attrib-read selectedEnt))
|
||||
(assoc "HOEHE" blockAttribs))
|
||||
(atof (cdr (assoc "HOEHE" blockAttribs))))
|
||||
((and (> (length pt) 2) (> (caddr pt) 0))
|
||||
(caddr pt))
|
||||
(t *kreisel-default-hoehe*)
|
||||
)
|
||||
)
|
||||
|
||||
;; 2. Abstand (Tangentenlaenge) - Linie gibt auch den Winkel vor
|
||||
(setq p2 (getpoint pt (ssg-textf "kreisel-prompt-abstand"
|
||||
(list (rtos *kreisel-default-laenge* 2 0)))))
|
||||
(setq erg (kreisel-insert-richtung pt p2 *kreisel-default-laenge*)
|
||||
abstand (car erg)
|
||||
rotation (cadr erg))
|
||||
(princ (ssg-textf "kreisel-abstand-ausgabe" (list (rtos abstand 2 0))))
|
||||
|
||||
;; 3. Hoehe (Z-Koordinate)
|
||||
(setq hoehe (getreal (ssg-textf "kreisel-prompt-hoehe-z" (list (rtos hoehe-vorgabe 2 0)))))
|
||||
(if (null hoehe) (setq hoehe hoehe-vorgabe))
|
||||
|
||||
;; 4. Kreiselart
|
||||
(setq typ (kreisel-ask-typ))
|
||||
|
||||
(princ (ssg-textf "kreisel-insert-zusammenfassung"
|
||||
(list (rtos rotation 2 1) (rtos hoehe 2 0) typ)))
|
||||
|
||||
;; Modul einfuegen
|
||||
(draw-module (list (car pt) (cadr pt) hoehe) abstand rotation
|
||||
(list (cons "KREISELART" typ)
|
||||
(cons "HOEHE" (rtos hoehe 2 0))))
|
||||
|
||||
(princ (ssg-text "kreisel-insert-fertig"))
|
||||
)
|
||||
)
|
||||
|
||||
;; 3. Abstand
|
||||
(initget 6)
|
||||
(setq abstand (getdist (list (car pt) (cadr pt))
|
||||
(ssg-textf "kreisel-prompt-abstand" (list (rtos *kreisel-default-laenge* 2 0)))))
|
||||
(if (null abstand) (setq abstand *kreisel-default-laenge*))
|
||||
(princ (ssg-textf "kreisel-abstand-ausgabe" (list (rtos abstand 2 0))))
|
||||
|
||||
;; 4. Rotation
|
||||
(setq rotStr (getstring (ssg-text "kreisel-prompt-rotation")))
|
||||
(if (= rotStr "")
|
||||
(setq rotation 0.0)
|
||||
(setq rotation (atof rotStr))
|
||||
)
|
||||
|
||||
;; 5. Kreiselart
|
||||
(setq typ (kreisel-ask-typ))
|
||||
|
||||
(princ (ssg-textf "kreisel-insert-zusammenfassung"
|
||||
(list (rtos rotation 2 1) (rtos hoehe 2 0) typ)))
|
||||
|
||||
;; 6. Modul einfuegen
|
||||
(draw-module (list (car pt) (cadr pt) hoehe) abstand rotation
|
||||
(list (cons "KREISELART" typ)
|
||||
(cons "HOEHE" (rtos hoehe 2 0))))
|
||||
|
||||
;; KEIN weiteres (setvar "OSMODE" ...) mehr nötig!
|
||||
;; ssg-end stellt nur CLAYER und CMDECHO wieder her, nicht OSMODE
|
||||
|
||||
(princ (ssg-text "kreisel-insert-fertig"))
|
||||
(ssg-end)
|
||||
(princ)
|
||||
)
|
||||
|
||||
|
||||
@@ -1429,6 +1509,9 @@
|
||||
(dbgp (strcat "INSERT Block: " *block-path* "AN8_" *ki-dxfm-dim* ".dwg"))
|
||||
(command "_.INSERT" (strcat *block-path* "AN8_" *ki-dxfm-dim* ".dwg") (list 0.0 0.0 0.0) 1 1 0)
|
||||
|
||||
;; Drehrichtungspfeil auf die Radmitte (GUZ gespiegelt)
|
||||
(kreisel-pfeile-einfuegen (eckrad-pfeil-params (cdr (assoc "DREHRICHTUNG" attribs))))
|
||||
|
||||
;; Unsichtbare Attribut-Definitionen erzeugen
|
||||
(dbgp (strcat "Erzeuge " (itoa (length *eckrad-attrib-defs*)) " Attribut-Definitionen"))
|
||||
(ssg-attrib-make-defs *eckrad-attrib-defs* 50.0)
|
||||
@@ -1461,6 +1544,8 @@
|
||||
(progn
|
||||
(princ (ssg-textf "kreisel-bestehende-blockdef" (list bname)))
|
||||
(dbgp (strcat "Verwende bestehende Blockdefinition: " bname))
|
||||
;; EckradEdit behaelt ECKRAD_n - Spiegelung des Pfeils nachziehen
|
||||
(kreisel-pfeil-aktualisieren bname (cdr (assoc "DREHRICHTUNG" attribs)))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user